/* spectrumanalyzeronline.com — dark instrument aesthetic */

:root {
  --bg:          oklch(0.145 0.008 250);
  --bg-raised:   oklch(0.195 0.010 250);
  --bg-sunken:   oklch(0.105 0.006 250);
  --line:        oklch(0.28 0.012 250);
  --line-soft:   oklch(0.22 0.010 250);
  --text:        oklch(0.94 0.004 250);
  --text-dim:    oklch(0.70 0.008 250);
  --text-faint:  oklch(0.52 0.010 250);
  --accent:      oklch(0.78 0.15 195);
  --accent-deep: oklch(0.62 0.13 195);
  --accent-2:    oklch(0.80 0.15 75);

  --font-ui:   "Space Grotesk", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  --measure: 68ch;
  --pad: clamp(1.25rem, 4vw, 3rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ---------- shared primitives ---------- */

.label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.rule {
  height: 1px;
  background: var(--line-soft);
  border: 0;
  margin: 0;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--pad);
  border-bottom: 1px solid var(--line-soft);
}

.wordmark {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
.wordmark b { color: var(--text); font-weight: 500; }

.masthead nav {
  display: flex;
  gap: 1.5rem;
}
.masthead nav a {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.15s;
}
.masthead nav a:hover { color: var(--accent); }
@media (max-width: 720px) { .masthead nav { display: none; } }

/* ---------- tool: first screen ---------- */

.tool {
  padding: var(--pad);
  display: grid;
  gap: 1.25rem;
  min-height: calc(100svh - 57px);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.tool-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

h1 {
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
}
h1 span { color: var(--text-faint); font-weight: 400; }

/* source toggle */

.sources {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.sources button {
  appearance: none;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.6rem 1.1rem;
  min-height: 44px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.sources button:last-child { border-right: 0; }
.sources button:hover { color: var(--text); }
.sources button[aria-pressed="true"] {
  background: var(--accent);
  color: oklch(0.16 0.02 195);
}

/* canvas stage */

.stage {
  position: relative;
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
  min-height: 200px;
}
/* Absolute so the canvas can never drive the stage height — that feedback loop
   pushes the readouts below the fold. */
.stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  text-align: center;
  padding: 2rem;
  background: var(--bg-sunken);
  transition: opacity 0.25s;
}
.stage-empty[hidden] { display: none; }
.stage-empty p { margin: 0; color: var(--text-faint); max-width: 34ch; font-size: 0.9375rem; }

.stage.dropping { border-color: var(--accent); }

/* readouts */

.readouts {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(200px, 0.8fr) auto;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
}
@media (max-width: 860px) {
  .readouts { grid-template-columns: 1fr; }
  .tool { min-height: 0; }
  .stage { min-height: 46svh; }
}

.panel {
  background: var(--bg);
  padding: 0.875rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: center;
}

.peak-value {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 6vw, 3.25rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.peak-value small {
  font-size: 0.3em;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-left: 0.4em;
}
.peak-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.top5 { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.top5 li {
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.top5 li i { color: var(--text-faint); font-style: normal; }
.top5 .bar {
  height: 2px;
  background: var(--accent-deep);
  border-radius: 1px;
  min-width: 1px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.875rem 1.125rem;
  background: var(--bg);
}

.btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.7rem 1.1rem;
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: oklch(0.16 0.02 195);
}
.btn-primary:hover:not(:disabled) {
  background: oklch(0.85 0.15 195);
  border-color: oklch(0.85 0.15 195);
  color: oklch(0.16 0.02 195);
}

/* view switch + fft control */

.tool-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.controls { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.control { display: flex; align-items: center; gap: 0.6rem; }
.control select {
  appearance: none;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.transport {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.transport[hidden] { display: none; }
.transport .track {
  width: clamp(120px, 22vw, 260px);
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.transport .track i { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- content ---------- */

main.content {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) var(--pad) 0;
}

section { margin-bottom: clamp(3rem, 7vw, 5rem); }

h2 {
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}
section > .label { display: block; margin-bottom: 0.75rem; }

h3 {
  font-size: 1.0625rem;
  font-weight: 500;
  margin: 2rem 0 0.5rem;
}

p { margin: 0 0 1.1rem; color: var(--text-dim); }
p strong { color: var(--text); font-weight: 500; }
main.content a { color: var(--accent); text-decoration-color: color-mix(in oklch, var(--accent), transparent 60%); }

ol.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
ol.steps li {
  counter-increment: s;
  position: relative;
  padding-left: 3rem;
  margin-bottom: 1.5rem;
  color: var(--text-dim);
}
ol.steps li::before {
  content: counter(s, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}
ol.steps b { color: var(--text); font-weight: 500; }

.table-wrap { overflow-x: auto; margin: 1.5rem 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 460px;
}
th, td {
  text-align: left;
  padding: 0.7rem 0.9rem 0.7rem 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
th {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 400;
}
td:first-child {
  font-family: var(--font-mono);
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
td { color: var(--text-dim); }
td.who { color: var(--text); font-family: var(--font-ui); }

.cases { display: grid; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: 3px; margin: 1.5rem 0; }
.cases > div { background: var(--bg); padding: 1.25rem; }
.cases h3 { margin: 0 0 0.4rem; font-size: 0.9375rem; }
.cases p { margin: 0; font-size: 0.9375rem; }

details {
  border-bottom: 1px solid var(--line-soft);
  padding: 1rem 0;
}
details summary {
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: "+";
  font-family: var(--font-mono);
  color: var(--accent);
  flex: none;
}
details[open] summary::after { content: "–"; }
details p { margin: 0.9rem 0 0; }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line-soft);
  margin-top: clamp(3rem, 8vw, 5rem);
  padding: clamp(2.5rem, 6vw, 4rem) var(--pad);
}
.footer-inner { max-width: var(--measure); margin: 0 auto; }
footer h2 { font-size: 1.125rem; }
footer p { font-size: 0.9375rem; }
.colophon {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; }
}
