/* 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); }
/* The double pendulum's long equations: slightly smaller text. */
.page.compact-text > .text { font-size: 26px; }

.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; }

/* Hamilton's equations: a title and two columns of equations. */
.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; }

.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; }
canvas.bars { height: 150px; }
canvas.phase { height: 390px; }
canvas.pendulum { height: 360px; }
canvas.pendulum-centered { height: 390px; }
#liouville-canvas, #liouville-pendulum-canvas { height: 360px; }
canvas.double { height: 700px; }
#double-phase-canvas, #double-poincare-canvas, #double-dispersion-canvas { height: 340px; }
/* Two phase planes side by side. */
.plane-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.plane-pair canvas { height: 360px; }
.caption { font-size: 26px; opacity: 0.8; }

/* Poincare section explorer: one wide section view with its controls above. */
.page:not(.split) > .demo.explorer { width: 1500px; }
.explorer-controls { display: flex; align-items: center; gap: 40px; font-size: 30px; }
.explorer-energy { display: flex; align-items: center; gap: 16px; flex: 1; }
.explorer-energy input { flex: 1; }
.explorer-energy output { width: 4em; text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: inline-flex; align-items: center; gap: 12px; font-size: 26px; }
/* a few of the per-orbit cool colors (main.js), then the blend to red */
.legend-bar { width: 160px; height: 12px; border-radius: 6px; background: linear-gradient(to right, #537eba 0 10%, #2e8b57 10% 20%, #1a9cb0 20% 30%, var(--force)); }
#double-explorer-canvas { height: 700px; cursor: crosshair; }
/* Listening to orbits: the section view on the left, the sound controls and
   spectrogram on the right. */
.page:not(.split) > .demo.explorer.listen { width: 1724px; }
.listen-body { display: grid; grid-template-columns: minmax(0, 1fr) 580px; gap: 48px; }
#double-listen-canvas, #double-damped-canvas { height: 700px; cursor: crosshair; }
.listen-panel { display: flex; flex-direction: column; gap: 20px; font-size: 28px; text-align: left; }
.listen-row { display: flex; align-items: center; gap: 16px; }
.listen-row select, .listen-row input { flex: 1; min-width: 0; }
.listen-row output { width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
#double-listen-spectrogram, #double-damped-spectrogram { height: 560px; }
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; }

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

.preset { display: inline-flex; align-items: center; gap: 16px; }

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

/* The q0 slider sits right under the phase plot; main.js stretches it so the
   thumb lines up with q0 on the diagram. */
.q0-row { margin-top: -18px; text-align: left; }
.q0-row input { display: block; }
.slider-caption { margin-top: -14px !important; font-size: 28px; opacity: 0.8; }

/* 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. The thumb
   is 30px wide; main.js relies on that to line up the q0 slider. */
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; }
