/* FxSound DSP Tutorial — styles. No external fonts or assets.
   Colours follow FxSound: the reds used in the app's code (#d51535, #e63462, #e33250, #f7546f, #fe566a, #ef4b65)
   and the website's buttons (#ee3f53, rounded, uppercase). Nunito Sans / Rubik are used when the host page
   (fxsound.com) already provides them; otherwise the system font is used. */
:root {
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #171717;
  --muted: #5f6368;
  --border: #e3e3e3;
  --accent: #e33250;
  --accent-strong: #d51535;
  --accent-weak: #fdecef;
  --btn: #ee3f53;
  --btn-hover: #d51535;
  --track: #e33250;
  --key: #ffffff;
  --key-border: #c7c7c7;
  --key-active: #e33250;
  --grid: #ececec;
  --warn: #d51535;
  /* Plot series. In the waveform, FxSound's output (--wet-light) is drawn twice: opaque under the original and
     60% see-through over it, so the original always shows through. Lines (zoom, spectrum, gain) use --wet. */
  --dry: #374151;
  --wet: #d51535;
  --wet-light: #fe566a;
  --wet-only: #fe566a;   /* waveform: output with no original under it */
  --mix: #ae4e60;        /* waveform: 60% --wet-light over --dry, where output and original overlap */
  --diff: #1c7ed6;
  --lev: #1c7ed6;
  --eqc: #6741d9;
  --cursor: #868e96;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f; --card: #1a1a1a; --text: #f1f1f1; --muted: #a3a3a3; --border: #2e2e2e;
    --accent: #f7546f; --accent-strong: #fe566a; --accent-weak: #3a1820; --btn-hover: #ef4b65;
    --key: #ececec; --key-border: #4a4a4a; --key-active: #e33250; --grid: #262626; --warn: #fe566a;
    --dry: #ced4da; --wet: #fe566a; --wet-light: #fe566a; --wet-only: #fe566a; --mix: #ea8997;
    --diff: #4dabf7; --lev: #4dabf7; --eqc: #9775fa;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0f; --card: #1a1a1a; --text: #f1f1f1; --muted: #a3a3a3; --border: #2e2e2e;
  --accent: #f7546f; --accent-strong: #fe566a; --accent-weak: #3a1820; --btn-hover: #ef4b65;
  --key: #ececec; --key-border: #4a4a4a; --key-active: #e33250; --grid: #262626; --warn: #fe566a;
  --dry: #ced4da; --wet: #fe566a; --wet-light: #fe566a; --wet-only: #fe566a; --mix: #ea8997;
  --diff: #4dabf7; --lev: #4dabf7; --eqc: #9775fa;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { font-family: Rubik, "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 500; }
a { color: var(--accent); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; }

.page-header, .page-footer { max-width: 1400px; margin: 0 auto; padding: 24px 16px 8px; }
.page-header h1 { margin: 0 0 6px; font-size: 1.8rem; }
.lede { margin: 0; color: var(--muted); max-width: 820px; }
.page-footer { color: var(--muted); font-size: 0.85rem; padding-bottom: 32px; }
/* Embedded: the host page supplies the title. The footer stays, because it carries the AGPL source link. */
html.embed .page-header { display: none; }

.layout { max-width: 1400px; margin: 0 auto; padding: 12px 16px; display: grid; gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.card h2 { margin: 0 0 8px; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.card h3 { margin: 18px 0 8px; font-size: 0.9rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.85rem; flex: none;
}
.hint, .view-hint { color: var(--muted); margin: 0 0 12px; font-size: 0.92rem; }
.hint.next { margin: 14px 0 0; }

/* ---- Workbench: fixed graph pane + scrollable controls pane ------------------------------------ */
.workbench { display: grid; gap: 12px; scroll-margin-top: 8px; }
.controls-pane { display: grid; gap: 12px; align-content: start; min-width: 0; }
.controls-pane:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
.graph-pane { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px 16px; }
.graph-head { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.graph-head h2 { margin: 0; }
.graph-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.graph-foot .play { gap: 8px; flex: 1 1 420px; min-width: 0; flex-wrap: nowrap; justify-content: flex-end; }
.graph-foot .play .status { flex: 0 1 230px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.graph-foot .play .badge { white-space: nowrap; }
.explain #explain-body p { margin: 0 0 10px; }
.explain .source { color: var(--muted); font-size: 0.82rem; margin: 8px 0 0; }

/* Wide and tall screens: the workbench fills the window. Only the controls pane (and the explanation)
   scroll, so the graph stays in view while controls change. */
@media (min-width: 980px) and (min-height: 620px) {
  .workbench {
    height: calc(100vh - 16px); height: calc(100dvh - 16px);
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "graph explain" "controls explain";
  }
  .graph-pane { grid-area: graph; }
  .controls-pane { grid-area: controls; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
  .explain { grid-area: explain; overflow-y: auto; overscroll-behavior: contain; }
  #plot { height: clamp(170px, 34vh, 360px); }
}
/* Narrow or short screens: one page scroll, with the graph pane pinned to the top. */
@media not all and (min-width: 980px) and (min-height: 620px) {
  .graph-pane { position: sticky; top: 0; z-index: 5; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); gap: 6px; padding: 8px 10px; }
  #plot { height: clamp(140px, 24vh, 300px); }
  .graph-foot .badge, .graph-foot .status { display: none; }
}
/* Phones: keep the pinned pane short so most of the screen is left for the controls. */
@media (max-width: 640px) {
  .graph-head h2 { display: none; }
  .graph-head .tabs { flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  .graph-pane .tab, .graph-pane .btn { font-size: 0.7rem; padding: 5px 9px; white-space: nowrap; flex: none; }
  .graph-pane .legend { font-size: 0.78rem; }
  .graph-foot .play { gap: 6px; flex-basis: auto; justify-content: flex-start; }
}

.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap { gap: 10px; margin-top: 10px; }

/* ---- Buttons (as on fxsound.com: red, rounded, uppercase) -------------------------------------- */
.btn, .tab {
  font: inherit; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.2;
  border-radius: 10px; padding: 8px 14px; cursor: pointer;
  border: 1.5px solid var(--btn); background: transparent; color: var(--btn);
}
.btn:hover, .tab:hover { border-color: var(--btn-hover); color: var(--btn-hover); }
.btn.primary, .tab.active { background: var(--btn); border-color: var(--btn); color: #fafafa; }
.btn.primary:hover, .tab.active:hover { background: var(--btn-hover); border-color: var(--btn-hover); color: #fafafa; }
.tab { padding: 6px 12px; }
.btn:focus-visible, .tab:focus-visible, .key:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.badge { background: var(--accent-weak); color: var(--accent-strong); border-radius: 999px; padding: 3px 10px; font-size: 0.82rem; }
.status { color: var(--muted); font-size: 0.85rem; }
.check, .switch { display: inline-flex; align-items: center; gap: 6px; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Sliders: native round thumb, track filled up to the thumb in FxSound red ------------------------ */
input[type="range"] { width: 100%; accent-color: var(--track); }
input[type="range"]:disabled { cursor: not-allowed; }

/* ---- Keyboard ------------------------------------------------------------------------------------ */
.keyboard { display: flex; overflow-x: auto; padding: 4px 0 8px; gap: 2px; scroll-snap-type: x proximity; }
.key {
  flex: 0 0 34px; height: 120px; border: 1px solid var(--key-border); border-radius: 0 0 6px 6px;
  background: var(--key); color: #171717; font: 600 11px/1.1 system-ui, sans-serif; cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 0 0 6px;
  scroll-snap-align: start; transition: background-color 0.08s;
}
.key small { font-weight: 400; color: #5f6368; font-size: 9px; }
.key.c-key { border-left-width: 3px; }
.key:active, .key.flash { background: var(--key-active); border-color: var(--accent-strong); color: #fff; }
.key:active small, .key.flash small { color: #fff; }

.sequence { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; margin-top: 6px; }
.chip {
  font: inherit; font-size: 0.85rem; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px;
  background: var(--accent-weak); color: var(--text); cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.empty { background: none; color: var(--muted); cursor: default; }

/* ---- Generic labelled range ---------------------------------------------------------------------- */
.control-line {
  display: grid; grid-template-columns: 170px minmax(0, 1fr) 140px; align-items: center; gap: 10px; margin-top: 12px;
}
.control-line label { font-weight: 600; }
.control-line output { font-variant-numeric: tabular-nums; text-align: right; }
.control-line.disabled { opacity: 0.45; }
@media (max-width: 560px) { .control-line { grid-template-columns: 1fr 90px; } .control-line label { grid-column: 1 / -1; } }

.effects, .settings { display: grid; gap: 2px; }
.effects .control-line, .settings .control-line { margin-top: 6px; }
.note { color: var(--muted); font-size: 0.82rem; grid-column: 1 / -1; margin-top: -2px; }

/* ---- Equalizer with vertical sliders -------------------------------------------------------------- */
.eq { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
.band { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.band input[type="range"] { writing-mode: vertical-lr; direction: rtl; width: 28px; height: 150px; }
.band output { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.band span { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 560px) { .eq { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 14px; } }

/* ---- Stage list ------------------------------------------------------------------------------------- */
.pipeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pipeline li {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px;
}
.pipeline li .group { grid-column: 2; color: var(--muted); font-size: 0.82rem; }
.pipeline li.inactive { opacity: 0.55; }
.pipeline li .why { grid-column: 2; font-size: 0.85rem; color: var(--warn); }

/* ---- Plot --------------------------------------------------------------------------------------------- */
#plot { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 8px; display: block; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 8px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }
.legend .dry i { background: var(--dry); }
.legend .wet i { background: var(--wet-only); }
.legend .mix i { background: var(--mix); }
.legend .diff i { background: var(--diff); }
.legend .lev i { background: var(--lev); }
.legend .eqc i { background: var(--eqc); }

/* ---- Tables ------------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin-top: 10px; }
.readout { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.88rem; }
.readout th, .readout td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; white-space: nowrap; }
.readout thead th { color: var(--muted); font-weight: 600; }
.clip { color: var(--warn); font-weight: 600; }

/* Note frequency table */
.notes { margin-top: 10px; }
.notes summary { cursor: pointer; font-weight: 600; color: var(--accent-strong); }
.notes .hint { margin: 8px 0 0; }
.notes .readout td, .notes .readout th { text-align: right; }
