
/* fonts.css */
/*
 * Embedded UI fonts, shared by editor, viewer and print/export.
 *
 * Why this exists: the default text font stack used to be the system stack
 * (-apple-system, "Segoe UI", Roboto, sans-serif). None of those fonts exist
 * on a typical Linux server, so the headless-Chrome PDF/PNG exporter fell back
 * to DejaVu/Liberation — wider, taller metrics than San Francisco/Segoe — and
 * text overflowed element boxes (overlap with images, wrapped lines). The
 * editor/viewer looked fine on a Mac because Chrome there resolves -apple-system
 * to San Francisco, but the server-side export did not match.
 *
 * Shipping real font files and making Inter the default means editor, viewer
 * and export all lay text out with byte-identical glyph metrics regardless of
 * OS — true WYSIWYG. The system stack is kept only as a pre-load fallback.
 *
 * Inter is the default (closest to the San Francisco metrics decks are authored
 * against). Roboto, Open Sans, Noto Sans, Albert Sans and Liberation Sans are
 * also embedded and selectable per-element in the editor's font picker. Every
 * face here is a full latin-ext font, so Croatian diacritics (č ć ž š đ …) and
 * € / smart-quote punctuation render correctly — no tofu, no fallback swap.
 *
 * font-display:block keeps text invisible (rather than fallback-then-swap)
 * until the face loads, so a capture that races font load never measures
 * fallback metrics. The exporter additionally waits on document.fonts.ready
 * (handlers.printReadyScript), so by capture time the real font is in.
 *
 * Albert Sans ships as two variable-font files (upright + italic) covering the
 * whole 100–900 weight range, so its two faces use a font-weight range.
 */

/* ---- Inter (default) ---- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/Inter-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/Inter-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/Inter-BoldItalic.woff2") format("woff2");
}

/* ---- Roboto ---- */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/Roboto-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/Roboto-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/Roboto-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto";
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/Roboto-BoldItalic.woff2") format("woff2");
}

/* ---- Open Sans ---- */
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/OpenSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Open Sans";
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/OpenSans-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/OpenSans-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Open Sans";
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/OpenSans-BoldItalic.woff2") format("woff2");
}

/* ---- Noto Sans ---- */
@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/NotoSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans";
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/NotoSans-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans";
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/NotoSans-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans";
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/NotoSans-BoldItalic.woff2") format("woff2");
}

/* ---- Albert Sans (variable, 100–900) ---- */
@font-face {
  font-family: "Albert Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url("/static/fonts/AlbertSans.woff2") format("woff2");
}
@font-face {
  font-family: "Albert Sans";
  font-style: italic;
  font-weight: 100 900;
  font-display: block;
  src: url("/static/fonts/AlbertSans-Italic.woff2") format("woff2");
}

/* ---- Liberation Sans (Arial-metric) ---- */
@font-face {
  font-family: "Liberation Sans";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/LiberationSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Liberation Sans";
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url("/static/fonts/LiberationSans-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Liberation Sans";
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/LiberationSans-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Liberation Sans";
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url("/static/fonts/LiberationSans-BoldItalic.woff2") format("woff2");
}


/* viewer.css */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #111;
  overflow: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
}

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.scaler {
  position: relative;
  transform-origin: top left;
  color: #111;
  overflow: hidden;
}

.slide-canvas {
  position: relative;
  /* Form a stacking context so elements with negative z-index paint above the
   * canvas background (set inline by the renderer) rather than escaping
   * behind it. */
  isolation: isolate;
  overflow: hidden;
  /* Transparent so the stage's #111 shows through where the slide doesn't
   * paint. A solid #fff here would leak as a bright sliver on slides whose
   * elements don't fully cover the canvas (e.g. header bands sized to
   * 1914 instead of 1920). The renderer sets an explicit background
   * (theme/slide background color/image) inline when the deck wants white. */
  background: transparent;
  width: 100%;
  height: 100%;
}

.el {
  font-family: inherit;
}

