/* The Frequency Lab — the simulation is the page; everything else floats. */

@font-face { font-family: Fraunces; src: url(../fonts/fraunces-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Fraunces; src: url(../fonts/fraunces-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: Fraunces; src: url(../fonts/fraunces-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url(../fonts/ibm-plex-sans-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url(../fonts/ibm-plex-sans-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url(../fonts/ibm-plex-sans-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --pad: clamp(14px, 1.5vw, 22px);
  --rail: calc(var(--pad) + 102px);   /* clear of the spectrum gauge and its labels */
  --ink: 226 232 244;
  --glass: rgba(11, 15, 25, 0.56);
  --edge: rgba(190, 205, 235, 0.13);
  --r: 16px;
  --tint: hsl(208 54% 54%);
  --tint-soft: hsl(208 54% 54% / .3);
  --tint-faint: hsl(208 54% 54% / .11);
  --bloom: 70%;
  --base: hsl(202 26% 8%);
  --base-far: hsl(196 30% 5%);
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;                        /* one screen, never a scroll */
}

body {
  background: var(--base-far);
  color: rgb(var(--ink));
  font: 400 15px/1.55 'IBM Plex Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.bloom {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 46%, var(--tint-soft) 0%, var(--tint-faint) 38%, transparent 72%);
  background-size: var(--bloom) var(--bloom);
  background-position: 50% 46%;
  background-repeat: no-repeat;
  transition: background 600ms var(--ease), background-size 600ms var(--ease);
  mix-blend-mode: screen;
  z-index: 1;
}

.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(ellipse 120% 90% at 50% 45%, transparent 35%, var(--base) 100%),
    linear-gradient(to bottom, rgba(0,0,0,.35), transparent 22%, transparent 62%, rgba(0,0,0,.42));
  transition: background 600ms var(--ease);
}

/* ── floating chrome ──────────────────────────────────────────────────── */

.card, .deck, .segmented, .sound, .pip, .gauge {
  position: fixed;
  z-index: 5;
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  box-shadow: 0 18px 44px -20px rgba(0, 0, 0, .85);
}

.top {
  position: fixed; z-index: 6;
  top: var(--pad); left: var(--pad); right: var(--pad);
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.mark {
  font: 600 15px/1 Fraunces, Georgia, serif;
  letter-spacing: .01em;
  opacity: .82;
  text-shadow: 0 2px 12px rgba(0,0,0,.7);
}

.tools { display: flex; gap: 8px; align-items: center; }

.segmented, .sound { position: static; padding: 4px; display: flex; gap: 2px; }

.segmented button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: rgb(var(--ink) / .62);
  font: 500 12.5px/1 'IBM Plex Sans', sans-serif;
  padding: 9px 15px; border-radius: 11px;
  transition: background 240ms var(--ease), color 240ms var(--ease);
}
.segmented button[aria-selected="true"] {
  background: var(--tint);
  color: #06080e;
  font-weight: 600;
}
.segmented button:not([aria-selected="true"]):hover { color: rgb(var(--ink) / .95); background: rgba(255,255,255,.05); }

.sound {
  align-items: center; gap: 7px; padding: 9px 14px 9px 12px; cursor: pointer;
  color: rgb(var(--ink) / .62);
  font: 500 12.5px/1 'IBM Plex Sans', sans-serif;
  transition: color 240ms var(--ease), border-color 240ms var(--ease);
}
.sound svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.sound svg path:first-child { fill: currentColor; stroke-linejoin: round; }
.sound .wv1, .sound .wv2 { opacity: 0; transition: opacity 240ms var(--ease); }
.sound .slash { opacity: .85; }
.sound[aria-pressed="true"] { color: var(--tint); border-color: var(--tint-soft); }
.sound[aria-pressed="true"] .wv1, .sound[aria-pressed="true"] .wv2 { opacity: 1; }
.sound[aria-pressed="true"] .slash { opacity: 0; }
.sound[data-nudge="1"]::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--tint);
  animation: pulse 2.2s var(--ease) infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* top-left slot */
.intro, .legend {
  top: calc(var(--pad) + 52px); left: var(--pad);
  width: clamp(250px, 25vw, 340px);
  padding: 18px 20px 20px;
  transition: opacity 420ms var(--ease), transform 420ms var(--ease);
}
.intro[hidden], .legend[hidden] { display: none; }
.intro.fade { opacity: 0; transform: translateY(-6px); pointer-events: none; }

.intro { background: transparent; border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; padding-left: 0; }
.intro h1 {
  font: 400 clamp(34px, 3.9vw, 52px)/1.02 Fraunces, Georgia, serif;
  margin: 0 0 16px; letter-spacing: -.015em;
  text-shadow: 0 4px 26px rgba(0,0,0,.75);
}
.intro h1 .dot { color: var(--tint); }
.intro p { margin: 0 0 5px; font-size: 13.5px; color: rgb(var(--ink) / .70); text-shadow: 0 2px 12px rgba(0,0,0,.8); }
.intro b { color: rgb(var(--ink) / .95); font-weight: 600; }

.kicker {
  margin: 0 0 12px;
  font: 500 9.5px/1 'IBM Plex Mono', monospace;
  letter-spacing: .17em; text-transform: uppercase;
  color: rgb(var(--ink) / .45);
}
.legend ul { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 9px; }
.legend li { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: rgb(var(--ink) / .80); }
.legend .swatch { flex: 0 0 auto; width: 20px; height: 14px; }
.legend .note { margin: 0; font-size: 11.5px; line-height: 1.5; color: rgb(var(--ink) / .48); }

/* hold the microscope's objective so a sweep really does crowd the bands */
.lens {
  display: block; margin: 0 0 13px; padding: 6px 11px;
  border: 1px solid rgb(var(--ink) / .16); border-radius: 999px;
  background: rgb(var(--ink) / .04); color: rgb(var(--ink) / .72);
  font: 500 11px/1 'IBM Plex Sans', sans-serif; cursor: pointer;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease);
}
.lens:hover { border-color: var(--tint-soft); color: rgb(var(--ink) / .92); }
.lens[aria-pressed="true"] {
  background: var(--tint-faint); border-color: var(--tint-soft); color: rgb(var(--ink) / .95);
}
.lens[hidden] { display: none; }

/* picture-in-picture: the scale you are not looking at, still live */
.pip {
  right: var(--rail);
  bottom: calc(var(--pad) + var(--deck-h, 236px) + 14px);
  width: clamp(178px, 16vw, 220px);
  margin: 0; padding: 10px;
  cursor: pointer;
  transition: transform 300ms var(--ease), border-color 300ms var(--ease);
}
.pip:hover, .pip:focus-visible { transform: translateY(-3px); border-color: var(--tint-soft); outline: none; }
.pip canvas { width: 100%; aspect-ratio: 16 / 10; display: block; border-radius: 9px; background: rgba(0,0,0,.32); }
.pip .live {
  position: absolute; top: 18px; left: 20px; z-index: 2;
  display: flex; align-items: center; gap: 5px;
  font: 500 8.5px/1 'IBM Plex Mono', monospace; letter-spacing: .16em;
  color: rgb(var(--ink) / .72);
}
.pip .live i { width: 5px; height: 5px; border-radius: 50%; background: #e0514a; animation: pulse 2.4s var(--ease) infinite; }
.pip figcaption { margin-top: 8px; font: 500 11px/1 'IBM Plex Sans', sans-serif; color: rgb(var(--ink) / .62); }

/* the spectrum ruler */
.gauge {
  right: var(--pad); top: 50%; transform: translateY(-50%);
  width: 44px; height: min(56vh, 380px);
  padding: 14px 0;
  display: flex; justify-content: center;
  background: transparent; border-color: transparent; backdrop-filter: none;
  -webkit-backdrop-filter: none; box-shadow: none;
}
.gauge .track {
  position: relative; width: 8px; height: 100%;
  border-radius: 999px; background: rgba(255,255,255,.07);
  border: 1px solid var(--edge);
}
.gauge .fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  border-radius: 999px;
  background: linear-gradient(to top, hsl(268 58% 46%), var(--tint));
  transition: height 260ms var(--ease);
}
.gauge .knob {
  position: absolute; left: 50%; width: 16px; height: 16px;
  margin-left: -8px; margin-bottom: -8px; border-radius: 50%;
  background: var(--tint); box-shadow: 0 0 18px 3px var(--tint-soft);
  transition: bottom 260ms var(--ease), background 260ms var(--ease);
}
.gauge .ticks { position: absolute; inset: 14px 100% 14px auto; width: 60px; }
.gauge .ticks span {
  position: absolute; right: 10px; transform: translateY(50%);
  font: 400 9px/1 'IBM Plex Mono', monospace;
  color: rgb(var(--ink) / .38); white-space: nowrap;
}
.gauge .ticks span::after {
  content: ''; position: absolute; right: -8px; top: 50%; width: 5px; height: 1px;
  background: rgb(var(--ink) / .28);
}
.gauge .ticks span.edge { color: rgb(var(--ink) / .58); }

/* the narration */
.narrate {
  left: var(--pad); bottom: var(--pad);
  width: clamp(276px, 26vw, 356px);
  padding: 18px 20px 16px;
}
.narrate .band {
  display: inline-block; padding: 4px 9px; border-radius: 999px;
  background: var(--tint-faint); border: 1px solid var(--tint-soft);
  color: rgb(var(--ink) / .88); letter-spacing: .13em;
}
.narrate h2 { margin: 0 0 8px; font: 400 clamp(20px, 2vw, 25px)/1.15 Fraunces, Georgia, serif; letter-spacing: -.01em; }
.narrate .lead { margin: 0 0 8px; font-weight: 600; font-size: 13.5px; color: rgb(var(--ink) / .93); }
.narrate .body { margin: 0; font-size: 12.5px; line-height: 1.62; color: rgb(var(--ink) / .66); }
.anchor-toggle {
  margin-top: 12px; padding: 0; border: 0; background: none; cursor: pointer;
  font: 500 9.5px/1 'IBM Plex Mono', monospace; letter-spacing: .13em; text-transform: uppercase;
  color: rgb(var(--ink) / .34);
  transition: color 220ms var(--ease);
}
.anchor-toggle:hover, .anchor-toggle[aria-expanded="true"] { color: var(--tint); }
.narrate .anchor {
  margin: 9px 0 0; padding-top: 9px; border-top: 1px solid var(--edge);
  font-size: 11.5px; line-height: 1.5; color: rgb(var(--ink) / .55);
}

/* the control deck */
.deck {
  right: var(--rail); bottom: var(--pad);
  width: clamp(468px, 45vw, 592px);
  padding: 18px 20px 20px;
}
.readout { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.readout .hz {
  margin: 0; font: 400 clamp(34px, 3.6vw, 46px)/1 Fraunces, Georgia, serif;
  letter-spacing: -.02em;
}
.readout .lam { margin: 4px 0 0; font-size: 12px; color: rgb(var(--ink) / .55); }
.readout .pill {
  margin: 6px 0 0; flex: 0 0 auto;
  padding: 8px 14px; border-radius: 999px;
  background: var(--tint-faint); border: 1px solid var(--tint-soft);
  font: 500 12.5px/1 'IBM Plex Sans', sans-serif; color: rgb(var(--ink) / .92);
  transition: background 300ms var(--ease), border-color 300ms var(--ease);
}
.readout .pill.silent { background: rgba(224,81,74,.10); border-color: rgba(224,81,74,.34); }

input[type=range] {
  appearance: none; width: 100%; height: 22px; background: none; cursor: pointer; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right,
    hsl(268 60% 46%), hsl(240 58% 50%), hsl(210 54% 55%), hsl(192 50% 60%), hsl(190 32% 72%));
}
input[type=range]::-moz-range-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(to right,
    hsl(268 60% 46%), hsl(240 58% 50%), hsl(210 54% 55%), hsl(192 50% 60%), hsl(190 32% 72%));
}
input[type=range]::-webkit-slider-thumb {
  appearance: none; width: 20px; height: 20px; border-radius: 50%; margin-top: -6px;
  background: #f2f5fb; border: 0; box-shadow: 0 0 0 3px rgba(8,11,18,.55), 0 0 20px 3px var(--tint-soft);
}
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #f2f5fb; border: 0; box-shadow: 0 0 0 3px rgba(8,11,18,.55), 0 0 20px 3px var(--tint-soft);
}
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--tint), 0 0 20px 3px var(--tint-soft); }

