/* Layout: a 16:9 handbill for the projector. The woodcut table or the street photo fills the
   left; the words sit on the right like the text block of a 1923 notice; the teacher's
   controls run along the bottom edge. One look on purpose: ink on banknote paper. */
:root {
  --paper: #dedfd2;      /* banknote-grey paper */
  --paper-deep: #cbccbc; /* the same paper in shadow */
  --ink: #1d1b18;        /* printing ink */
  --ink-soft: #57534a;   /* worn ink, for narration and asides */
  --stamp: #b42318;      /* the red of the 1923 overprints stamped on banknotes */
  --muted-bar: #78756b;  /* chart bars that are context, not the point */

  --font-display: 'UnifrakturMaguntia', 'Old English Text MT', 'Times New Roman', serif;
  --font-poster: 'League Gothic', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --font-text: 'Literata', Georgia, 'Times New Roman', serif;

  --step-0: clamp(17px, 1.5vw, 28px);
  --step-1: clamp(19px, 1.8vw, 33px);
  --step-2: clamp(23px, 2.5vw, 44px);
  --step-3: clamp(34px, 4.2vw, 76px);
  --step-4: clamp(44px, 6.6vw, 120px);

  color-scheme: light;
}

html, body { height: 100%; }

body {
  margin: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.45;
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 4px solid var(--stamp); outline-offset: 3px; }

/* ---------- the stage ---------- */

.stage {
  overflow: auto;
  padding-block: clamp(16px, 3vh, 44px);
  padding-left: max(16px, env(safe-area-inset-left, 0px), 3vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 3vw);
}

.screen { min-height: 100%; }

.two-up {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(20px, 3.5vw, 64px);
  align-items: center;
}

.art { position: relative; margin: 0; min-width: 0; }
.art .scene { display: block; }
.words { min-width: 0; max-width: 34em; }

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
.words > * + * { margin-top: 0.75em; }

.month {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-3);
  line-height: 1;
  text-wrap: balance;
}

.question {
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}

h3 { font-family: var(--font-poster); font-weight: 400; font-size: var(--step-2); letter-spacing: 0.02em; }

/* ---------- the dinner table: Blender layers ---------- */

.scene {
  position: relative;
  width: min(100%, calc(74vh * 1840 / 940));
  aspect-ratio: 1840 / 940;
  container-type: inline-size;
  overflow: hidden;
  background: var(--paper);
}
.scene .layer { position: absolute; display: block; max-width: none; }
.scene .room { inset: 0; width: 100%; height: 100%; }
.scene picture img, .scene .calendar img { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene .cal-month, .scene .cal-year { position: absolute; left: 0; right: 0; text-align: center; color: var(--ink); line-height: 1; }
.scene .cal-month { top: 37%; font-family: var(--font-display); font-size: 1.55cqw; }
.scene .cal-year { top: 58%; font-family: var(--font-poster); font-size: 2.7cqw; }
.scene[data-pot="thin"] .steam { opacity: 0.45; }

/* Arriving at a payday: the new money lands, the month turns over, a brother's chair empties. */
.scene .bundle.new { animation: bundle-drop 0.5s cubic-bezier(0.3, 1.35, 0.5, 1) both; animation-delay: calc(var(--k) * 150ms + 600ms); }
@keyframes bundle-drop { from { transform: translateY(-150%); opacity: 0; } 40% { opacity: 1; } }
.scene .tear { transform-origin: 50% 2%; animation: tear-off 1.1s ease-in 0.3s both; }
@keyframes tear-off {
  30% { transform: rotate(-9deg); }
  to { transform: translate(-25%, 150%) rotate(-48deg); opacity: 0; }
}
.scene .leaving { animation: leave 1.6s ease-in 1.2s both; }
@keyframes leave { to { opacity: 0; transform: translateY(-3%); } }
/* Arriving in September 1923, the brothers' badges are pinned on; a brother who leaves takes his along. */
.scene .worn.arrives { animation: pin-on 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) 2s both; }
@keyframes pin-on { from { opacity: 0; transform: scale(2.2); } }
/* After a choice, what the family bought comes into the room and what it gave up goes. */
.scene .thing.arrives { animation: arrive 0.9s ease-out 1.4s both; }
@keyframes arrive { from { opacity: 0; transform: translateY(-4%); } }
.scene .thing.goes { animation: leave 1.6s ease-in 1.4s both; }

/* ---------- the intro ---------- */

