/* ==========================================================================
   Games: the shared setup form and projector stage for every game
   (Who Was That?, Before or After?). The ww- prefix is historical: it
   started as Who Was That?'s stylesheet. js/game-stage.js is the shared
   script. Tokens come from f39.css. The stage is a full-screen <dialog>
   on Ink, sized to read from the back of a room on a projector.
   ========================================================================== */

/* ---------- Page ---------- */
.ww-how h2, .ww-setup h2, .ww-sheet h2 { margin-bottom: var(--s-6); }
.ww-steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-5); }
.ww-steps li { counter-increment: step; background: var(--scroll); border: 1px solid var(--line); border-top: 6px solid var(--gold); border-radius: var(--radius); padding: var(--s-5); }
.ww-steps li::before { content: counter(step, decimal-leading-zero); display: block; font-family: var(--font-display); font-weight: 900; font-size: 2.25rem; line-height: 1; color: var(--gold-deep); margin-bottom: var(--s-3); }
.ww-steps b { display: block; font-family: var(--font-display); font-size: 1.2rem; line-height: 1.25; margin-bottom: var(--s-2); }
@media (max-width: 1023px) { .ww-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 479px) { .ww-steps { grid-template-columns: 1fr; } }

.ww-hero-cta { margin-top: var(--s-6); }
.ww-setup { scroll-margin-top: 76px; } /* clears the sticky header when "Play" jumps here */
.ww-soon { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin: 0; color: var(--stone); }
.ww-soon .pill { color: var(--accent); }

/* Setup form */
.ww-form { display: grid; gap: var(--s-6); max-width: 880px; }
.ww-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.ww-form legend, .ww-field label { font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; margin-bottom: var(--s-3); padding: 0; }
.ww-form legend .muted { font-family: var(--font-body); font-weight: 400; font-size: var(--fs-small); }
.ww-legend-note { margin: calc(-1 * var(--s-2)) 0 var(--s-4); }
/* Pack toggles: the whole card is the switch's label */
.ww-pack-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.ww-pack { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: 64px; cursor: pointer;
  background: var(--scroll); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-2) var(--s-4); transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.ww-pack:hover { border-color: var(--stone); }
.ww-pack:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ww-pack-text { min-width: 0; line-height: 1.3; }
.ww-pack-text b { font-family: var(--font-display); font-size: 1.05rem; }
.ww-pack-text small { display: block; color: var(--stone); font-size: .8rem; }
.ww-pack-text small strong { color: var(--ink); font-weight: 700; }
.ww-total { margin: var(--s-3) 0 0; font-family: var(--font-display); font-weight: 500; font-size: 1.125rem; }
.ww-total b { font-weight: 900; font-size: 1.4em; letter-spacing: -.02em; margin-right: .1em; }
@media (max-width: 767px) { .ww-pack-list { grid-template-columns: 1fr; } }

