:root {
  color-scheme: light;
  --ink: #221b16;
  --ink-soft: #57483b;
  --paper: #f6f1e8;
  --paper-strong: #efe7da;
  --surface: rgba(255, 251, 244, 0.82);
  --surface-solid: #fffaf2;
  --border: rgba(62, 45, 30, 0.2);
  --border-strong: rgba(62, 45, 30, 0.36);
  --accent: #8c3b2f;
  --accent-strong: #6f1f16;
  --gold: #b27a37;
  --in-tune: #6f8f52;
  --in-tune-strong: #4f6a38;
  --tune-gray: #9c9186;
  --shadow-soft: 0 10px 30px rgba(34, 27, 22, 0.1);
  --shadow-strong: 0 18px 45px rgba(34, 27, 22, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  line-height: 1.55;
  background:
    radial-gradient(circle at 85% 8%, rgba(178, 122, 55, 0.16), transparent 35%),
    radial-gradient(circle at 12% 22%, rgba(140, 59, 47, 0.1), transparent 34%),
    repeating-linear-gradient(
      180deg,
      rgba(57, 43, 31, 0.035) 0,
      rgba(57, 43, 31, 0.035) 1px,
      transparent 1px,
      transparent 36px
    ),
    linear-gradient(180deg, #fcf7ef 0%, #f3eadb 100%);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.6rem 1.1rem 3.4rem;
  display: grid;
  gap: 1.35rem;
}

.hero {
  text-align: center;
  position: relative;
  padding: 1.4rem 0.7rem 0.1rem;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  left: 50%;
  width: min(520px, 78vw);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(62, 45, 30, 0.46), transparent);
}

.hero::before {
  top: 0.3rem;
}

.hero::after {
  bottom: -0.2rem;
}

.eyebrow {
  margin: 0;
  font-family: "Marck Script", "Brush Script MT", cursive;
  font-size: clamp(1.2rem, 2.6vw, 1.7rem);
  color: var(--accent);
}

.hero h1 {
  margin: 0.2rem 0 0.55rem;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.4rem, 5.2vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: #2d221b;
}

.strobetuner {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  border-radius: 1.05rem;
  padding: 0.8rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
}

/* ---- sticky "live" area: the current reading, disc and Start/Stop
   control stay pinned at the top of the viewport as the settings below
   scroll past, matching /tuner/'s .tuner-live. Padding trimmed down to
   just enough for the sticky header not to feel cramped — the disc
   itself is the priority, not the frame around it. ---- */
.strobetuner-live {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 0.5rem;
  margin: -0.8rem -0.8rem 0;
  padding: 0.9rem 0.6rem 0.6rem;
  background: var(--surface-solid);
  border-radius: 1.05rem 1.05rem 0 0;
  border-bottom: 1px solid var(--border);
}

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

/* ---- note readout: which pitch class the autocorrelation detector has
   identified — the /tuner/-style half of this page's hybrid, distinct
   from the disc below it (which shows *that* note's per-octave tuning,
   the /multistrobe/-style half). ---- */
.note-readout {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.15rem;
  min-height: clamp(3.2rem, 9vw, 4rem);
  text-align: center;
}

.note-name {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: clamp(2.6rem, 8vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: color-mix(in srgb, var(--tune-gray) calc(var(--tune-mix, 0) * 1%), var(--accent-strong));
  transition: color 160ms ease;
}

.strobetuner.in-tune .note-name {
  color: var(--in-tune-strong);
}

.note-name.is-no-signal {
  font-size: clamp(1.3rem, 3.8vw, 1.7rem);
  letter-spacing: 0;
  white-space: nowrap;
}

.strobetuner.in-tune .note-name.is-no-signal {
  color: #e2261c;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(226, 38, 28, 0.4);
}

.no-signal-hint {
  font-family: "Cormorant Garamond", Georgia, serif;
  color: #e2261c;
  font-size: clamp(0.9rem, 2.6vw, 1.1rem);
  text-align: center;
  text-shadow: 0 0 12px rgba(226, 38, 28, 0.4);
}

.no-signal-hint[hidden] {
  display: none;
}

.strobetuner-explainer {
  text-align: center;
  max-width: 38rem;
  margin: 0 auto;
}

.transport-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
}

.tap-status {
  text-align: center;
  min-height: 1.1em;
}

.tuning-statement {
  margin: 0;
  text-align: center;
  color: var(--accent-strong);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

.control-block {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.9rem;
  display: grid;
  gap: 0.7rem;
  align-content: start;
  max-width: 26rem;
  margin: 0 auto;
  width: 100%;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  margin-right: auto;
}

.hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.hint.is-error {
  color: var(--accent-strong);
}

/* ---- collapsible frames: every panel-header carries a toggle; clicking
   it hides everything in the .control-block except the header itself,
   collapsing the frame down to a title bar. ---- */
.collapse-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 0.5rem;
}

.collapse-toggle:hover {
  background: var(--paper-strong);
  color: var(--ink);
}

.collapse-icon {
  display: inline-block;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 150ms ease;
}

.collapse-toggle[aria-expanded="false"] .collapse-icon {
  transform: rotate(-90deg);
}

.control-block.is-collapsed > *:not(.panel-header) {
  display: none;
}

.fine-freq-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
}

