/* Slide decks (/talks/{slug}), docs/talk/04-infra.md.
   Loaded only by talk.html, on top of style.css. All sizes inside a slide
   are in cqw of the .deck container, so a slide looks identical at any
   window size; 100cqw = slide width, slide height = 56.25cqw. */

/* ------------------------------------------------------------- theme -- */

html.talk[data-theme="light"] {
  color-scheme: light;
  --bg: #fbfaf7;
  --bg-soft: #f2f0ea;
  --demo-surface: #1e2024;
  --fg: #1d1d1f;
  --fg-muted: #5c5c66;
  --border: #e3e0d8;
  --accent: #0f6e6e;
  --accent-soft: #e0f0ef;
  --error: #b42318;
}

html.talk[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141517;
  --bg-soft: #1d1f22;
  --demo-surface: #141517;
  --fg: #e6e4df;
  --fg-muted: #a09ea0;
  --border: #2c2e33;
  --accent: #5cc8c2;
  --accent-soft: #17302f;
  --error: #ff8a80;
}

html.talk {
  /* Diagram palette (docs/talk/03-visuals.md), readable on both themes. */
  --good: #2a9d8f;
  --bad: #e76f51;
  --warn: #e9c46a;
  --violet: #8e7dbe;
  --blue: #4f8fd8;
  /* No system-ui on slides: it resolves to whatever the presenting desktop
     uses as its UI font (a monospace one on the author's machine). */
  --font-sans: "Noto Sans", "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  scroll-behavior: auto;
}

html.talk body {
  display: block;
  min-height: 0;
}

/* ------------------------------------------------- scroll / no-JS view -- */

.deck {
  container-type: inline-size;
  inline-size: min(100%, 1600px);
  margin-inline: auto;
}

.slide {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 3.2cqw 5cqw;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 2.35cqw;
  line-height: 1.35;
  border-block-end: 1px solid var(--border);
}

.slide-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.2cqw;
}

/* --------------------------------------------------------- deck view -- */

html.js-deck,
html.js-deck body {
  block-size: 100%;
  overflow: hidden;
}

html.js-deck body {
  display: grid;
  place-items: center;
  background: var(--bg);
}

html.js-deck .deck {
  position: relative;
  inline-size: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
}

html.js-deck .slide {
  position: absolute;
  inset: 0;
  visibility: hidden;
  border: 0;
}

html.js-deck .slide.is-current {
  visibility: visible;
}

html.js-deck .step {
  opacity: 0;
  transition: opacity 0.25s ease;
}

html.js-deck .step.is-shown {
  opacity: 1;
}