.ww-row { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); gap: var(--s-5); }
@media (max-width: 479px) { .ww-row { grid-template-columns: 1fr; } }
.ww-field label { display: block; }
.ww-form select, .ww-form input[type="text"] {
  width: 100%; min-height: 48px; font: inherit; color: var(--ink); background: var(--scroll);
  border: 1px solid var(--stone); border-radius: var(--radius); padding: 0 var(--s-4);
}
.ww-add { display: flex; gap: var(--s-3); max-width: 480px; }
.ww-add input { flex: 1; min-width: 0; }
.ww-add .btn { min-height: 48px; }
.ww-roster { list-style: none; margin: var(--s-4) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ww-roster:empty { display: none; }
.ww-roster li { display: inline-flex; align-items: center; gap: var(--s-1); background: var(--scroll); border: 1px solid var(--line); border-radius: var(--radius-pill); padding-left: var(--s-4); font-weight: 600; }
.ww-roster button { all: unset; box-sizing: border-box; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; border-radius: 50%; font-size: 1.25rem; color: var(--stone); }
.ww-roster button:hover { color: var(--danger); }
.ww-roster button:focus-visible { outline: 3px solid var(--ink); outline-offset: -6px; }
.ww-form-msg { font-weight: 600; margin: 0; }
.ww-form-msg:empty { display: none; }
.ww-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.ww-actions .btn[disabled] { opacity: .5; cursor: default; }
.ww .btn[hidden], .ww-bottom [hidden] { display: none; }

/* One-of-several choice (radio cards), e.g. difficulty */
.ww-choice-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.ww-choice { display: flex; align-items: flex-start; gap: var(--s-3); min-height: 64px; cursor: pointer; background: var(--scroll); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-3) var(--s-4); transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.ww-choice:hover { border-color: var(--stone); }
.ww-choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ww-choice input { flex: none; width: 1.25rem; height: 1.25rem; margin: .15rem 0 0; accent-color: var(--accent); }
.ww-choice input:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.ww-choice b { display: block; font-family: var(--font-display); font-size: 1.05rem; line-height: 1.3; }
.ww-choice small { display: block; color: var(--stone); font-size: .8rem; line-height: 1.35; }
@media (max-width: 767px) { .ww-choice-list { grid-template-columns: 1fr; } }

/* Host sheet */
.ww-sheet-actions { margin: var(--s-5) 0; }
.ww-sheet-list { border-top: 1px solid var(--line); }
.ww-sheet-list summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; }
.ww-sheet-list h3 { margin: var(--s-6) 0 var(--s-3); }
.ww-sheet-list dl { margin: 0; display: grid; grid-template-columns: minmax(10rem, 1fr) 3fr; border-top: 1px solid var(--line); }
.ww-sheet-list dt, .ww-sheet-list dd { margin: 0; padding: var(--s-3) var(--s-3) var(--s-3) 0; border-bottom: 1px solid var(--line); }
.ww-sheet-list dt { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; line-height: 1.3; }
.ww-sheet-list dt small { display: block; font-family: var(--font-body); font-weight: 400; font-size: var(--fs-small); color: var(--stone); }
.ww-sheet-list dd small { color: var(--stone); font-size: var(--fs-small); }
@media (max-width: 479px) {
  .ww-sheet-list dl { grid-template-columns: 1fr; }
  .ww-sheet-list dt { border-bottom: 0; padding-bottom: 0; }
}

/* ---------- Stage (the projected game) ---------- */
.ww-stage {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--ink); color: var(--scroll); overflow: hidden;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
.ww-stage[open] { display: grid; grid-template-rows: auto 1fr auto; }
.ww-stage::backdrop { background: var(--ink); }
.ww-stage :focus-visible { outline-color: var(--gold); }
.ww-stage::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  background: linear-gradient(90deg, var(--law) 0 12.8%, var(--history) 0 43.6%, var(--poetry) 0 56.4%, var(--major) 0 69.2%, var(--minor) 0); }

.ww-top, .ww-bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--gutter); }
.ww-bottom { padding-bottom: calc(var(--s-5) + 10px); }
.ww-count { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-eyebrow); letter-spacing: .32em; text-transform: uppercase; color: var(--muted-on-dark); }
.ww-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); }
.ww-tool {
  all: unset; box-sizing: border-box; min-height: 44px; padding: 0 var(--s-4); display: inline-flex; align-items: center; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--scroll); border: 1px solid var(--line-on-dark); border-radius: var(--radius);
}
.ww-tool:hover { border-color: var(--scroll); }
.ww-tool:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.ww-tool[hidden] { display: none; }
.ww-tool[aria-pressed="true"] { background: var(--scroll); color: var(--ink); }
.ww-bottom .btn { font-size: 1.05rem; padding: 1.05rem 2rem; margin-left: auto; }