.el-text-inner {
  width: 100%;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Match the editor: leave background/color to the Prism theme stylesheet
 * (or to the per-element c.background override applied inline by the
 * server renderer). Hard-coding a default here would diverge from the
 * editor and from print. */
.el-code pre {
  margin: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
  box-sizing: border-box;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Override Prism's defaults so highlighted code matches the textarea used in
 * editable mode: same monospace stack, no text-shadow, tighter line-height.
 * Without this Prism's `pre[class*=language-]` selector wins and falls back to
 * Consolas with text-shadow + 1.5 line-height, making view-mode look bulkier
 * than edit-mode. */
.el-code pre[class*="language-"],
.el-code code[class*="language-"],
.el-code textarea.el-code-edit {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-shadow: none;
  line-height: 1.35;
}

/* Inline markdown `code` and ==highlight==. Scoped to bare elements (no
 * class) so Prism's `code.language-*` in code blocks is never touched.
 * Sizing in em keeps it tied to the surrounding text on the fixed canvas. */
.el code:not([class]) {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: rgba(135, 131, 120, 0.18);
  padding: 0.1em 0.35em;
  border-radius: 0.3em;
}
.el mark {
  background: #fef08a;
  color: #1a1a1a;
  padding: 0.05em 0.2em;
  border-radius: 0.2em;
}

/* Edit mode: a <textarea> can only render one color, so we'll never get per-
 * token highlighting like the read-mode <pre>. But the browser's UA styles
 * (system text color, native font smoothing) tend to render textarea glyphs
 * thinner and dimmer than the same characters in a <pre>, which next to
 * Prism's bright tokens looks "washed out." Force the same weight, smoothing,
 * and letter-spacing so the only visible difference between modes is the
 * lack of syntax colors — not a font/contrast change. The base color itself
 * is JS-mirrored from the <pre>'s computed style on render and on every swap
 * to the textarea, so it tracks whichever Prism theme is in effect. */
.el-code textarea.el-code-edit {
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
}

.controls {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: rgba(0,0,0,0.5);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  user-select: none;
  z-index: 100;
}

.controls button, .controls a {
  background: #222;
  color: #fff;
  border: 1px solid #444;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.controls button:hover, .controls a:hover {
  background: #333;
}

.empty {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #888;
}

/* ─── Slide transitions ──────────────────────────────────────────────────── */

.stage {
  --t-dur: 400ms;
  --t-ease: ease;
}

/* Both scalers share the stage. Only the active one is shown; the inactive
   one is display:none until a transition starts (JS adds scaler-active).
   Transitions animate a .slide-wrap inner div so the scaler's own
   scale+position transform (applied by JS) is never disturbed. */
.scaler {
  position: absolute;
  display: none;
}
.scaler.scaler-active {
  display: block;
}

.slide-wrap {
  position: absolute;
  inset: 0;
}

/* fade — animate the wrap's opacity */
.t-fade .scaler-out .slide-wrap { animation: t-fade-out var(--t-dur) var(--t-ease) forwards; }
.t-fade .scaler-in  .slide-wrap { animation: t-fade-in  var(--t-dur) var(--t-ease) forwards; }

@keyframes t-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes t-fade-in  { from { opacity: 0; } to { opacity: 1; } }

/* slide-left: current exits left, new enters from right.
   100% here means 100% of the wrap's own width = canvas width in canvas px,
   but since the wrap fills the scaler exactly we use 100%. */
.t-slide-left .scaler-out .slide-wrap { animation: t-slide-left-out var(--t-dur) var(--t-ease) forwards; }
.t-slide-left .scaler-in  .slide-wrap { animation: t-slide-left-in  var(--t-dur) var(--t-ease) forwards; }

@keyframes t-slide-left-out { from { transform: translateX(0); }     to { transform: translateX(-100%); } }
@keyframes t-slide-left-in  { from { transform: translateX(100%); }  to { transform: translateX(0); } }

/* slide-right: current exits right, new enters from left */
.t-slide-right .scaler-out .slide-wrap { animation: t-slide-right-out var(--t-dur) var(--t-ease) forwards; }
.t-slide-right .scaler-in  .slide-wrap { animation: t-slide-right-in  var(--t-dur) var(--t-ease) forwards; }

@keyframes t-slide-right-out { from { transform: translateX(0); }    to { transform: translateX(100%); } }
@keyframes t-slide-right-in  { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* zoom-in: new slide zooms in over current */
.t-zoom-in .scaler-out .slide-wrap { animation: t-zoom-in-out var(--t-dur) var(--t-ease) forwards; }
.t-zoom-in .scaler-in  .slide-wrap { animation: t-zoom-in-in  var(--t-dur) var(--t-ease) forwards; }

@keyframes t-zoom-in-out { from { opacity: 1; transform: scale(1); }    to { opacity: 0; transform: scale(0.85); } }
@keyframes t-zoom-in-in  { from { opacity: 0; transform: scale(1.15); } to { opacity: 1; transform: scale(1); } }

/* zoom-out: current zooms out, new arrives at normal scale */
.t-zoom-out .scaler-out .slide-wrap { animation: t-zoom-out-out var(--t-dur) var(--t-ease) forwards; }
.t-zoom-out .scaler-in  .slide-wrap { animation: t-zoom-out-in  var(--t-dur) var(--t-ease) forwards; }

@keyframes t-zoom-out-out { from { opacity: 1; transform: scale(1); }    to { opacity: 0; transform: scale(1.15); } }
@keyframes t-zoom-out-in  { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* Element animations + print/reduced-motion suppression now live in
   animations.css (shared with the editor). */

/* ─── Audio widgets (display modes other than "bar") ───────────────────── */
/* The renderer wraps the <audio> element in .audio-widget for button/icon
   modes. The audio tag itself stays 0×0 (no controls), and the widget is
   what the user clicks. data-state mirrors the audio playback state so we
   can swap the glyph between play and pause. */
.audio-widget {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.audio-widget-button {
  background: #2d6cdf;
  color: #fff;
  border-radius: 9999px;
  font-size: 0;
  position: relative;
}
.audio-widget-button::before {
  content: '';
  display: block;
  width: 40%;
  height: 40%;
  background: currentColor;
  /* Play triangle by default; flipped to two bars when [data-state=playing]. */
  clip-path: polygon(20% 0, 100% 50%, 20% 100%);
}
.audio-widget-button[data-state="playing"]::before {
  /* Two pause bars: 0–35% solid, 35–65% transparent, 65–100% solid. A single
     polygon clip-path can't punch a hole through a filled shape, so we paint
     the bars with a linear-gradient and drop the clip-path entirely. */
  clip-path: none;
  background: linear-gradient(to right,
    currentColor 0%, currentColor 35%,
    transparent  35%, transparent  65%,
    currentColor 65%, currentColor 100%);
}
.audio-widget-icon {
  color: #444;
  font-size: 0;
}
.audio-widget-icon::before {
  content: '';
  display: block;
  width: 70%;
  height: 70%;
  background: currentColor;
  /* Speaker silhouette: trapezoid + rectangle stem on the left. */
  clip-path: polygon(0 35%, 30% 35%, 60% 10%, 60% 90%, 30% 65%, 0 65%);
}
.audio-widget-icon[data-state="playing"] {
  color: #2d6cdf;
}

/* ─── TTS widgets ──────────────────────────────────────────────────────── */
/* Mirrors .audio-widget shapes — SpeechSynthesis has no native UI, so every
   TTS element renders as either a custom click target or stays invisible.
   The icon variant uses a "speech bubble" glyph to distinguish it from the
   speaker icon used for audio. */
.tts-widget {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.tts-widget-button {
  background: #6c4adf;
  color: #fff;
  border-radius: 9999px;
  font-size: 0;
  position: relative;
}
.tts-widget-button::before {
  content: '';
  display: block;
  width: 40%;
  height: 40%;
  background: currentColor;
  clip-path: polygon(20% 0, 100% 50%, 20% 100%);
}
.tts-widget-button[data-state="playing"]::before {
  /* See .audio-widget-button[data-state=playing] for the rationale. */
  clip-path: none;
  background: linear-gradient(to right,
    currentColor 0%, currentColor 35%,
    transparent  35%, transparent  65%,
    currentColor 65%, currentColor 100%);
}
.tts-widget-icon {
  color: #444;
  font-size: 0;
}
.tts-widget-icon::before {
  content: '';
  display: block;
  width: 70%;
  height: 70%;
  background: currentColor;
  /* Speech-bubble silhouette: rounded rect body + tail bottom-left. */
  clip-path: polygon(10% 10%, 90% 10%, 90% 70%, 35% 70%, 20% 95%, 22% 70%, 10% 70%);
}
.tts-widget-icon[data-state="playing"] {
  color: #6c4adf;
}


/* animations.css */
/* Element animations — shared between viewer and editor preview.
   Duration / delay / direction are passed via inline CSS custom properties
   (--anim-dur, --anim-delay, --anim-dir-x, --anim-dir-y, --anim-wipe-from,
   --anim-iter). The animation class (anim-fade-in, anim-fly-in, ...) is
   added by JS to start the animation. */

.anim-fade-in {
  animation: el-fade-in var(--anim-dur, 500ms) var(--anim-ease, ease) var(--anim-delay, 0ms) both;
}
@keyframes el-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.anim-fade-out {
  animation: el-fade-out var(--anim-dur, 500ms) var(--anim-ease, ease) var(--anim-delay, 0ms) both;
}
@keyframes el-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.anim-fly-in {
  animation: el-fly-in var(--anim-dur, 500ms) var(--anim-ease, ease) var(--anim-delay, 0ms) both;
}
@keyframes el-fly-in {
  from { opacity: 0; transform: translate(var(--anim-dir-x, 0px), var(--anim-dir-y, 0px)); }
  to   { opacity: 1; transform: translate(0, 0); }
}

.anim-zoom-in {
  animation: el-zoom-in var(--anim-dur, 500ms) var(--anim-ease, ease) var(--anim-delay, 0ms) both;
}
@keyframes el-zoom-in {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

.anim-wipe {
  animation: el-wipe var(--anim-dur, 500ms) var(--anim-ease, ease) var(--anim-delay, 0ms) both;
}
@keyframes el-wipe {
  from { clip-path: var(--anim-wipe-from, inset(0 100% 0 0)); }
  to   { clip-path: inset(0 0 0 0); }
}

.anim-spin {
  animation: el-spin var(--anim-dur, 1000ms) linear var(--anim-delay, 0ms) var(--anim-iter, 1);
}
@keyframes el-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Suppress all transitions and animations in print */
@media print {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* prism/slides-overrides.css */
/* Local overrides applied on top of every Prism theme.
 *
 * Loaded after prism.min.css and any per-element scoped theme. Scoped themes
 * are rewritten by scoped-loader.js to live under `.code-theme-X` (specificity
 * 0,2,0), so plain `.token.operator` selectors here can't beat them via the
 * cascade. The rules in this file therefore use !important deliberately —
 * they are vendor-reset declarations that must apply regardless of which
 * Prism theme rewrote the same property.
 *
 * Keep this file small. Every rule here makes a Prism upgrade a little
 * harder to verify. See CHANGES.md for the rationale behind each rule.
 */

/* Prism's light theme ships .token.operator (and entity/url, plus
 * language-css/style strings) with a translucent white background to keep
 * them legible on its cream default background. Every dark theme — Atom
 * Dark, Dracula, One Dark, etc. — inherits that rule and ends up with a
 * faint white box behind every `=`, URL, and CSS string. Reset to
 * transparent across the board; each theme's own color rule is unaffected.
 */
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  background: transparent !important;
}