.fine-freq-value {
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-size: 0.85rem;
  white-space: nowrap;
}

.fine-freq-value input[type="number"] {
  width: 3.2ch;
  border: none;
  background: none;
  padding: 0;
  text-align: right;
  font: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-strong);
  -moz-appearance: textfield;
  appearance: textfield;
  border-radius: 0.65rem;
}

.fine-freq-value input[type="number"]::-webkit-inner-spin-button,
.fine-freq-value input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.panel-slider {
  width: 100%;
}

/* ---- shared primitives ---- */
input,
select,
button {
  font: inherit;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle-btn {
  width: min(170px, 100%);
  justify-self: center;
  border: 1px solid rgba(123, 71, 32, 0.55);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  background: linear-gradient(145deg, #b57a38, #885123);
  color: #fffdf8;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 3px 9px rgba(82, 47, 20, 0.2);
}

.toggle-btn:hover {
  filter: brightness(1.04);
}

.toggle-btn[aria-pressed="true"] {
  background: linear-gradient(145deg, #d1453a, #9c2620);
  border-color: rgba(156, 38, 32, 0.65);
  box-shadow: 0 3px 10px rgba(156, 38, 32, 0.35);
}

.small-btn {
  border: 1px solid var(--border-strong);
  background: #fff9f1;
  color: var(--ink);
  border-radius: 0.65rem;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.small-btn:hover {
  background: #fff3e3;
}

.toggle-btn:focus-visible,
.small-btn:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(163, 86, 34, 0.9);
  outline-offset: 2px;
}

/* ============================================================
   STROBE DISC STAGE — a single, large instance of the same disc
   /multistrobe/ draws twelve small copies of (see shared/strobe-disc.js).
   Unlike /multistrobe/'s 90°-arc discs (sized to fit 12 across a
   keyboard), this page hands the engine a much wider, half-circle
   geometry (see STAGE_GEOMETRY in script.js) so a single disc can be the
   hero of the page.
   ============================================================ */
.strobetuner-disc-stage {
  display: flex;
  justify-content: center;
  padding: 0 0 0.3rem;
}

/* The rings are the entire point of this page, so the disc gets as much
   width as the card can spare — a much higher cap than a purely
   decorative device would need. */
.strobetuner-disc-wrap {
  width: min(720px, 100%);
  display: grid;
  justify-items: center;
}

.strobetuner-disc-wrap .strobe-disc {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  width: 100%;
}

/* Only one disc is ever mounted at a time (see setActiveDisc in
   script.js), which hides the previous one via the `hidden` attribute —
   but the `display: grid` rule above has higher specificity than the
   browser's default `[hidden] { display: none }`, so it needs restating
   here or a hidden disc would still render. */
.strobetuner-disc-wrap .strobe-disc[hidden] {
  display: none;
}

/* The disc's own note label (drawn by shared/strobe-disc.js under every
   disc, including /multistrobe/'s small ones) would just repeat what the
   big .note-name readout above already says here, so it's hidden on this
   page rather than duplicated. */
.strobetuner-disc-wrap .disc-label {
  display: none;
}

.disc-device {
  display: block;
  width: 100%;
  overflow: visible;
  transition: filter 300ms ease;
}

.disc-case {
  fill: url(#discCaseGradient);
  filter: drop-shadow(0 3px 8px rgba(61, 31, 15, 0.18));
}

.disc-window {
  fill: url(#discWindowGradient);
  transition: filter 300ms ease;
}

/* A real strobe disc's wedges are just black and white — the pattern's
   *motion* (or stillness) carries the tuning information, not a color
   change, so unlike /multistrobe/'s colored rings, active and in-tune
   here render identically (both bright white); only whether the ring is
   actually spinning tells them apart. Idle rings sit dim and low-
   contrast, like a wheel with its light off. */
.disc-ring path {
  fill: #3a3a3a;
  opacity: 0.55;
  transition: fill 220ms ease, opacity 220ms ease;
}

.disc-ring.is-active path,
.disc-ring.in-tune path {
  fill: #fbfaf7;
  opacity: 1;
}

/* In tune specifically means "stopped spinning" (see shared/strobe-disc.js
   RING_DEADZONE_CENTS), so it earns a soft white glow on top of the same
   plain white fill every active ring gets — a reward for stillness, still
   strictly monochrome. */
.disc-ring.in-tune path {
  filter: drop-shadow(0 0 2.5px rgba(255, 255, 255, 0.9));
}

.disc-hub {
  fill: #f6f1e8;
}

/* "Illuminating" the whole disc when anything is sounding — the window
   backlight brightens and the whole device gains a touch of contrast,
   distinct from any single ring's own state. */
.strobe-disc.is-active .disc-window {
  filter: brightness(1.9) saturate(1.05);
}

.strobe-disc.is-active .disc-device {
  filter: brightness(1.06) contrast(1.05);
}

/* A soft golden glow layered on top of whichever coloring a ring already
   has (idle/active/in-tune) — marks it as autocorrelation's "best guess"
   fundamental octave, without overriding what its own Goertzel reading
   says about it. */
.disc-ring.is-fundamental path {
  filter: drop-shadow(0 0 3px rgba(178, 122, 55, 0.85)) drop-shadow(0 0 1px rgba(178, 122, 55, 0.95));
}

/* ---- reference bezel: static calibration ticks + flat/sharp glyphs
   around the disc's outer rim, drawn once per disc by addScaleTicks() in
   script.js. Decorative framing, not a readable scale — see that
   function's comment. ---- */
.disc-scale-tick {
  stroke: var(--border-strong);
  stroke-width: 0.6;
}

.disc-scale-tick-major {
  stroke: var(--gold);
  stroke-width: 1;
}

.disc-scale-label {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 9px;
  fill: var(--gold);
  dominant-baseline: middle;
}

/* ============================================================
   OCTAVE LEGEND — one row per ring of the active disc, mirroring its
   note name and live cents reading (see buildLegend/updateDiscExtras in
   script.js). Only one .octave-legend-disc is ever visible at a time,
   matching whichever disc is currently mounted.
   ============================================================ */
.octave-legend {
  width: min(320px, 100%);
  margin: 0 auto;
  padding: 0.2rem 0 0.4rem;
}

.octave-legend-disc {
  display: grid;
  gap: 0.3rem;
}

.octave-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  height: 2.2rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface-solid);
  font-variant-numeric: tabular-nums;
  transition: border-color 160ms ease, background 160ms ease;
}

.octave-legend-note {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink-soft);
}

.octave-legend-cents {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tune-gray);
}

.octave-legend-row.is-active .octave-legend-note {
  color: var(--accent-strong);
}

.octave-legend-row.is-active .octave-legend-cents {
  color: color-mix(in srgb, var(--tune-gray) calc(var(--tune-mix, 0) * 1%), var(--accent-strong));
}

.octave-legend-row.is-in-tune {
  border-color: var(--in-tune);
  background: color-mix(in srgb, var(--in-tune) 12%, var(--surface-solid));
}

.octave-legend-row.is-in-tune .octave-legend-note,
.octave-legend-row.is-in-tune .octave-legend-cents {
  color: var(--in-tune-strong);
}

/* The autocorrelation-identified fundamental gets the same golden
   treatment as its ring on the disc (see .disc-ring.is-fundamental) —
   left as a border/glow accent rather than a text color change so it
   doesn't fight with the is-active/is-in-tune coloring above. */
.octave-legend-row.is-fundamental {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}

/* ---- Input Monitor: gain boost + level meter, same as /tuner/'s. ---- */
.signal-block .hint {
  text-align: center;
}

.signal-meters-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2.2rem;
  padding-top: 0.2rem;
}

