/* Styled after the CCM PowerPoint template (2025): navy text on white, Flatiron
   orange and blue accents, Tiempos Headline titles and Founders Grotesk body text.
   The brand fonts are used when installed; otherwise the bundled open fonts
   Source Serif 4 and Hanken Grotesk stand in. */
@font-face { font-family: "Source Serif 4"; font-weight: 300; src: url("vendor/fonts/source-serif-4-latin-300-normal.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 400; src: url("vendor/fonts/source-serif-4-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 400; src: url("vendor/fonts/hanken-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 600; src: url("vendor/fonts/hanken-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 700; src: url("vendor/fonts/hanken-grotesk-latin-700-normal.woff2") format("woff2"); }

/* Slides keep the template's light colors in both themes; only the window
   around them and the nav bar follow the system theme. */
:root {
  --bg: #ffffff;
  --fg: #1c2954;
  --accent: #537eba;
  --brand-orange: #f6862d;
  --force: #c0392b;
  --momentum: #2e8b57;
  --potential: #c98a1b;
  --font-head: "Tiempos Headline", "Source Serif 4", Georgia, serif;
  --font-body: "Founders Grotesk", "Hanken Grotesk", system-ui, sans-serif;
  --window-bg: #eef0f4;
  --window-fg: #1c2954;
}

@media (prefers-color-scheme: dark) {
  :root {
    --window-bg: #141416;
    --window-fg: #e8e8ea;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--window-bg);
  color: var(--window-fg);
  font-family: var(--font-body);
}

/* The area above the nav bar (main.js sets bottom); the deck is scaled to fit inside it. */
main {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* Slides are laid out at 1920 x 1080 and scaled as a whole by main.js,
   so sizes below are in slide pixels. */
#deck {
  position: absolute;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
}

.page {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--bg);
  color: var(--fg);
  border: 3px solid color-mix(in srgb, var(--fg) 35%, transparent);
  text-align: center;
}

/* Content slides: the title on top and the content below it. */
.page.active {
  display: flex;
  flex-direction: column;
  padding: 84px 98px 40px;
}

/* Flatiron logo, added to every slide by main.js: top right as in the
   template's content layouts, bottom right on the title slide. */
.page > .logo { position: absolute; top: 30px; right: 98px; height: 42px; }
#landing > .logo { top: auto; bottom: 90px; height: 50px; }

/* Title slide: the template's white title layout, text left-aligned. */
#landing.active {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 240px 98px 0;
  text-align: left;
}

h1, h2 { font-family: var(--font-head); font-weight: 300; }

h1 {
  font-size: 108px;
  line-height: 1.08;
  max-width: 1400px;
  margin: 0 0 120px;
}

h2 {
  font-size: 76px;
  line-height: 1.1;
  text-align: left;
  margin: 0 0 34px;
}

button.start { font-size: 40px; padding: 18px 44px; }

/* Link on the title slide to the replay of how the recipe was written. */
.crafted { margin-top: 64px; font-size: 28px; }
.crafted a { color: inherit; opacity: 0.8; text-decoration: none; }
.crafted a:hover { opacity: 1; text-decoration: underline; }

/* Slides with a title on top, text on the left and the interactive content
   on the right. Each panel scrolls on its own if its content is too tall. */
.page.split.active {
  display: grid;
  grid-template-columns: 960px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "title title" "text demo";
  gap: 0 72px;
  text-align: left;
}
/* Controls on the left need less room than equations. */
.page.split.narrow-left.active { grid-template-columns: 600px minmax(0, 1fr); }

.page.split > h2 { grid-area: title; }
.page.split > .text { grid-area: text; }
.page.split > .demo { grid-area: demo; min-width: 0; }
.page.split > .text,
.page.split > .demo { min-height: 0; overflow-y: auto; }

/* Slides that are not split: the interactive content centered below the title. */
.page:not(.split) > .demo { align-self: center; width: 1100px; }

.text { font-size: 30px; line-height: 1.45; text-align: left; }
.text p { margin: 0 0 16px; }

h3 { font-weight: 600; font-size: 32px; margin: 28px 0 6px; }

.katex-display { margin: 12px 0; }

.equations {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 56px;
  text-align: left;
}
.equations > div > :first-child { margin-top: 0; }

/* Text-only slides: a title and large equations, centered. */
.page.text-only > .equations {
  align-self: center;
  width: 1500px;
  margin-top: 40px;
  font-size: 40px;
  line-height: 1.45;
}
.page.text-only h3 { font-size: 42px; margin: 48px 0 10px; }
.page.text-only p { margin: 0 0 16px; }

.defs { list-style: none; padding: 0; margin: 0; }
.defs li { margin: 6px 0; padding-left: 1.2em; text-indent: -1.2em; }  /* wrapped lines indented */

.exercise {
  margin: 32px 0 0;
  padding: 16px 28px;
  border-left: 4px solid var(--accent);
}
.exercise h3 { margin-top: 0; }

/* Interactive content: diagrams, plots and their controls, stacked. */
.demo { display: flex; flex-direction: column; gap: 24px; text-align: center; }
.demo > p { margin: 0; }

canvas { display: block; width: 100%; height: 300px; }
.caption { font-size: 26px; opacity: 0.8; }
/* Oscillator pages: room for the longest definition on one line. */
.page.split.oscillator-page.active { grid-template-columns: 700px minmax(0, 1fr); }
canvas.oscillator { height: 260px; }
canvas.spectrogram { height: 222px; }
canvas.phase { height: 700px; }
/* shorter while the spectrogram shows below it */
.with-spectrogram canvas.phase { height: 440px; }
/* The phase-space slide's controls: the presets dropdown above the sliders. */
[data-phase-controls] .presets { margin: 0 0 24px; }
/* The lab page's instrument controls, below the sliders. */
.instrument-controls { margin-top: 36px; padding-top: 24px; border-top: 2px solid color-mix(in srgb, var(--fg) 12%, transparent); }
.instrument-controls .preset { display: flex; width: 100%; margin-bottom: 16px; }
.instrument-controls select { flex: 1; min-width: 0; font-size: 26px; }
.instrument-controls select:disabled { opacity: 0.4; }
.instrument-controls .sliders { font-size: 26px; }
.check { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 26px; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }
/* Lab write-up pages: two columns of text, scrolling if needed. */
.page.doc.active > .text { flex: 1; min-height: 0; overflow-y: auto; font-size: 25px; line-height: 1.45; }
.page.doc .equations { gap: 0 64px; }
.page.doc h3 { font-size: 28px; margin: 22px 0 6px; }
.page.doc p { margin: 0 0 10px; }
.page.doc .katex-display { margin: 8px 0; }
.doc-list { margin: 0 0 10px; padding-left: 1.2em; }
.doc-list li { margin: 4px 0; }
canvas.responses { height: 520px; }
canvas[hidden] { display: none; }
.demo-footer { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; font-size: 28px; }
.demo-footer button.link { font-size: 28px; }
.defs + div { margin-top: 28px; }

/* Sliders under a diagram: label, slider and value line up in columns. */
.sliders {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 5.5em;
  align-items: center;
  gap: 6px 24px;
  font-size: 30px;
  text-align: left;
}
.sliders .row { display: contents; }
.sliders input { width: 100%; }
.sliders output { text-align: right; font-variant-numeric: tabular-nums; }

button.run:disabled { opacity: 0.4; cursor: default; background: var(--bg); color: var(--accent); }

/* A diagram with its Start/Stop and reset buttons in the top-right corner. */
.stage { position: relative; }
.run-controls { position: absolute; top: 0; right: 0; display: flex; gap: 10px; }
button.run { font-size: 26px; padding: 6px 20px; background: var(--bg); }
button.run:hover { background: var(--accent); color: var(--bg); }
.run-controls select { font-size: 26px; }

/* Volume next to Play: small and faint until used. */
.volume { display: flex; align-items: center; gap: 6px; color: var(--accent); opacity: 0.55; transition: opacity 0.2s; }
.volume:hover, .volume:focus-within { opacity: 1; }
.volume svg { width: 28px; height: 28px; }
.volume input[type="range"] { width: 110px; }
.volume input[type="range"]::-webkit-slider-runnable-track { height: 4px; }
.volume input[type="range"]::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -7px; }
.volume input[type="range"]::-moz-range-track { height: 4px; }
.volume input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; }