.ww-body { overflow-y: auto; display: grid; align-items: center; padding: var(--s-5) var(--gutter); }
.ww-phase { width: 100%; max-width: 1280px; margin-inline: auto; }
.ww-phase > * { max-width: none; }
.ww-kicker { display: inline-flex; align-items: center; gap: var(--s-3); font-family: var(--font-display); font-weight: 600; font-size: clamp(.9rem, 1.4vw, 1.25rem); letter-spacing: .32em; text-transform: uppercase; color: var(--gold); margin-bottom: var(--s-4); }
.ww-kicker::before { content: ""; width: 2.5rem; height: 4px; background: var(--gold); }
.ww-name { font-size: clamp(3rem, 10vw, 10rem); font-weight: 900; text-transform: uppercase; line-height: .9; letter-spacing: -.035em; margin-bottom: var(--s-5); overflow-wrap: anywhere; outline: none; }
.ww-name--sm { font-size: clamp(2.25rem, 6.5vw, 6rem); }
.ww-name:focus, .ww-name:focus-visible { outline: none; } /* moved to by script, not a control */
.ww-clue { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.5rem, 3.6vw, 3.25rem); line-height: 1.2; margin-bottom: var(--s-6); }
.ww-say { font-size: clamp(1rem, 1.6vw, 1.375rem); color: var(--muted-on-dark); }

/* Waiting screen: just the name, big and centered, while answers come in */
.ww-wait { text-align: center; }
.ww-wait .ww-name { font-size: clamp(3.5rem, 13vw, 13rem); margin-bottom: var(--s-6); }
.ww-wait-say { display: inline-flex; align-items: center; gap: var(--s-4); margin: 0; max-width: none;
  font-family: var(--font-display); font-weight: 600; font-size: clamp(1.25rem, 3vw, 2.5rem); letter-spacing: .02em; color: var(--gold); }
.ww-wait-say::before, .ww-wait-say::after { content: ""; width: clamp(1.5rem, 4vw, 3.5rem); height: 4px; background: var(--gold); }

.ww-timer { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-6); }
.ww-clock { margin: 0 var(--s-3) 0 0; font-family: var(--font-display); font-weight: 800; font-size: clamp(2.5rem, 6vw, 5rem); line-height: 1; font-variant-numeric: tabular-nums; }
.ww-timer.is-done .ww-clock { color: var(--gold); }
.ww-timer[hidden] { display: none; }


.ww-answer { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.5rem, 3.4vw, 3rem); line-height: 1.25; max-width: 32ch !important; margin-bottom: var(--s-5); }
.ww-ref { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); font-family: var(--font-display); font-weight: 600; font-size: clamp(1rem, 1.8vw, 1.5rem); letter-spacing: .04em; color: var(--muted-on-dark); }
.ww-chip { font-size: .7em; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; padding: .45em .9em; border-radius: var(--radius); }
.ww-chip[hidden] { display: none; }

/* Feedback on the name: kept quiet so it doesn't pull focus from the reveal */
.ww-rate { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-7); font-size: var(--fs-small); color: var(--muted-on-dark); }
.ww-rate span:first-child { margin-right: var(--s-1); }
.ww-rate button { all: unset; box-sizing: border-box; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer;
  color: var(--muted-on-dark); border: 1px solid var(--line-on-dark); border-radius: var(--radius); }
