* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --paper: #0a0b0d;   /* near-black — page + panels */
  --ink:   #e8e6e1;   /* soft off-white — primary text */
  --taupe: #8a8f96;   /* muted gray — captions / secondary labels */
  --line:  rgba(232, 230, 225, 0.10);  /* hairline dividers (light on black) */
  --faint: #464b52;   /* dim — the withheld TRL horizon */
  --signal: #fa8f38;  /* ▶ THE accent colour — one knob for the whole site. Both the CSS accents
                           (legend, focus ring, hover, caret) AND the canvas waveform + glow read
                           this. Change it here to re-theme everything. Try: #5a8cf0 blue,
                           #9b5af0 purple, #f0635a coral (default). */
  --display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1rem, 0.6vw + 0.9rem, 1.18rem);
  line-height: 1.5;
  overflow: hidden;                 /* desktop: one screen, no scroll */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Reveal (per-element, staggered; no-JS safe via .js gate) ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.85s ease, transform 0.85s ease;
  will-change: opacity, transform;   /* the intro JS sequences each line's timing precisely */
}
[data-reveal].is-visible { opacity: 1; transform: none; }

/* ---------- Stage: landscape bento grid ---------- */
.stage {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 2.55fr) minmax(0, 0.85fr);          /* tall wave stage over the sign-up strip */
  grid-template-areas:
    "wave"
    "contact";
  background: var(--paper);
}
.panel {
  position: relative;
  background: var(--paper);
  min-width: 0; min-height: 0;
  padding: clamp(0.85rem, 1.4vw, 1.5rem);
  display: flex;
  flex-direction: column;
}
/* Intro: no fill change — each box simply draws its 1px outline in, then its content animates.
   Borders (not an inset shadow) so single edges can be dropped: the wave/contact junction is
   seamless — a stacked hairline pair there rounds into a fat band on tall screens. */
.panel::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}
.panel.lit::after { opacity: 1; }
.wave::after { border-bottom: none; }
.contact::after { border-top: none; }

/* ---------- Wordmark (lives in the contact box) ---------- */
.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.75rem, 2.9vw, 2.9rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin-bottom: 1.5rem;
}

/* ---------- Waveform ---------- */
.wave { grid-area: wave; gap: 0.5rem; isolation: isolate; }   /* keep the glow blend inside this box */
/* PCB render behind the scope, very much darkened; fades in over 0.75s once the image has
   loaded (js/intro.js adds .bg-ready) — without JS it simply shows statically */
.wave::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../img/background.jpg') center / cover no-repeat;
  opacity: 0.1;
  pointer-events: none;
}
.js .wave::before { opacity: 0; transition: opacity 0.75s ease; }
.js .wave.bg-ready::before { opacity: 0.1; }
/* canvas oscilloscope — drawn in JS (real-time sweep, phosphor fade, soft edges).
   Two stacked GL layers: #glow carries the halo on black and is SCREEN-blended, so its light
   adds over the image and black adds nothing; #wave carries the traces on a transparent canvas
   with normal compositing, so the coral stays full-saturation (screen-blending the crisp line
   washed its green/blue up toward pink). */
.waveband { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; overflow: hidden; }
.wave-cap { position: relative; }                 /* paints above the ::before backdrop */
.waveband canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
#glow { mix-blend-mode: screen; }
/* Legend: one centred label per trace — the coral caption below the band (under the real
   trace's bottom lane), the gray one floated into the inter-lane gap mid-canvas */
.wave-cap { flex: 0 0 auto; }
.js .leg { transition-duration: 1s; }           /* each legend label fades in gently, one at a time */
.leg {
  display: block;
  text-align: center;
  font-size: clamp(0.92rem, 1.1vw, 1.08rem);
  letter-spacing: 0.02em;
  line-height: 1.35;
}
.leg--real { color: var(--signal); }            /* our sensor — coral, matches the red trace */
.leg--ppg {                                     /* traditional PPG — gray, matches the ghost */
  color: var(--taupe);
  position: absolute;
  left: 0; right: 0;
  top: 50%;                                     /* the lane gap is centred on 50% of the band */
  margin-top: -0.7em;                           /* ≈ half a line — no transform (reveal animates it) */
}

/* ---------- Contact (brand + sign up + contact line, one box) ---------- */
.contact { grid-area: contact; justify-content: center; }
.c-head { font-size: 0.95rem; letter-spacing: 0.04em; margin-bottom: 0.55rem; }
.signup {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.signup input[type="email"] {
  font-family: var(--body);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.3rem 0.2rem;
  width: min(17rem, 52vw);
}
.signup input[type="email"]::placeholder { color: var(--taupe); font-style: italic; }
.signup input[type="email"]:focus { outline: none; border-bottom-color: var(--signal); }
.signup button {
  font-family: var(--body);
  font-size: 1.1rem;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink);
  padding: 0.3rem 0.1rem;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.signup button:hover { color: var(--signal); border-bottom-color: var(--signal); }
.signup-done { font-style: italic; color: var(--taupe); }
/* invalid-email flag: sits on its own line under the field, in the accent colour */
.signup input[type="email"][aria-invalid="true"] { border-bottom-color: var(--signal); }
.signup-err {
  flex: 1 0 100%;                 /* force onto its own line, below the field + button */
  margin-top: 0.15rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--signal);          /* the one accent doubles as the attention/flag colour */
}

.reach { margin-top: 0.65rem; }
.reach a {
  display: inline-block;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.reach a:hover { border-bottom-color: var(--signal); }
/* typewriter cursor — solid while typing; contact.js fades it out when the address completes */
.caret {
  display: inline-block;
  width: 1px;
  height: 1.05em;
  background: var(--signal);
  vertical-align: -0.12em;
  margin-left: 2px;
}

/* ---------- Mobile: stack into scrollable boxes ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  .stage {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "wave"
      "contact";
  }
  .panel { padding: clamp(1.1rem, 5vw, 1.8rem); }
  .wave { min-height: auto; }
  .waveband { flex: none; height: clamp(320px, 58vh, 500px); }   /* room for two stacked lanes on mobile */
  .contact { padding-top: 1.6rem; padding-bottom: 1.6rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] { opacity: 1; transform: none; transition: none; }
  .js .wave::before { transition: none; }
  .panel::after { transition: none; }
  .caret { display: none; }
}