.intro { display: grid; gap: clamp(14px, 2.4vh, 32px); align-content: center; }

.title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-4);
  line-height: 0.95;
}

.lede { font-size: var(--step-2); max-width: 28em; }

.family {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 36px);
}

.member .portrait { display: block; height: clamp(90px, 17vh, 210px); width: auto; max-width: 100%; }
.member h2 { font-family: var(--font-poster); font-weight: 400; font-size: var(--step-2); line-height: 1.1; margin-top: 0.3em; }
.member p { font-size: 0.82em; color: var(--ink-soft); }

.holdings { max-width: 40em; }

.actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- buttons ---------- */

.primary, .secondary, .controls button {
  font-family: var(--font-poster);
  font-size: var(--step-1);
  letter-spacing: 0.03em;
  padding: 0.25em 0.9em;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  cursor: pointer;
}

.primary, .controls .next { background: var(--ink); color: var(--paper); }
.primary:hover, .controls .next:hover:not(:disabled) { background: var(--stamp); border-color: var(--stamp); }
.secondary:hover, .controls button:not(.next):hover:not(:disabled) { background: var(--paper-deep); }
.controls button:disabled { opacity: 0.35; cursor: default; }

/* ---------- dialogue ---------- */

.dialogue { display: grid; gap: 0.55em; font-size: var(--step-1); line-height: 1.35; }
.speaker { font-family: var(--font-poster); font-size: 1.05em; letter-spacing: 0.03em; color: var(--ink-soft); }
.narration { font-style: italic; color: var(--ink-soft); font-size: 0.86em; }

/* ---------- the street ---------- */

.photo img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  filter: grayscale(1) contrast(1.05);
  border: 3px solid var(--ink);
}

.photo-missing {
  aspect-ratio: 4 / 3;
  max-width: 100%;
  max-height: 60vh;
  display: grid;
  place-items: center;
  padding: 1em;
  border: 3px solid var(--ink);
  background: repeating-linear-gradient(45deg, var(--paper-deep) 0 5px, var(--paper) 5px 13px);
  font-family: var(--font-poster);
  font-size: var(--step-1);
  text-align: center;
}

.photo-missing span { background: var(--paper); padding: 0.2em 0.5em; }

figcaption { margin-top: 0.6em; font-size: 0.9em; }
.credit { display: block; margin-top: 0.3em; font-size: 0.72em; color: var(--ink-soft); }

.price-tag { border: 3px solid var(--ink); padding: 0.6em 0.9em 0.8em; }
.tag-label { font-family: var(--font-poster); font-size: var(--step-1); letter-spacing: 0.03em; }
.old-price { font-family: var(--font-poster); font-size: var(--step-2); color: var(--ink-soft); }
.old-price s { text-decoration-thickness: 0.12em; text-decoration-color: var(--ink); }
.old-price span { font-family: var(--font-text); font-size: 0.55em; }
.new-price { margin-top: 0.15em; }

.stamp {
  display: inline-block;
  font-family: var(--font-poster);
  font-size: clamp(44px, min(5.6vw, 9vh), 108px);
  line-height: 1.05;
  color: var(--stamp);
  border: 0.06em solid currentColor;
  border-radius: 6px;
  padding: 0 0.22em;
  transform: rotate(-4deg);
  transform-origin: 30% 60%;
  mix-blend-mode: multiply;
  animation: stamp-down 0.42s cubic-bezier(0.2, 1.5, 0.4, 1) 0.25s both;
}

@keyframes stamp-down {
  from { transform: rotate(-14deg) scale(1.9); opacity: 0; }
  to { transform: rotate(-4deg) scale(1); opacity: 1; }
}

.pay strong { font-weight: 600; }
.was { color: var(--ink-soft); }
.note-line { font-size: 0.9em; }

/* The month's real banknote, dropped on the tablecloth while the class guesses. */
.banknote {
  position: absolute;
  left: 5%;
  bottom: 6%;
  width: 46%;
  max-width: 380px;
  height: auto;
  transform: rotate(-5deg);
  box-shadow: 0 8px 18px rgba(29, 27, 24, 0.35);
  animation: note-down 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.15) 0.35s both;
}
@keyframes note-down { from { transform: translateY(-40%) rotate(-14deg); opacity: 0; } }
.street .words > * + * { margin-top: 0.55em; }

