/* Per-era tokens, textures and layouts. Each section carries its own data-era,
   so print and scroll mode get the right look per scene; body[data-era] follows
   the current scene (counter, gaps between sections). */

[data-era] {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}
section[data-era] { background-image: var(--texture); }
b { font-weight: inherit; color: var(--accent-text, var(--accent)); }
h1, h2, h3 { font-family: var(--font-head); font-weight: var(--head-weight, 700); }
small, .meta { font-size: max(20px, 0.72em); color: var(--muted); }

/* ================= Bao cấp: pulp paper, rubber stamps, misregistered print ================= */
[data-era="baocap"] {
  --bg: #D9D2BC;
  --ink: #2A2622;
  --accent: #B3261E;
  --violet: #3E3A6B;
  --accent-text: #7A1712;
  --muted: #3D352D;
  --font-body: "Xanh Mono", ui-monospace, monospace;
  --font-head: "Xanh Mono", ui-monospace, monospace;
  --head-weight: 400;
  --texture: url(../assets/pulp.svg);
}
section[data-era="baocap"] h1,
section[data-era="baocap"] h2 {
  line-height: 1.12;
  /* misregistered second ink pass */
  text-shadow: -0.045em 0.035em 0 rgb(179 38 30 / 0.38);
}
section[data-era="baocap"] b { text-decoration: underline 0.08em var(--accent); text-underline-offset: 0.15em; }

.coupon {
  position: relative;
  background: #EFE9D6 url(../assets/pulp.svg);
  border: 0;
  outline: 1.5px solid var(--ink);
  outline-offset: -18px;
  padding: 1.3em 1.7em 1.4em;
  -webkit-mask: var(--holes);
  mask: var(--holes);
}
.coupon-head {
  display: flex; justify-content: space-between; gap: 1em;
  border-bottom: 3px double var(--ink);
  padding-bottom: 0.25em; margin-bottom: 0.5em;
  font-style: italic; color: var(--accent-text);
}
/* The punched edge + shadow is drawn by a separate layer behind the coupon, so no filter
   sits on the text (a filter makes Chrome print the whole coupon as an image). */