.readout { font-size: 30px; font-variant-numeric: tabular-nums; }

.preset { display: inline-flex; align-items: center; gap: 16px; }
/* Presets dropdown: never wider than the panel, whatever its options. */
.presets { margin-top: 28px; }
.presets .preset { display: flex; width: 100%; }
.presets select { flex: 1; min-width: 0; width: 100%; font-size: 26px; text-overflow: ellipsis; }

select {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 6px 12px;
}

/* Grouped sliders: symbol, slider and value line up in columns. */
.control-groups {
  display: grid;
  gap: 24px;
  max-width: 520px;
  margin: 0 0 28px;
}

.control-groups fieldset {
  display: grid;
  grid-template-columns: 1.5em 1fr 3.2em;
  align-items: center;
  gap: 10px 16px;
  margin: 0;
  padding: 14px 24px 20px;
  border: 2px solid color-mix(in srgb, var(--fg) 15%, transparent);
  border-radius: 12px;
}

.control-groups legend { padding: 0 8px; font-size: 24px; opacity: 0.7; }
.control-groups .row { display: contents; }
.control-groups input { width: 100%; }
.control-groups output { text-align: right; font-variant-numeric: tabular-nums; }

/* Sliders drawn large enough to use when the deck is scaled down. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 34px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 18%, transparent);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -11px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}
input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 18%, transparent);
}
input[type="range"]::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.pager {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--window-bg);
  color: var(--window-fg);
  border-top: 1px solid color-mix(in srgb, var(--window-fg) 12%, transparent);
}

.pager button { padding: 0.35rem 0.8rem; font-size: 0.9rem; border-width: 1px; }
.pager button:disabled { opacity: 0.3; cursor: default; background: none; color: var(--accent); }
/* Slide counter; opens the table of contents. */
.pager .nav-toc { border-color: transparent; color: inherit; font-size: 0.85rem; opacity: 0.75; }
.pager .nav-toc:hover, .pager .nav-toc[aria-expanded="true"] { opacity: 1; background: color-mix(in srgb, var(--window-fg) 10%, transparent); color: inherit; }