/* The class's guess, read back under the real price once the stamp has landed. */
.verdict {
  font-family: var(--font-poster);
  font-size: var(--step-1);
  letter-spacing: 0.02em;
  animation: verdict-in 0.35s ease-out 0.75s both;
}
.verdict.right { color: var(--stamp); }
@keyframes verdict-in { from { opacity: 0; transform: translateY(6px); } }

/* What the savings book is still worth, at every dinner from April on. */
.savings { border-left: 6px solid var(--stamp); padding-left: 0.6em; font-size: 0.9em; }

/* What Dad's weekly pay buys, 1913 = 100%: one column per payday so far. */
.buys { --plot: min(85px, 8vh); display: grid; gap: 0.3em; }
.buys-title { font-family: var(--font-poster); font-size: 0.9em; letter-spacing: 0.02em; }
.cols { display: flex; align-items: flex-end; gap: 6px; height: calc(var(--plot) + 2.3em); }
.col {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  flex: 0 0 3.1em;
  font-size: 0.78em;
}
.col-value { min-height: 1.25em; font-variant-numeric: tabular-nums; }
.col-bar {
  width: 100%;
  height: calc(var(--h) * var(--plot) / 100);
  background: var(--muted-bar);
  border-radius: 4px 4px 0 0;
  transform-origin: bottom;
  animation: grow-up 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 90ms + 200ms);
}
.col.is-focus .col-bar { background: var(--stamp); }
.col.is-focus .col-value, .col.is-focus .col-label { font-weight: 600; }
.col-label { width: 100%; text-align: center; border-top: 2px solid var(--ink); color: var(--ink-soft); }
.col:hover .col-bar, .col:focus-visible .col-bar { filter: brightness(1.15); }
.col:hover::after, .col:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 2;
  bottom: calc(100% + 4px);
  padding: 0.3em 0.6em;
  background: var(--ink);
  color: var(--paper);
  white-space: nowrap;
  border-radius: 4px;
  pointer-events: none;
}
.buys details { font-size: 0.75em; }
.buys summary { cursor: pointer; }
.buys table { margin-top: 0.4em; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.buys th, .buys td { text-align: left; padding: 0.15em 1.2em 0.15em 0; border-bottom: 1px solid var(--paper-deep); }
@keyframes grow-up { from { transform: scaleY(0); } }

/* ---------- the vote ---------- */

.options { display: grid; gap: 0.55em; }

.option {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7em;
  align-items: center;
  text-align: left;
  font-size: var(--step-1);
  line-height: 1.25;
  padding: 0.45em 0.7em;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  cursor: pointer;
}

.option:hover, .option:focus-visible { background: var(--ink); color: var(--paper); }
.option:hover .num, .option:focus-visible .num { border-color: var(--paper); }

.num {
  display: grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border: 3px solid var(--ink);
  border-radius: 50%;
  font-family: var(--font-poster);
  font-size: 1.3em;
}

.hint { font-size: 0.78em; color: var(--ink-soft); }

/* ---------- results ---------- */

.chosen { font-style: italic; color: var(--ink-soft); }
.outcome { display: grid; gap: 0.5em; font-size: var(--step-1); line-height: 1.35; }
.pot-line { font-family: var(--font-poster); font-size: var(--step-2); letter-spacing: 0.02em; }
.many strong { font-weight: 600; }

.ledger { display: grid; gap: 0.35em; }
.ledger li::before { content: "– "; color: var(--ink-soft); }

/* ---------- 1930 ---------- */

.ballots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.ballot {
  display: grid;
  gap: 0.15em;
  align-content: start;
  padding: 0.5em 0.7em;
  border: 3px solid var(--ink);
  background: var(--paper);
}

.ballot .who { color: var(--ink-soft); font-size: 0.85em; }
.ballot .party { font-family: var(--font-poster); font-size: var(--step-2); line-height: 1.05; }
.ballot .why { font-size: 0.78em; }
.ballot .party .flag { width: 1.5em; margin-right: 0.3em; vertical-align: -0.12em; }
.option .label .flag { width: 2em; margin-right: 0.45em; vertical-align: -0.25em; }
.ballot.blank .party { color: var(--stamp); }
/* Fritz's ballot lies face down until its line is read aloud, or for six seconds with the voices off.
   Its back covers the writing until the card stands edge-on, halfway through the turn. As it turns,
   his armband or pin appears in the picture. */
.ballot.turns { position: relative; }
.ballot.turns::after { content: ""; position: absolute; inset: -3px; background: var(--ink); }
[data-voices="off"] .ballot.turns { animation: turn-over 0.6s linear 6s both; }
[data-voices="off"] .ballot.turns::after { animation: card-back 0.6s linear 6s both; }
.ballot.turns.heard { animation: turn-over 0.6s linear both; }
.ballot.turns.heard::after { animation: card-back 0.6s linear both; }
@keyframes turn-over { from { transform: perspective(600px) rotateY(180deg); } }
@keyframes card-back { 0%, 49.9% { opacity: 1; } 50%, 100% { opacity: 0; } }
.screen:has(.ballot.turns) .scene [data-worn*="-fritz1930-"] { opacity: 0; }
[data-voices="off"] .screen:has(.ballot.turns) .scene [data-worn*="-fritz1930-"] { animation: band-on 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) 6.3s both; }
.screen:has(.ballot.turns.heard) .scene [data-worn*="-fritz1930-"] { animation: band-on 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) 0.3s both; }
@keyframes band-on { from { opacity: 0; transform: scale(2.2); } to { opacity: 1; transform: none; } }
.footnote { font-size: 0.78em; color: var(--ink-soft); }