.ww-rate button:hover { color: var(--scroll); border-color: var(--muted-on-dark); }
.ww-rate button[aria-pressed="true"] { background: var(--scroll); color: var(--ink); border-color: var(--scroll); }
.ww-rate button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
/* Section colors: Ink text on Law (gold) and Poetry (sage); white fails there */
.ww-chip--law { background: var(--law); color: var(--ink); }
.ww-chip--history { background: var(--history); color: #fff; }
.ww-chip--poetry { background: var(--poetry); color: var(--ink); }
.ww-chip--major { background: var(--major); color: #fff; box-shadow: inset 0 0 0 1px var(--line-on-dark); }
.ww-chip--minor { background: var(--minor); color: #fff; box-shadow: inset 0 0 0 1px var(--line-on-dark); }

/* The answer, inverted: the room has been in the dark (Ink) through the guessing,
   and the truth arrives on Scroll paper, like a base slide in the F39 deck style.
   Brand rules for light backgrounds: Ink type, Gold only as a rule, Gold Deep for
   gold text (Gold fails as text on Scroll), Stone for secondary text, Ink focus ring. */
.ww-stage.is-light { background: var(--scroll); color: var(--ink); }
.ww-stage.is-light :focus-visible { outline-color: var(--ink); }
.ww-stage.is-light .ww-count { color: var(--stone); }
.ww-stage.is-light .ww-tool { color: var(--ink); border-color: var(--line); }
.ww-stage.is-light .ww-tool:hover { border-color: var(--ink); }
.ww-stage.is-light .ww-tool:focus-visible { outline-color: var(--ink); }
.ww-stage.is-light .ww-kicker { color: var(--gold-deep); }
.ww-stage.is-light .ww-ref { color: var(--stone); }
.ww-stage.is-light .ww-chip--major, .ww-stage.is-light .ww-chip--minor { box-shadow: none; }
.ww-stage.is-light .ww-rate { color: var(--stone); }
.ww-stage.is-light .ww-rate button { color: var(--stone); border-color: var(--line); }
.ww-stage.is-light .ww-rate button:hover { color: var(--ink); border-color: var(--stone); }
.ww-stage.is-light .ww-rate button[aria-pressed="true"] { background: var(--ink); color: var(--scroll); border-color: var(--ink); }
.ww-stage.is-light .ww-rate button:focus-visible { outline-color: var(--ink); }
.ww-stage.is-light .ww-bottom .btn--gold { --btn-bg: var(--ink); --btn-fg: var(--scroll); }

.ww-scores { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--s-3); }
.ww-scores li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s-2) var(--s-4); border: 1px solid var(--line-on-dark); border-radius: var(--radius); padding: var(--s-4); }
.ww-scores .who { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.15rem, 1.8vw, 1.5rem); line-height: 1.2; overflow-wrap: anywhere; }
.ww-scores .pts { font-family: var(--font-display); font-weight: 900; font-size: clamp(2rem, 3.4vw, 3rem); line-height: 1; color: var(--gold); font-variant-numeric: tabular-nums; }
.ww-scores .btns { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ww-scores .rank { color: var(--muted-on-dark); font-weight: 600; margin-right: var(--s-2); }
.ww-scores li.is-lead { border-color: var(--gold); }
.ww-final .ww-scores .btns { display: none; }

@media (max-width: 767px) {
  .ww-top { flex-wrap: wrap; }
  .ww-count { flex-basis: 100%; }
  .ww-tools { justify-content: flex-start; }
}

/* ---------- Print: the host sheet only ---------- */
@media print {
  body > :not(main), .ww > :not(.ww-sheet), .ww-sheet-actions, .ww-sheet-list summary { display: none !important; }
  .ww-sheet { padding: 0; }
  .ww-sheet-list dt, .ww-sheet-list dd { break-inside: avoid; }
}

/* ---------- "Who was…?" buttons on a reveal, and their drawer ---------- */
.ww-about-row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.ww-about-row:empty { display: none; }
.ww-about { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: .55em; min-height: 44px; padding: 0 1rem 0 .55rem; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(.9rem, 1.15vw, 1.05rem); color: inherit;
  border: 1.5px solid currentColor; border-radius: var(--radius-pill); }
.ww-about > span { display: grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: currentColor; font-weight: 900; font-size: .85em; }
.ww-stage.is-light .ww-about { color: var(--ink); border-color: rgba(22, 21, 20, .35); }
.ww-stage.is-light .ww-about > span { background: var(--ink); color: var(--scroll); }
.ww-about:hover { border-color: currentColor; }
.ww-stage.is-light .ww-about:hover { border-color: var(--ink); }
.ww-about:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.gl-body { padding: var(--s-5) var(--s-6) var(--s-7); }
.gl-text { margin: 0; max-width: 40ch; font-size: clamp(1.2rem, 2.2vw, 1.6rem); line-height: 1.5; }
/* A First Eight profile opened from a game: its Pause button sits on the hero video */
.fe-embed .fe-embed-motion { position: absolute; left: var(--s-4); top: var(--s-4); z-index: 2; background: rgba(22, 21, 20, .8); border-color: transparent; color: var(--scroll); }
.fe-embed .fe-embed-motion:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