/* Table of contents, opening upward from the nav bar. */
.toc {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--window-fg) 18%, transparent);
  background: var(--window-bg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: slide; }
.toc li { counter-increment: slide; }
.toc button {
  display: flex;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.95rem;
  color: var(--window-fg);
}
.toc button::before { content: counter(slide); min-width: 1.6em; text-align: right; opacity: 0.5; font-variant-numeric: tabular-nums; }
.toc button:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--window-fg); }
.toc button.current { background: color-mix(in srgb, var(--accent) 22%, transparent); font-weight: 600; }

button {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 10px 24px;
  cursor: pointer;
}

button:hover { background: var(--accent); color: var(--bg); }

/* The suggested next step: filled and pulsing gently. */
button.next {
  font-size: 32px;
  padding: 14px 36px;
  background: var(--accent);
  color: var(--bg);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.6s;
}

button.next.ready {
  visibility: visible;
  opacity: 1;
  animation: pulse 2s ease-in-out 0.6s 3;
}

button.next:hover { opacity: 0.85; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent); }
  50% { box-shadow: 0 0 0 12px transparent; }
}

button.link {
  border: none;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 5px;
}

button.link:hover { background: none; color: var(--accent); opacity: 0.8; }
.sliders .unit { font-size: 0.7em; opacity: 0.7; }
/* Many sliders (the driven oscillator): smaller and closer together, so the
   panel still fits with the spectrogram open. */
.sliders.compact { font-size: 26px; row-gap: 0; }
.sliders.compact input[type="range"] { height: 30px; }