.coupon-wrap {
  align-self: center;
  position: relative;
  /* perforated edges: half-holes punched out of the top and bottom, page shows through */
  --holes:
    radial-gradient(circle 12px at 18px 0, #0000 97%, #000) top / 36px 51% repeat-x,
    radial-gradient(circle 12px at 18px 100%, #0000 97%, #000) bottom / 36px 51% repeat-x;
}
.coupon-edge {
  position: absolute; inset: 0;
  /* 1.5px ink edge traced around the punched outline, then the offset shadow */
  filter: drop-shadow(0 -1.5px 0 var(--ink)) drop-shadow(0 1.5px 0 var(--ink)) drop-shadow(-1.5px 0 0 var(--ink)) drop-shadow(1.5px 0 0 var(--ink)) drop-shadow(0.3em 0.35em 0 rgb(42 38 34 / 0.22));
}
.coupon-edge > div { position: absolute; inset: 0; background: #EFE9D6; -webkit-mask: var(--holes); mask: var(--holes); }
.coupon-title { max-width: 30em; font-size: 1.12em; }
.coupon-title h1 { font-size: 2.35em; margin: 0.15em 0 0.1em; max-width: 12em; }
.coupon-title .deck { font-style: italic; font-size: 1.15em; }
.holders { display: grid; grid-template-columns: auto 1fr; gap: 0.15em 0.8em; margin-top: 1em; max-width: 16em; }
.holders dt { color: var(--muted); font-style: italic; }
.holders dd { border-bottom: 2px dotted var(--ink); }
.stamp {
  position: absolute; right: 1.2em; bottom: 0.6em;
  width: 7em; color: var(--violet);
  transform: rotate(-14deg);
  opacity: 0.82;
  mix-blend-mode: multiply;
  font-family: "Xanh Mono", monospace;
}

/* Scene 1: a ledger on the left, the inflation stamp on the right */
#scene-1 { display: grid; grid-template-columns: 1.25fr 1fr; align-items: center; gap: 1.5em; }
.inflation-col { position: relative; min-height: 16em; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.pho { display: grid; justify-items: center; gap: 0.3em; }
.pho .tag { width: 9em; transform: rotate(-8deg); transform-origin: 50% 0; overflow: visible; }
.pho figcaption { font-size: max(22px, 0.8em); font-style: italic; color: var(--muted); max-width: 16em; text-align: center; }
.inflation-col .inflation { position: absolute; left: -2.4em; bottom: -1.1em; z-index: 2; background: rgb(239 233 214 / 0.55); }
.ledger h2 { font-size: 2em; margin-bottom: 0.5em; }
.ledger-rows > div { padding: 0.35em 0; border-bottom: 2px dashed rgb(42 38 34 / 0.45); }
.ledger-rows dt { font-size: max(20px, 0.75em); color: var(--muted); font-style: italic; }
.ledger-rows dd { font-size: 1.05em; }
.inflation {
  justify-self: center;
  border: 0.14em solid var(--accent);
  outline: 0.05em solid var(--accent); outline-offset: 0.12em;
  padding: 0.4em 0.8em 0.2em;
  color: var(--accent-text);
  transform: rotate(-4deg);
  mix-blend-mode: multiply;
  text-align: center;
}
.inflation-label { font-style: italic; }
.inflation-value { font-size: 3.4em; line-height: 1; letter-spacing: -0.03em; }

/* Scene 2: the Đổi Mới coupon fills the stage (it tears into scene 3) */
.coupon-reform { max-width: 34em; padding-right: 7.5em; }
.coupon-reform .coupon-head { margin-right: -5.8em; }
.coupon-reform .stamp-big { position: absolute; right: 1em; top: 50%; width: 6em; transform: translateY(-50%) rotate(12deg); color: var(--violet); opacity: 0.8; mix-blend-mode: multiply; }
.coupon-reform h2 { font-size: 1.9em; margin-bottom: 0.3em; }
.reforms { counter-reset: r; display: grid; gap: 0.15em; }
.reforms li { counter-increment: r; display: flex; gap: 0.6em; align-items: baseline; }
.reforms li::before {
  content: counter(r);
  flex: none; width: 1.3em; height: 1.3em; line-height: 1.25em; text-align: center;
  border: 2px solid var(--violet); color: var(--violet);
  transform: rotate(-6deg);
}
.pain { margin-top: 0.6em; border-top: 2px dashed rgb(42 38 34 / 0.45); padding-top: 0.5em; display: grid; gap: 0.25em; }
.stamped { color: var(--violet); border: 2px solid var(--violet); padding: 0 0.25em; display: inline-block; transform: rotate(-2deg); }

/* ================= Newsprint: 1990s newspaper, halftone, coarse serif ================= */
[data-era="newsprint"] {
  --bg: #E6E2D6;
  --ink: #1C1C1C;
  --accent: #C0392B;
  --accent-text: #8E1B15;
  --muted: #3D3A35;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-head: "Playfair Display", Georgia, serif;
  --head-weight: 900;
  --texture: url(../assets/grain.svg);
}
section[data-era="newsprint"] section, section[data-era="newsprint"] { justify-content: flex-start; padding-top: 4.5vh; }
.masthead {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 5px solid var(--ink);
  box-shadow: 0 7px 0 -5px var(--bg), 0 9px 0 -5px var(--ink); /* thick-thin rule */
  padding-bottom: 0.15em;
}
.masthead-name { font-family: "Playfair Display", serif; font-weight: 900; font-style: italic; font-size: 1.7em; line-height: 1; }
.masthead-date { font-style: italic; }
.front { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.2em; flex: 1; min-height: 0; padding-top: 0.6em; }
.story { display: flex; flex-direction: column; justify-content: center; gap: 0.55em; }
.headline { font-size: 2.55em; line-height: 1.04; letter-spacing: -0.01em; text-wrap: balance; }
.standfirst { font-style: italic; line-height: 1.3; }
.sidebar { border-top: 4px solid var(--accent); padding-top: 0.3em; }
.kicker { font-family: "Playfair Display", serif; font-style: italic; font-weight: 700; color: var(--accent-text); }
.continued { font-style: italic; border-top: 1px solid var(--ink); padding-top: 0.3em; margin-top: auto; }
.halftone-photo { border-left: 1px solid var(--ink); padding-left: 1.2em; display: flex; flex-direction: column; gap: 0.3em; }
.halftone-photo svg { width: 100%; height: auto; filter: contrast(1.1); mix-blend-mode: multiply; }
.halftone-photo figcaption { font-size: max(20px, 0.72em); font-style: italic; color: var(--muted); }

/* ================= Lights on: night, lanterns ================= */
[data-era="lights"] {
  --bg: #0E1A2B;
  --ink: #F1E9DA;
  --accent: #F2A33A;
  --accent-text: #F2A33A;
  --silk: #C8322B;
  --muted: #B8B0A2;
  --font-body: "Be Vietnam Pro", system-ui, sans-serif;
  --font-head: "Be Vietnam Pro", system-ui, sans-serif;
  --head-weight: 300;
  --texture: none;
}
#scene-4 { justify-content: center; padding-top: 4vh; padding-bottom: 4vh; }
#scene-4 h2 { font-size: 1.6em; letter-spacing: 0.02em; color: var(--accent); }
.lights-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5em; align-items: end; }
.lights-panel { display: flex; flex-direction: column; align-items: center; gap: 0.45em; text-align: center; }
.lantern-grid, .people-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 0.08em 0.14em; width: 11em; }
.lantern, .person { display: block; width: 100%; height: auto; overflow: visible; }
.lantern .lit, .person .lit { opacity: var(--lit, 0); }
.lantern .lit { filter: drop-shadow(0 0 3px rgb(242 163 58 / 0.85)); }
.legend { font-size: max(20px, 0.72em); color: var(--muted); }
.lights-label { color: var(--muted); font-weight: 300; }
.lights-change { font-size: 1.35em; font-weight: 300; }
.lights-change b { font-weight: 600; text-shadow: 0 0 0.5em rgb(242 163 58 / 0.55); }

/* ================= Dashboard: clean modern data UI ================= */
[data-era="dashboard"] {
  --bg: #FFFFFF;
  --ink: #1F2937;
  --accent: #DA251D;
  --accent-text: #A01A14;
  --gold: #FFCD00;
  --line: #D9DDE3;
  --muted: #4B5563;
  --font-body: "Be Vietnam Pro", system-ui, sans-serif;
  --font-head: "Be Vietnam Pro", system-ui, sans-serif;
  --head-weight: 800;
  --texture:
    linear-gradient(#EEF0F3 1px, transparent 1px) 0 0 / 2em 2em,
    linear-gradient(90deg, #EEF0F3 1px, transparent 1px) 0 0 / 2em 2em;
  font-variant-numeric: tabular-nums;
}
section[data-era="dashboard"] { background: var(--texture), var(--bg); justify-content: center; gap: 0.75em; }
.dash-bar { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; border-bottom: 2px solid var(--ink); padding-bottom: 0.25em; }
.dash-bar h2 { font-size: 1.5em; letter-spacing: -0.02em; }
.dash-status { font-size: max(20px, 0.75em); font-weight: 600; border-left: 0.35em solid var(--gold); padding: 0.1em 0.5em; background: #FFF8D6; }
.dash-status-warn { border-left-color: var(--accent); background: #FDECEB; color: #8E1B15; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1em; }
.kpi { display: flex; flex-direction: column; border-top: 0.2em solid var(--ink); padding-top: 0.25em; }
.kpi:first-child { border-top-color: var(--accent); }
.kpi-label { font-size: max(20px, 0.75em); color: var(--muted); font-weight: 600; }
.kpi-value { white-space: nowrap; font-size: 1.55em; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.dash-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1em; }
.dash-row p:nth-child(2) { grid-column: span 2; }
.dash-row p { border-left: 1px solid var(--line); padding-left: 0.6em; }
.dash-row b { font-weight: 800; }
.dash-row .kpi-label { display: block; }
.compare { width: 100%; }
.compare th, .compare td { text-align: left; padding: 0.12em 0.8em 0.12em 0; border-bottom: 1px solid var(--line); }
.compare thead th { font-weight: 800; border-bottom: 2px solid var(--ink); }
.compare tbody th { font-weight: 400; color: var(--muted); }
.compare td { font-weight: 600; }
.flag { display: inline-block; width: 1.1em; height: 0.75em; margin-right: 0.35em; vertical-align: -0.05em; position: relative; }
.flag-vn { background: #DA251D; }
.flag-vn::after { content: ""; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 20'%3E%3Cpath fill='%23FFCD00' d='M15 4l1.8 5.5h5.8l-4.7 3.4 1.8 5.5-4.7-3.4-4.7 3.4 1.8-5.5-4.7-3.4h5.8z'/%3E%3C/svg%3E") center / contain no-repeat; }
.flag-ph { background: linear-gradient(#0038A8 50%, #CE1126 50%); }
.flag-ph::after { content: ""; position: absolute; inset: 0; background: #fff; clip-path: polygon(0 0, 50% 50%, 0 100%); }

.alerts { display: grid; gap: 0.65em; position: relative; }
.alerts li {
  display: grid; grid-template-columns: 5.2em 5.8em 1fr auto; gap: 0 0.6em; align-items: baseline;
  border-left: 0.22em solid var(--accent); padding: 0.1em 0 0.1em 0.55em; line-height: 1.22;
  background: var(--bg); /* the crack shows only between the rows */
}
.alert-tag { font-weight: 800; color: var(--accent-text); }
.alert-fig { font-size: 1.15em; font-weight: 800; line-height: 1.05; white-space: nowrap; }
.alert-text { line-height: 1.2; }
.alert-text [lang="vi"] { white-space: nowrap; }
.crack { position: absolute; inset: 0; width: 100%; height: 100%; max-height: 100%; pointer-events: none; }
.crack path { fill: none; stroke: #9CA3AF; stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linejoin: bevel; }
.dash-bar, .alerts { position: relative; z-index: 1; }
.fx-crack { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 6; pointer-events: none; }
.fx-crack path { fill: none; stroke: #111827; stroke-width: 5; stroke-dasharray: 1; stroke-linejoin: bevel; }
.trio { display: flex; gap: 0.5em; align-self: center; margin-right: 1.2em; }
.trio-item { display: grid; justify-items: center; font-size: max(20px, 0.7em); color: var(--muted); line-height: 1.1; }
.trio .lantern { width: 2.6em; }
.trio .lantern > use:first-child { filter: grayscale(1) brightness(3.6); }

/* ================= The road: asphalt, road paint, signage ================= */
[data-era="road"] {
  --bg: #2B2B2E;
  --ink: #F4F4F0;
  --accent: #FFCD00;
  --accent-text: #FFCD00;
  --green: #1E6B45;
  --muted: #C9C9C2;
  --font-body: "Overpass", system-ui, sans-serif;
  --font-head: "Overpass", system-ui, sans-serif;
  --head-weight: 800;
  --texture: url(../assets/asphalt.svg);
}
.sign {
  align-self: flex-start;
  padding: 0.3em 0.7em 0.2em;
  border-radius: 0.3em;
  box-shadow: inset 0 0 0 0.12em currentColor, 0 0.2em 0 rgb(0 0 0 / 0.35);
  line-height: 1.25;
}
.sign b { color: inherit; font-weight: 800; margin-right: 0.35em; }
.sign-green { background: var(--green); color: #fff; }
.sign-warn { background: var(--accent); color: #1A1A1A; }
.sign-work {
  background: #F4F4F0; color: #1A1A1A;
  border-top: 0.4em solid transparent;
  border-image: repeating-linear-gradient(-45deg, #1A1A1A 0 0.4em, var(--accent) 0.4em 0.8em) 1;
  border-radius: 0;
}
#scene-8 { justify-content: flex-start; padding-top: 4vh; padding-bottom: 6vh; }
#scene-8 h2 { font-size: 1.5em; }
.road-notes { display: grid; gap: 0.45em; }
.road-notes .sign { max-width: 32em; }
.road { width: 100vw; max-width: none; height: 44vh; margin: auto -6vw 0; overflow: visible; }
#scene-9 { justify-content: center; align-items: center; text-align: center; }
.fork-signs { display: flex; justify-content: space-between; width: 100%; max-width: 30em; margin-bottom: 0.6em; }
.question { font-size: 2.4em; line-height: 1.05; max-width: 11em; }
.sources {
  position: absolute; inset: 0;
  background: var(--bg) var(--texture);
  padding: 5vh 5vw;
  text-align: left;
  display: flex; flex-direction: column; justify-content: center;
  font-size: max(22px, 0.8em);
}
@media screen { .presenter .sources a { display: none; } }
.sources h3 { font-size: 1.6em; margin-bottom: 0.4em; color: var(--accent); }
.sources ol { columns: 2; column-gap: 3.5em; list-style: decimal; padding-left: 1.4em; }
.sources li { break-inside: avoid; margin-bottom: 0.45em; }
.sources a { color: var(--muted); }

/* Narrow screens: scroll mode, stacked layouts */
@media screen and (max-width: 800px) {
  #scene-1, .front, .lights-grid, .dash-row { grid-template-columns: 1fr; }
  .alerts li { grid-template-columns: auto 1fr; }
  /* decorative stamps stop overlapping text on phones */
  .stamp { position: static; display: block; margin: 0.6em auto 0; width: 5.5em; }
  .coupon-reform { padding-right: 1.7em; }
  .coupon-reform .coupon-head { margin-right: 0; }
  .coupon-reform .stamp-big { display: none; }
  .inflation-col { min-height: 0; }
  .lantern-grid, .people-grid { width: 8.5em; }
  .road { height: auto; margin-top: 1.5em; }
  #scene-8 { justify-content: center; }
  #counter { display: none; } /* phones scroll; the slide counter is for presenting */
  .compare th, .compare td { padding-top: 0.02em; padding-bottom: 0.02em; }
  section[data-era] { padding-top: 3vh; padding-bottom: 3vh; }
  .road text { font-size: 90px; }
  .road .fork-label { display: none; } /* too small at phone width; scene 9 shows the fork */
  .inflation-col .inflation { position: static; justify-self: center; margin: 4.5em auto 0; } /* clears the tag at its 1.55× end scale */
  .alerts li > .alert-text, .alerts li > .trio { grid-column: 1 / -1; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .halftone-photo { border-left: 0; padding-left: 0; }
  .sources { position: static; }
  .sources ol { columns: 1; }
}

@media print {
  /* light PNG tiles instead of SVG noise: keeps the paper feel without a 30 MB PDF */
  section[data-era="baocap"], .coupon { background-image: url(../assets/pulp-print.png); }
  section[data-era="newsprint"] { background-image: url(../assets/grain-print.png); }
  section[data-era="road"] { background-image: url(../assets/asphalt-print.png); }
  .sources { background-image: none; }
  .lantern .lit { filter: none; } /* glow is invisible on paper and costs ~1 MB */
  #scene-9 { height: auto; display: block; padding: 0; }
  #scene-9 > .question { margin: 0 auto; }
  #scene-9 > .fork-signs { margin: 0 auto 0.8em; padding-top: 30vh; }
  .sources { position: relative; inset: auto; break-before: page; min-height: 100vh; font-size: 17px; }
  .sources a { font-size: 14px; }
  .halftone-photo svg { max-height: 45vh; }
}
