/* Unboring story engine. Every colour and face comes from the story's style (set inline as custom properties by
   story.js from the server's theme). Per-style texture and character live in the [data-style] blocks at the end. */
.ub { --bg:#fff; --ink:#111; --accent:#c00; --accent2:#00c; --muted:#666; --line:#111;
  --display: serif; --body: sans-serif; --mono: monospace;
  background: var(--bg); color: var(--ink); font: 400 clamp(17px, 1.05vw + 12px, 21px)/1.55 var(--body);
  -webkit-font-smoothing: antialiased; position: relative; overflow-x: clip; }
.ub *, .ub *::before, .ub *::after { box-sizing: border-box; }
.ub-progress { position: fixed; inset: 0 auto auto 0; height: 3px; width: 0; background: var(--accent); z-index: 30; }
.ub-scene { min-height: 100svh; display: grid; align-items: center; padding: clamp(4rem, 9vh, 7rem) clamp(1.25rem, 6vw, 7rem); position: relative; }
.ub-in { width: 100%; max-width: 72rem; margin: 0 auto; }
.ub-col { max-width: 40rem; }
.ub h1, .ub h2, .ub h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: -0.01em; line-height: 1.04; text-wrap: balance; }
.ub p { margin: 0; text-wrap: pretty; }
.ub .ub-src { margin-top: 1.4rem; font-size: .78em; color: var(--muted); max-width: 46rem; }
.ub .ub-src q { quotes: "“" "”"; font-style: italic; }

/* cover */
.ub-cover { align-items: end; min-height: 100svh; }
/* Cover art gets its own side on wide screens and a top band on phones: the title never sits on a busy image. */
.ub-cover .ub-art { position: absolute; top: 0; right: 0; bottom: 0; width: 55%; background-size: cover; background-position: center; }
.ub-cover .ub-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to right, var(--bg) 0%, color-mix(in srgb, var(--bg) 40%, transparent) 30%, transparent 60%); }
.ub-cover h1, .ub-cover .ub-sub { max-width: min(14ch, 46vw); } .ub-cover .ub-sub { max-width: min(34ch, 44vw); }
@media (max-width: 760px) { .ub-cover .ub-art { width: 100%; bottom: auto; height: 46svh; } .ub-cover .ub-art::after { background: linear-gradient(to top, var(--bg) 0%, transparent 60%); } .ub-cover h1, .ub-cover .ub-sub { max-width: none; } }
.ub-cover .ub-in { position: relative; }
.ub-kicker { color: var(--accent); font-weight: 600; margin-bottom: 1rem; font-size: .95em; }
.ub-cover h1 { font-size: clamp(2.6rem, 7.5vw, 7.5rem); max-width: 14ch; }
.ub-cover .ub-sub { margin-top: 1.4rem; font-size: clamp(1.1rem, 1.6vw, 1.5rem); max-width: 34ch; color: color-mix(in srgb, var(--ink) 80%, transparent); }
.ub-hint { margin-top: 3rem; color: var(--muted); font-size: .85em; }

/* statement */
.ub-statement h2 { font-size: clamp(2rem, 4.6vw, 4.4rem); max-width: 22ch; }
.ub-statement mark { background: none; color: var(--accent); }

/* stat */
.ub-stat .ub-num { font-family: var(--display); font-weight: 800; font-size: clamp(5rem, 19vw, 17rem); line-height: .86; letter-spacing: -0.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.ub-stat .ub-label { font-size: clamp(1.3rem, 2.4vw, 2.2rem); font-family: var(--display); margin-top: .6rem; max-width: 22ch; }
.ub-stat .ub-ctx { margin-top: 1rem; max-width: 36ch; color: color-mix(in srgb, var(--ink) 82%, transparent); }

/* stats */
.ub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: clamp(1.5rem, 4vw, 3.5rem); }
.ub-stats .ub-num { font-family: var(--display); font-weight: 800; font-size: clamp(3rem, 7vw, 6rem); line-height: .9; color: var(--accent); font-variant-numeric: tabular-nums; }
.ub-stats .ub-item:nth-child(even) .ub-num { color: var(--accent2); }
.ub-stats .ub-label { margin-top: .5rem; max-width: 18ch; }
/* unit words sit under the number, smaller, so "4.5 million sentences" never overflows its column */
.ub-num .u.word { display: block; font-size: .3em; letter-spacing: 0; line-height: 1.2; margin-top: .25em; }
.ub-stats .ub-num { overflow-wrap: anywhere; }