.vertical-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.vertical-control-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.vertical-control-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-strong);
  width: 4.6rem;
  text-align: center;
  white-space: nowrap;
}

.vertical-slider-wrap {
  position: relative;
  width: 44px;
  height: 160px;
}

.vertical-slider-wrap .vertical-slider {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 160px;
  height: 32px;
  margin: 0;
  transform: translate(-50%, -50%) rotate(-90deg);
  accent-color: var(--accent);
}

.level-meter-case {
  width: 44px;
  height: 160px;
  padding: 4px;
  border-radius: 1rem;
  background: linear-gradient(145deg, #caa06a, #8a5a30);
  box-shadow: 0 2px 5px rgba(61, 31, 15, 0.14);
}

.level-meter-track {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 0.7rem;
  background: linear-gradient(180deg, #241b14, #171310);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.level-meter-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: color-mix(in srgb, var(--accent) calc(var(--level-mix, 0) * 1%), var(--gold));
  transition: height 90ms linear;
}

.footer {
  text-align: center;
  color: var(--ink-soft);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.22rem;
}

.footer-links,
.footer-contact {
  margin: 0.3rem 0 0;
  font-family: Inter, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 0.85rem;
}

.footer-links a,
.footer-contact a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.05rem;
  transition: color 120ms ease, border-color 120ms ease;
}

.footer-links a:hover,
.footer-contact a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 720px) {
  .page {
    padding-top: 2rem;
  }

  .strobetuner {
    padding: 0.6rem;
  }

  .strobetuner-live {
    margin: -0.6rem -0.6rem 0;
    padding: 0.8rem 0.5rem 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