.results { display: grid; gap: 0.7em; }
.results-title { font-family: var(--font-poster); font-size: var(--step-1); letter-spacing: 0.02em; }
.bars { display: grid; gap: 10px; }

.bar-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(7em, 34%) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  font-size: 0.86em;
  border-radius: 4px;
}

.bar-track { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar {
  display: block;
  height: 22px;
  background: var(--muted-bar);
  border-radius: 0 4px 4px 0;
  transform-origin: left;
  animation: grow-right 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 260ms + 400ms);
}
@keyframes grow-right { from { transform: scaleX(0); } }
.is-focus .bar { background: var(--stamp); }
.bar-value { font-variant-numeric: tabular-nums; }
.is-focus .bar-name, .is-focus .bar-value { font-weight: 600; }
.bar-row:hover .bar, .bar-row:focus-visible .bar { filter: brightness(1.15); }

.bar-row:hover::after, .bar-row:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 2;
  left: 34%;
  bottom: calc(100% + 6px);
  padding: 0.3em 0.6em;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85em;
  white-space: nowrap;
  border-radius: 4px;
  pointer-events: none;
}

.results-note { color: var(--ink-soft); font-size: 0.86em; }
.results details { font-size: 0.8em; }
.results summary { cursor: pointer; }
.results table { margin-top: 0.5em; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.results th, .results td { text-align: left; padding: 0.2em 1.2em 0.2em 0; border-bottom: 1px solid var(--paper-deep); }

.debrief { display: grid; gap: 0.5em; font-size: var(--step-2); line-height: 1.25; list-style: decimal; padding-left: 1.2em; }
.notes { font-style: italic; }

/* ---------- the teacher's controls ---------- */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px), 3vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 3vw);
  border-top: 3px solid var(--ink);
  background: var(--paper);
}

.controls button { font-size: clamp(17px, 1.4vw, 26px); }

.months {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 1.6vw, 28px);
  font-family: var(--font-poster);
  font-size: clamp(17px, 1.4vw, 26px);
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.months .done { color: var(--ink); }
.months [aria-current] { color: var(--stamp); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 5px; }

/* ---------- the voice and the records ---------- */

/* The line being read aloud, marked like a pencil underline on the handbill. */
.speaking {
  background: var(--paper-deep);
  box-shadow: 0 0 0 0.25em var(--paper-deep);
  border-radius: 2px;
}

.option.speaking { background: var(--paper-deep); }

.sound-controls { display: flex; gap: 8px; }

.controls .toggle[aria-pressed="false"] {
  color: var(--ink-soft);
  border-color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

/* ---------- smaller screens ---------- */

@media (max-width: 820px) {
  .two-up { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .family { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ballots { grid-template-columns: minmax(0, 1fr); }
  .months { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .stamp, .verdict, .col-bar, .bar, .scene .bundle.new, .banknote, .scene .thing.arrives, .scene .worn.arrives { animation: none; }
  .ballot.turns, .ballot.turns.heard, [data-voices="off"] .ballot.turns { animation: none; }
  .ballot.turns::after { display: none; }
  .scene .tear, .scene .leaving, .scene .thing.goes { display: none; }
  :root .screen:has(.ballot.turns) .scene [data-worn*="-fritz1930-"] { opacity: 1; animation: none; }
}