/* chart */
.ub-chart h2 { font-size: clamp(1.7rem, 3.4vw, 3rem); max-width: 24ch; margin-bottom: .4rem; }
.ub-chart .ub-unit { color: var(--muted); margin-bottom: 1.6rem; font-size: .9em; }
.ub-chart svg { width: 100%; height: auto; overflow: visible; display: block; }
.ub-chart text { font-family: var(--body); fill: var(--ink); }
.ub-chart .ub-note { margin-top: 1.2rem; max-width: 46ch; color: color-mix(in srgb, var(--ink) 80%, transparent); }
.ub-bar { transform-origin: left; transform: scaleX(0); transition: transform 1.1s cubic-bezier(.2,.8,.2,1); }
.ub-line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); transition: stroke-dashoffset 1.8s ease; }
.ub-arc { transition: stroke-dashoffset 1.4s cubic-bezier(.2,.8,.2,1); }
.ub-cell { opacity: 0; transition: opacity .25s; }
.is-on .ub-bar { transform: scaleX(1); } .is-on .ub-line { stroke-dashoffset: 0; } .is-on .ub-cell { opacity: 1; }

/* timeline */
.ub-timeline h2 { font-size: clamp(1.7rem, 3.4vw, 3rem); margin-bottom: 2.4rem; }
.ub-tl { list-style: none; margin: 0; padding: 0 0 0 1.6rem; border-left: 2px solid var(--line); max-width: 44rem; }
.ub-tl li { position: relative; padding: 0 0 1.8rem; }
.ub-tl li::before { content: ""; position: absolute; left: calc(-1.6rem - 7px); top: .45em; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.ub-tl .ub-when { font-family: var(--display); font-weight: 700; color: var(--accent); font-size: 1.15em; }

/* compare */
.ub-compare h2 { font-size: clamp(1.7rem, 3.4vw, 3rem); margin-bottom: 2.2rem; max-width: 24ch; }
.ub-sides { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1rem, 4vw, 4rem); }
.ub-side h3 { font-size: clamp(1.3rem, 2.2vw, 2rem); padding-bottom: .6rem; border-bottom: 3px solid var(--accent); margin-bottom: 1rem; }
.ub-side:last-child h3 { border-color: var(--accent2); }
.ub-side ul { margin: 0; padding-left: 1.1em; } .ub-side li { margin: .5rem 0; }
@media (max-width: 620px) { .ub-sides { grid-template-columns: 1fr; } }

/* steps: a real sequence, so it is numbered */
.ub-steps h2 { font-size: clamp(1.7rem, 3.4vw, 3rem); margin-bottom: 2.2rem; }
.ub-steps ol { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 1.6rem; max-width: 46rem; }
.ub-steps li { counter-increment: s; display: grid; grid-template-columns: 3.2rem 1fr; gap: 1rem; align-items: baseline; }
.ub-steps li::before { content: counter(s); font-family: var(--display); font-weight: 800; font-size: 2.4rem; color: var(--accent); line-height: 1; }
.ub-steps h3 { font-size: 1.3em; margin-bottom: .2rem; }

/* quote */
.ub-quote blockquote { margin: 0; font-family: var(--display); font-size: clamp(1.8rem, 4vw, 3.6rem); line-height: 1.15; max-width: 24ch; }
.ub-quote blockquote::before { content: "“"; display: block; color: var(--accent); font-size: 2em; line-height: .6; }
.ub-quote .ub-by { margin-top: 1.4rem; color: var(--muted); }