.deck-controls {
  position: fixed;
  inset-block-end: 0.5rem;
  inset-inline-end: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.35;
  transition: opacity 0.2s;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

.deck-controls:hover,
.deck-controls:focus-within {
  opacity: 1;
}

.deck-controls[hidden] {
  display: none;
}

/* Progress ring: fills per slide (not per step); --progress is set by slides.js. */
.deck-counter {
  display: grid;
  place-items: center;
  inline-size: 3.6rem;
  block-size: 3.6rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  border: 3px solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    conic-gradient(var(--accent) calc(var(--progress, 0) * 1turn), var(--border) 0) border-box;
}

.deck-controls button {
  min-inline-size: var(--tap);
  min-block-size: var(--tap);
  font: inherit;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.deck-counter {
  cursor: pointer;
}

/* ---------------------------------------------------------- overview -- */

/* Built by slides.js (key `o`): slide titles to jump to, plus a key legend. */
.deck-overview {
  inline-size: min(92vw, 72rem);
  max-block-size: 88vh;
  padding: 1.5rem 2rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  font-family: var(--font-sans);
}

.deck-overview::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.deck-overview ol {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 3 18rem;
  column-gap: 1.5rem;
}

.deck-overview li {
  break-inside: avoid;
}

.deck-overview button {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  inline-size: 100%;
  padding: 0.35rem 0.6rem;
  font: inherit;
  color: inherit;
  text-align: start;
  background: none;
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
}

.deck-overview button:hover {
  background: var(--bg-soft);
}

.deck-overview button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.deck-overview button[aria-current="true"] {
  font-weight: 700;
  background: var(--accent-soft);
}

.deck-overview .num {
  flex: none;
  min-inline-size: 2ch;
  text-align: end;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
}

.deck-overview button[aria-current="true"] .num {
  color: var(--accent);
}

.deck-overview-help {
  margin: 1.2rem 0 0;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.deck-overview-help kbd {
  padding: 0.05rem 0.35rem;
  font: inherit;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--bg-soft);
}

/* -------------------------------------------------------- typography -- */

.slide h1,
.slide h2,
.slide h3 {
  margin: 0;
  line-height: 1.15;
  text-wrap: balance;
}

.slide h1 {
  font-size: 2.4em;
}

.slide h2 {
  font-size: 1.6em;
  margin-block-end: 0.4em;
}

.slide h3 {
  font-size: 1.15em;
  color: var(--fg-muted);
}

/* The slide title sits at the top; the rest of the body centers below it. */
.slide-body > h2:first-child {
  margin-block-end: auto;
}

.slide-body > h2:first-child ~ :last-child {
  margin-block-end: auto;
}

.slide p,
.slide ul,
.slide ol {
  margin: 0;
}

.slide ul,
.slide ol {
  padding-inline-start: 1.2em;
}

.slide li + li {
  margin-block-start: 0.35em;
}

.slide a {
  color: var(--accent);
}

.slide code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.slide pre {
  font-size: 0.7em;
  margin: 0;
  overflow: hidden;
}

.slide blockquote {
  margin: 0;
  padding-inline-start: 0.8em;
  border-inline-start: 0.2em solid var(--accent);
  color: var(--fg-muted);
}

.slide .header-anchor {
  display: none;
}

/* ------------------------------------------------------------ media -- */

.slide figure {
  margin: 0;
}

.slide figcaption {
  font-size: 0.65em;
  color: var(--fg-muted);
  text-align: center;
  margin-block-start: 0.4em;
}

.slide img {
  display: block;
  max-inline-size: 100%;
  max-block-size: 40cqw;
  inline-size: auto;
  block-size: auto;
  margin-inline: auto;
  object-fit: contain;
}

.slide .typst-figure svg {
  max-block-size: 40cqw;
  margin-inline: auto;
  display: block;
}

/* Demos: no prose breakout on slides, fill the slide width. */
.slide .wasm-demo {
  inline-size: auto;
  margin: 0;
  font-size: 0.55em;
}

/* Demo captions are written for the blog; on a slide the speaker talks. */
.slide .wasm-demo figcaption:empty,
.slide .wasm-demo .no-caption,
.slide .wasm-demo-root[data-demo^="treppe"] > p:last-child {
  display: none;
}

.slide .wasm-demo select,
.slide .wasm-demo input {
  font: inherit;
}

/* ----------------------------------------------------------- helpers -- */

.slide .cols {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3cqw;
  align-items: center;
}

.slide .center {
  text-align: center;
  align-items: center;
}

.slide .fill {
  flex: 1;
  min-height: 0;
}

.slide .small {
  font-size: 0.75em;
}

.slide .muted {
  color: var(--fg-muted);
}

.slide .mono {
  font-family: var(--font-mono);
  font-size: 0.8em;
}

.slide .big-number {
  font-size: 4em;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  text-align: center;
}

.slide .good {
  color: var(--good);
}

.slide .bad {
  color: var(--bad);
}

/* ------------------------------------------------------------ print -- */

@page {
  size: 1600px 900px;
  margin: 0;
}

@media print {
  html.talk,
  html.talk body {
    block-size: auto;
    overflow: visible;
    display: block;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html.talk .deck {
    inline-size: 1600px;
    aspect-ratio: auto;
  }

  html.talk .slide {
    position: relative;
    inset: auto;
    visibility: visible;
    inline-size: 1600px;
    block-size: 900px;
    aspect-ratio: auto;
    border: 0;
    break-after: page;
  }

  html.talk .step {
    opacity: 1;
  }

  .deck-controls {
    display: none !important;
  }
}