.ends {
  display: flex; justify-content: space-between; margin: 2px 2px 12px;
  font: 400 10px/1 'IBM Plex Mono', monospace; color: rgb(var(--ink) / .40);
}

.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.chip {
  min-height: 34px;
  appearance: none; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 9px; border-radius: 11px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--edge);
  color: rgb(var(--ink) / .70);
  font: 500 11px/1.1 'IBM Plex Sans', sans-serif; text-align: left;
  transition: background 220ms var(--ease), border-color 220ms var(--ease), color 220ms var(--ease), transform 220ms var(--ease);
}
.chip:hover { background: rgba(255,255,255,.09); color: rgb(var(--ink) / .95); transform: translateY(-1px); }
.chip[aria-pressed="true"] {
  background: rgba(255,255,255,.94); border-color: transparent; color: #0a0d15; font-weight: 600;
}
.chip svg { flex: 0 0 auto; width: 22px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; opacity: .78; }
.chip[aria-pressed="true"] svg { opacity: 1; }
.chip.locked { color: rgb(var(--ink) / .40); }
.chip.locked svg { stroke-dasharray: 2 2.4; }

/* the secret lab */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(4, 6, 12, .58);
  backdrop-filter: blur(3px);
  animation: fade 260ms var(--ease);
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0 } }
.sheet {
  width: min(600px, 90vw); padding: 30px 34px 32px;
  background: rgba(14, 19, 32, .93);
  border: 1px solid var(--edge); border-radius: 22px;
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.9);
  text-align: center;
  animation: rise 320ms var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) } }
