@font-face { font-family: Poppins; font-weight: 500; src: url(/render/fonts/Poppins-Medium.ttf); }
@font-face { font-family: Poppins; font-weight: 600; src: url(/render/fonts/Poppins-SemiBold.ttf); }
@font-face { font-family: Poppins; font-weight: 700; src: url(/render/fonts/Poppins-Bold.ttf); }
@font-face { font-family: Poppins; font-weight: 800; src: url(/render/fonts/Poppins-ExtraBold.ttf); }
@font-face { font-family: InterMath; font-style: normal; font-weight: 500; src: url(/render/fonts/Inter-Medium.ttf); }
@font-face { font-family: InterMath; font-style: italic; font-weight: 500; src: url(/render/fonts/Inter-MediumItalic.ttf); }

/* Sans math (html.sansmath): KaTeX's Computer Modern serif swapped for Inter, which has real −, ±, ², √ and matches the
   Poppins captions. Big operators, radicals and delimiters keep KaTeX's size fonts. */
.sansmath .katex { font-family: InterMath, KaTeX_Main, serif; }
.sansmath .katex .mathnormal, .sansmath .katex .mathit { font-family: InterMath, KaTeX_Math, serif; font-style: italic; }
.sansmath .katex .mord, .sansmath .katex .mbin, .sansmath .katex .mrel, .sansmath .katex .mopen, .sansmath .katex .mclose,
.sansmath .katex .mpunct, .sansmath .katex .minner { font-family: InterMath, KaTeX_Main, serif; }
.sansmath .katex .mathnormal { font-family: InterMath, KaTeX_Math, serif; }
.sansmath .katex .text, .sansmath .katex .textrm { font-family: Poppins, InterMath, sans-serif; font-style: normal; }

