/* Subscribe on Load: push test bench. Dark instrument-panel look; the beacon colour follows body[data-state]. */

:root {
  --bg: #0d0f12;
  --panel: #14181d;
  --line: #262c33;
  --ink: #e9edf1;
  --muted: #8b96a3;
  --signal: #ffb000;
  --tone: #7b8794;
  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

body[data-state='ok'] {
  --tone: #3ddc84;
}

body[data-state='wait'] {
  --tone: #ffb000;
}

body[data-state='bad'] {
  --tone: #ff5d4d;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  background:
    radial-gradient(900px 480px at 88% -8%, rgba(255, 176, 0, 0.1), transparent 62%),
    radial-gradient(760px 420px at -5% 105%, rgba(61, 220, 132, 0.07), transparent 60%), var(--bg);
  overflow-x: hidden;
}

/* faint blueprint grid and film grain */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
}

body::after {
  opacity: 0.06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 20px 48px;
}

/* masthead */
.masthead {
  padding-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--signal);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(3.2rem, 13vw, 7.5rem);
  line-height: 0.86;
  letter-spacing: -0.005em;
  text-transform: uppercase;
}

h1 span {
  color: transparent;
  -webkit-text-stroke: 1.5px var(--ink);
}

.host {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  background: rgba(20, 24, 29, 0.7);
}

.host-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 10px var(--tone);
  transition:
    background 0.4s,
    box-shadow 0.4s;
}

.lede {
  max-width: 62ch;
  margin: 0 0 28px;
  color: var(--muted);
}

/* panels */
.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), var(--panel);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 48px -24px rgba(0, 0, 0, 0.7);
}

.hero {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 20px;
  padding: 28px;
  border-left: 4px solid var(--tone);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.02), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), var(--panel);
  transition: border-color 0.4s;
}

@supports (background: color-mix(in srgb, red 10%, blue)) {
  .hero {
    background:
      linear-gradient(90deg, color-mix(in srgb, var(--tone) 12%, transparent), transparent 62%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), var(--panel);
  }
}

.hero-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

/* beacon: rings spread out like a broadcast signal; the state sets the colour and the tempo */
.beacon {
  position: relative;
  flex: none;
  width: 110px;
  height: 110px;
}

.beacon .core,
.beacon .ring {
  position: absolute;
  inset: 39px;
  border-radius: 50%;
}

.beacon .core {
  background: var(--tone);
  box-shadow:
    0 0 26px var(--tone),
    0 0 4px var(--tone) inset;
  transition:
    background 0.4s,
    box-shadow 0.4s;
}

.beacon .ring {
  border: 2px solid var(--tone);
  opacity: 0;
  animation: ping 3s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}

.beacon .ring:nth-child(2) {
  animation-delay: 1s;
}

.beacon .ring:nth-child(3) {
  animation-delay: 2s;
}

body[data-state='wait'] .beacon .ring {
  animation-duration: 1.6s;
}

body[data-state='wait'] .beacon .ring:nth-child(2) {
  animation-delay: 0.53s;
}

body[data-state='wait'] .beacon .ring:nth-child(3) {
  animation-delay: 1.06s;
}

body[data-state='bad'] .beacon .ring,
body[data-state='unknown'] .beacon .ring {
  animation: none;
}

@keyframes ping {
  from {
    transform: scale(1);
    opacity: 0.7;
  }

  to {
    transform: scale(3.2);
    opacity: 0;
  }
}

/* status text */
.status {
  margin: 0;
}

.status-headline {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: 0.005em;
  text-transform: uppercase;
  color: var(--tone);
}

.status-detail {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  opacity: 0.85;
}

.btn {
  padding: 9px 18px;
  border: 1px solid var(--tone);
  border-radius: 8px;
  color: var(--tone);
  font: 600 13px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.2s;
}

.btn:hover {
  color: var(--bg);
  background: var(--tone);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.event-log:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}

/* readout + log */
.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

@media (min-width: 880px) {
  .columns {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  }
}

.columns .card {
  padding: 22px 24px 24px;
}

h2 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 14px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.idx {
  color: var(--signal);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.diagnostics {
  margin: 0;
}

.diagnostics > div {
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  gap: 16px;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
}

.diagnostics dt {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnostics dd {
  margin: 0;
  overflow-wrap: anywhere;
}

#d-permission[data-value='granted'] {
  color: #3ddc84;
}

#d-permission[data-value='default'] {
  color: #ffb000;
}

#d-permission[data-value='denied'],
#d-permission[data-value='unsupported'] {
  color: #ff5d4d;
}

.event-log {
  max-height: 340px;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: #0a0c0f;
}

.event-log:empty::before {
  content: 'Waiting for events...';
  color: var(--muted);
}

.log-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 10px;
  padding: 2px 0;
  overflow-wrap: anywhere;
  animation: slide-in 0.3s ease-out;
}

.log-time {
  color: var(--muted);
  text-align: right;
}

.log-ok {
  color: #3ddc84;
}

.log-wait {
  color: #ffb000;
}

.log-bad {
  color: #ff5d4d;
}

footer {
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
}

footer code {
  color: var(--ink);
}

/* entrance */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: calc(var(--i, 0) * 90ms);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 28px 16px 40px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 18px 20px 24px;
  }

  .beacon {
    width: 84px;
    height: 84px;
    margin: 0 0 4px -26px;
  }

  .beacon .core,
  .beacon .ring {
    inset: 26px;
  }

  .diagnostics > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .beacon .ring,
  .log-row {
    animation: none;
  }
}