.sheet .kicker { text-align: center; }
.sheet h3 { margin: 0 0 20px; font: 400 clamp(23px, 2.6vw, 31px)/1.15 Fraunces, Georgia, serif; }
.prizes { display: flex; gap: 14px; justify-content: center; margin-bottom: 20px; }
.prizes div {
  flex: 1 1 0; padding: 18px 12px; border-radius: 15px;
  background: rgba(255,255,255,.04); border: 1px solid var(--edge);
}
.prizes b { display: block; font: 400 27px/1 Fraunces, Georgia, serif; margin-bottom: 7px; }
.prizes span { font-size: 11.5px; color: rgb(var(--ink) / .58); }
.prizes .lo { border-color: hsl(268 58% 52% / .45); box-shadow: inset 0 0 30px -8px hsl(268 58% 52% / .35); }
.prizes .hi { border-color: hsl(190 40% 66% / .45); box-shadow: inset 0 0 30px -8px hsl(190 40% 66% / .3); }
.options { display: grid; gap: 9px; margin-bottom: 18px; }
.options button {
  appearance: none; cursor: pointer; padding: 15px 18px; border-radius: 13px;
  background: rgba(255,255,255,.05); border: 1px solid var(--edge);
  color: rgb(var(--ink) / .92); font: 500 13.5px/1.35 'IBM Plex Sans', sans-serif;
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.options button:hover { background: rgba(255,255,255,.11); }
.options button.wrong { border-color: rgba(224,81,74,.6); background: rgba(224,81,74,.12); }
.sheet .note { margin: 0 0 18px; font-size: 12.5px; color: rgb(var(--ink) / .62); }
.dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 18px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--ink) / .18); }
.dots i.now { background: var(--tint); }
.dots i.got { background: #4fbf8b; }
.cta {
  appearance: none; cursor: pointer; padding: 14px 30px; border-radius: 999px; border: 0;
  background: #f2f5fb; color: #0a0d15; font: 600 13.5px/1 'IBM Plex Sans', sans-serif;
  transition: transform 200ms var(--ease);
}
.cta:hover { transform: translateY(-1px); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition-duration: 1ms !important; }
}