:root { --bg: #ffffff; --ink: #15202b; --accent: #0b6e4f; --pale: #e9f5f0; --muted: #4a5763; --pad: 28px; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--ink); overflow: hidden; }
/* Poppins lacks some math glyphs (−, ✓): Inter, then DejaVu Sans, fill them per character. */
body { font-family: Poppins, InterMath, 'DejaVu Sans', sans-serif; font-weight: 500; -webkit-font-smoothing: antialiased; }

#frame { position: relative; width: 540px; height: 960px; overflow: hidden; background: var(--bg); }
.wide #frame { width: 960px; height: 540px; }

/* Persistent brand header, CSS y 56-90 (top 110 px stays clear for platform UI). */
#brand { position: absolute; left: var(--pad); right: var(--pad); top: 56px; height: 34px; display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--pale); }
#brand .domain { font-weight: 600; font-size: 22px; color: var(--accent); letter-spacing: 0.2px; }
#brand .tagline { font-weight: 500; font-size: 14px; color: var(--muted); }

/* Body: CSS y 110-760 on the tall layout (bottom 200 px clear for platform UI). */
#body { position: absolute; left: 0; right: 0; top: 110px; height: 650px; overflow: hidden; }
.wide #body { top: 104px; height: 410px; }

.scene, .end, .title-card { position: absolute; inset: 0; transition: opacity 300ms ease; }
.hidden { opacity: 0; }

/* No CSS mask here: a mask on the viewport re-rasterises it every frame and halved the capture rate (18 vs 30 fps). */
.viewport { position: absolute; left: var(--pad); right: var(--pad); top: 18px; bottom: 0; overflow: hidden; }
.stack { transition: transform 300ms ease; will-change: transform; }

.row { padding: 10px 14px 12px; margin-bottom: 10px; border-left: 4px solid transparent; border-radius: 4px; transition: opacity 300ms ease, background-color 300ms ease, border-color 300ms ease; }
.row.past { opacity: 0.55; }
.row.current { background: var(--pale); border-left-color: var(--accent); }
.stack > .gone { opacity: 0 !important; } /* rows scrolling off the top fade instead of being sliced */

/* fade out first, then collapse (T.collapse = 350 ms), so no line is ever clipped while still visible */
.hook { font-weight: 700; font-size: 30px; line-height: 1.25; max-height: calc(3 * 1.25em); overflow: hidden; margin-bottom: 18px; transition: opacity 150ms ease, max-height 220ms ease 130ms, margin 220ms ease 130ms; }
.hook.collapsed { opacity: 0; max-height: 0; margin-bottom: 0; }
.problem-row { padding-top: 14px; }

.note { font-weight: 600; font-size: 19px; line-height: 1.3; color: var(--muted); opacity: 0; transition: opacity 250ms ease; }
.note.in { opacity: 1; }

/* clip sideways only (fit() keeps lines inside the column); a popping \hl may grow above/below the line */
.math { font-size: 32px; white-space: nowrap; overflow-x: clip; overflow-y: visible; padding-top: 4px; }
.math.big { font-size: 34px; }
.math.step { opacity: 0; transform: translateY(12px); transition: opacity 350ms ease, transform 350ms ease; }
.math.step.in { opacity: 1; transform: none; }
.katex-display { margin: 0; text-align: left; }
/* inline-block so the .katex box is as wide as the formula (player.js fit() measures it) */
.katex-display > .katex { display: inline-block; text-align: left; }
.check { font-weight: 700; font-size: 22px; color: var(--accent); padding: 6px 18px 0; opacity: 0; transition: opacity 250ms ease; }
.check.in { opacity: 1; }

/* Animated operations (player.js): op chips, flying \mv terms, \hl emphasis. */
.math.step.fade-only { transform: none; }
.layer { position: absolute; inset: 0; pointer-events: none; }
.op-chip { position: absolute; color: var(--accent); white-space: nowrap; opacity: 0; transform: translateY(-8px); transition: opacity 250ms ease, transform 250ms ease; }
.op-chip.in { opacity: 1; transform: none; }
.op-chip.out { opacity: 0; transition-duration: 150ms; }
.fly { position: absolute; color: var(--accent); white-space: nowrap; transform-origin: center; }
/* Both clones travel as one opaque term; swap the glyphs only between 55% and 75% of the flight. */
.fly.go.from { transition: transform 750ms cubic-bezier(0.65, 0, 0.35, 1), opacity 150ms linear 412.5ms; }
.fly.go.to { transition: transform 750ms cubic-bezier(0.65, 0, 0.35, 1), opacity 150ms linear 412.5ms; }
.math .enclosing { transition: color 900ms ease; }
.math .enclosing.mv-src, .math .enclosing.mv-arrived { color: var(--accent); transition: none; }
.math .enclosing.gap { display: inline-block; overflow: hidden; vertical-align: bottom; transition: max-width 400ms ease; }
.math .enclosing.hl { display: inline-block; }
.math.in .enclosing.hl { animation: hl-pop 700ms ease 250ms both; }
@keyframes hl-pop { 0% { transform: scale(1); color: var(--ink); } 45% { transform: scale(1.18); color: var(--accent); } 100% { transform: scale(1); color: var(--accent); } }

.end { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 var(--pad); gap: 14px; transition-duration: 400ms; }
.end .q { font-weight: 700; font-size: 34px; line-height: 1.2; }
.end .offer { font-weight: 500; font-size: 24px; line-height: 1.35; white-space: pre-line; }
.end .site { font-weight: 600; font-size: 30px; color: var(--accent); margin-top: 18px; }
.end .bio { font-weight: 500; font-size: 18px; color: var(--muted); }
.wide .end .offer { white-space: normal; max-width: 640px; }

.title-card { background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 40px; }

/* Long-form 960x540: problem left, steps right. */
.wide .left { position: absolute; left: var(--pad); width: 380px; top: 18px; bottom: 0; }
.wide .left .hook { font-size: 26px; }
.wide .left .math { font-size: 30px; white-space: nowrap; }
.wide .viewport { left: 430px; }
.wide .math { font-size: 30px; }
.wide .note { font-size: 17px; }