/* hero: pinned while the reader scrolls; scroll position drives t */
.ub-hero { min-height: 260svh; padding: 0; display: block; }
.ub-hero .ub-pin { position: sticky; top: 0; height: 100svh; display: grid; grid-template-rows: 1fr auto; }
.ub-hero iframe { width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.ub-hero .ub-cap { padding: 0 clamp(1.25rem, 6vw, 7rem) clamp(1.5rem, 5vh, 3rem); max-width: 50rem; font-size: 1.05em; }
.ub-hero .ub-wait { position: absolute; top: 1rem; right: 1rem; color: var(--muted); font-size: .75em; pointer-events: none; }
.ub-hero .ub-wait:empty { display: none; }

/* closing */
.ub-closing h2 { font-size: clamp(2rem, 4.4vw, 4rem); max-width: 22ch; }
.ub-closing ul { margin: 2rem 0 0; padding: 0; list-style: none; max-width: 40rem; }
.ub-closing li { padding: .9rem 0; border-top: 1px solid color-mix(in srgb, var(--line) 35%, transparent); }
.ub-end { padding: 3rem clamp(1.25rem, 6vw, 7rem) 4rem; color: var(--muted); font-size: .85em; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between; align-items: center; border-top: 1px solid color-mix(in srgb, var(--line) 25%, transparent); }
.ub-end a { color: var(--ink); }
.ub-cta { display: inline-block; background: var(--accent); color: var(--bg) !important; padding: .7rem 1.1rem; font-weight: 700; text-decoration: none; border-radius: 4px; }

/* reveals: content-specific, not generic. Text sharpens in; numbers count (in JS); charts draw. */
.ub-rv { opacity: 0; filter: blur(6px); transition: opacity .7s ease, filter .7s ease; }
.is-on .ub-rv { opacity: 1; filter: none; }
.is-on .ub-rv:nth-child(2) { transition-delay: .12s; } .is-on .ub-rv:nth-child(3) { transition-delay: .24s; }
@media (prefers-reduced-motion: reduce) { .ub-rv, .ub-bar, .ub-line, .ub-arc, .ub-cell { transition: none !important; opacity: 1 !important; filter: none !important; transform: none !important; stroke-dashoffset: 0 !important; } }
@media print { .ub-hero { min-height: auto; } .ub-hero .ub-pin { position: static; height: 70vh; } .ub-scene { break-inside: avoid; min-height: auto; } .ub-rv { opacity: 1; filter: none; } }

/* ---------------------------------------------------------------- per-style character */
[data-style="broadsheet"] { background-image: radial-gradient(color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.2px); background-size: 4px 4px; }
[data-style="broadsheet"] .ub-scene + .ub-scene { border-top: 1px solid var(--line); }
[data-style="broadsheet"] .ub-stat .ub-num { color: var(--ink); } [data-style="broadsheet"] .ub-stat .ub-num .u { color: var(--accent); }
[data-style="blueprint"] { background-image: linear-gradient(color-mix(in srgb, var(--line) 12%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--line) 12%, transparent) 1px, transparent 1px); background-size: 24px 24px; }
[data-style="blueprint"] h1, [data-style="blueprint"] h2 { text-transform: none; letter-spacing: 0; }
[data-style="blueprint"] .ub-stat .ub-num { -webkit-text-stroke: 2px var(--accent); color: transparent; }
[data-style="riso"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
[data-style="riso"] h1, [data-style="riso"] h2 { text-shadow: 3px 2px 0 color-mix(in srgb, var(--accent) 70%, transparent), -2px -1px 0 color-mix(in srgb, var(--accent2) 60%, transparent); }
[data-style="riso"] .ub-stat .ub-num { color: var(--accent); mix-blend-mode: multiply; text-shadow: 6px 4px 0 var(--accent2); }
[data-style="noir"] .ub-stat .ub-num, [data-style="noir"] .ub-stats .ub-num { text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 60%, transparent); }
[data-style="noir"] .ub-scene::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(to bottom, transparent 0 3px, color-mix(in srgb, #fff 3%, transparent) 3px 4px); }
[data-style="museum"] { background-image: radial-gradient(ellipse 70% 60% at 50% 40%, color-mix(in srgb, #fff 6%, transparent), transparent 70%); background-attachment: fixed; }
[data-style="museum"] h1, [data-style="museum"] h2 { font-weight: 500; }
[data-style="museum"] .ub-stat .ub-num { font-weight: 500; }
[data-style="museum"] .ub-src { border-left: 2px solid var(--accent); padding-left: 1rem; }
[data-style="playground"] h1, [data-style="playground"] h2 { font-weight: 800; }
[data-style="playground"] .ub-side h3, [data-style="playground"] .ub-cta { border: 3px solid var(--ink); }
[data-style="playground"] .ub-stat .ub-num { color: var(--accent); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
