/* theater.css (ps-theater, theater.py): a big way to watch the live run. Loaded after arena.css. The big stage on the
   homepage loaded while someone plays, theater (the stage fills the window) and full screen (the same, in the
   browser's full screen); web/theater.js switches them. Pixel fonts at 16 and 24 px, line heights 24 and 32, the bar
   48 px. Aaron: "give as much playable space to the game as possile". */

/* ---- the big stage: the picture as wide as the window allows with the strip still on the first screen
   (72 top bar + 24 above + 104 strip + 24 below = 224 px around it), the headline kept for screen readers only */
.arena.big { padding: 24px 0 56px; --around: 224px; }
.arena.big .headline { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.arena.big .arenain { max-width: none; }
.arena.big .cabinet { grid-template-columns: minmax(0, 1fr); justify-items: center; }
.arena.big .stage, .arena.big .rail { box-sizing: border-box; width: min(100%, max(640px, (100vh - var(--around)) * 16 / 9));
  width: min(100%, max(640px, (100svh - var(--around)) * 16 / 9)); }
.arena.big .rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
/* a window wide for its height (a maximised browser on a 1920 x 1080 screen, 1920 x 969 inside): the card and the
   top five fit beside the picture without making it smaller (width - 544 >= (height - 224) * 16 / 9 from 800 px up) */
@media (min-aspect-ratio: 49/25) and (min-width: 1500px) and (min-height: 800px) {
  .arena.big .cabinet { grid-template-columns: auto 432px; justify-content: center; justify-items: stretch; }
  .arena.big .stage { width: min(100vw - 544px, (100vh - var(--around)) * 16 / 9); }
  .arena.big .rail { width: auto; display: flex; }
}
@media (max-width: 700px) {
  .arena.big { padding: 0 0 40px; }
  .arena.big .rail { grid-template-columns: minmax(0, 1fr); }
}

/* ---- the stage's own buttons (theater.py CONTROLS): bottom right of the picture, quiet; sound in gold while muted */
.th-ui > div { position: absolute; z-index: 4; display: flex; align-items: center; gap: 16px; }
.th-ctl { right: 16px; bottom: 16px; }
.th-ui > .th-ctas { display: none; }
.th-ui button, .th-ui a.button { margin: 0; padding: 4px 16px; font: 16px/24px var(--px); white-space: nowrap; }
.th-ui :is(.th-theater, .th-full, .th-share) { --b: rgba(1, 9, 27, .82); --lip: transparent; color: #f4f7fb; background: rgba(1, 9, 27, .82);
  box-shadow: 0 -4px var(--cta), 0 4px var(--cta), -4px 0 var(--cta), 4px 0 var(--cta), 0 -8px var(--cta-edge), 0 8px var(--cta-edge), -8px 0 var(--cta-edge), 8px 0 var(--cta-edge); }
.th-ui :is(.th-theater, .th-full, .th-share):hover { --b: rgba(1, 9, 27, .82); color: var(--cta-ink); background: var(--cta); }
.th-ui :is(.th-theater, .th-full, .th-share):active { transform: none; }
/* the sound control (theater.py sound(), theater.js; Nov 28, Aaron: "just a normal volume thing with mute and volume
   buttons"): the speaker, quieter, four pips and louder in one frame like the buttons beside it. The marks are one
   colour on a 2 px grid. The speaker is blue while the picture is muted (the one thing to tap for sound), and the pips
   light to the level while it plays. On a phone each button is a 44 px target. */
.th-ui .snd { display: flex; align-items: stretch; box-sizing: border-box; height: 32px; color: #f4f7fb; background: rgba(1, 9, 27, .82);
  box-shadow: 0 -4px var(--cta), 0 4px var(--cta), -4px 0 var(--cta), 4px 0 var(--cta), 0 -8px var(--cta-edge), 0 8px var(--cta-edge), -8px 0 var(--cta-edge), 8px 0 var(--cta-edge); }
.th-ui .snd[hidden] { display: none; }
.th-ui .snd button { --b: transparent; display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 36px;
  height: auto; min-height: 0; margin: 0; padding: 0 12px; color: inherit; background: transparent; box-shadow: none; }
.th-ui .snd .snd-mute { min-width: 48px; }
.th-ui .snd button:hover { color: var(--cta-ink); background: var(--cta-hover); }
.th-ui .snd button:active { transform: none; }
.th-ui .snd button:focus-visible { outline: 4px solid #fff; outline-offset: -4px; }
.th-ui .snd[data-muted="1"] .snd-mute { color: var(--cta-ink); background: var(--cta); }
.th-ui .snd button[aria-disabled=true] { color: rgba(244, 247, 251, .3); background: transparent; cursor: default; }
.snd svg { display: block; flex: none; }
.snd:not([data-muted="1"]) .snd-x, .snd[data-muted="1"] .snd-w { display: none; }
.snd-pips { display: flex; align-items: flex-end; align-self: center; gap: 4px; height: 16px; padding: 0 4px; }
.snd-pips i { width: 4px; height: 4px; background: rgba(244, 247, 251, .3); }
.snd-pips i:nth-child(2) { height: 8px; } .snd-pips i:nth-child(3) { height: 12px; } .snd-pips i:nth-child(4) { height: 16px; }
.snd:not([data-muted="1"]) .snd-pips i.on { background: #f4f7fb; }
.snd[data-fixed] :is(.snd-down, .snd-pips, .snd-up) { display: none; }       /* iPhone: the phone's own buttons set the level */
@media (pointer: coarse), (max-width: 560px) {
  .th-ui .snd { height: 44px; }
  .th-ui .snd button { min-width: 44px; }
}
.th-js .screen:focus { outline: none; }      /* a click on the picture gives it focus for M and the arrows */
.th-js .cap { padding-right: 412px; }     /* the sound, Theater and Fullscreen are 386 px and sit 12 in (Nov 29: the name ran under them) */
@container stage (max-width: 700px) {
  .stage:not(.th-on) .th-theater { display: none; }
  .th-ctl { right: 12px; bottom: 12px; }
  .th-js .cap { padding-right: 300px; }
}
.stage:not(.th-on) :is(.th-onair, .th-vs, .th-watch) { display: none !important; }

/* ---- theater and full screen: the stage fills the window (or the screen), the picture letterboxed on black */
.arena .stage.th-on { position: fixed; inset: 0; z-index: 1000; width: auto; height: auto; margin: 0; overflow: hidden;
  container: stage / size; background: #000; box-shadow: none;
  --pw: min(100cqw, 100cqh * 16 / 9); --ph: min(100cqh, 100cqw * 9 / 16);
  --pl: calc((100cqw - var(--pw)) / 2); --pt: calc((100cqh - var(--ph)) / 2); --bar: 48px; --skip: .14; }
.arena .stage.th-fs { width: 100%; height: 100%; }
html.th-lock, html.th-lock body { overflow: hidden; }
.th-ph { display: block; }
.arena .stage.th-on .screen { position: absolute; left: var(--pl); top: var(--pt); width: var(--pw); height: var(--ph); aspect-ratio: auto;
  background: #000; }
.arena .stage #live { max-width: none; }      /* live.css caps the player at 1280 for a page of its own; the big stage is wider */
.th-on :is(.chip.onair, .viewers, button.rplay), .th-on #live :is(.lv-badge, .lv-info) { display: none !important; }
.th-on [hidden] { display: none !important; }
/* the reel's line moves to the top in theater (the bar has the bottom) */
/* (Nov 28: it was at the top, over the game's own boss bar; the game's HUD is its corners and its top centre, so the
   caption rides bottom centre, just over the bar, between Share and the buttons) */
.arena .stage.th-on .cap { top: auto; bottom: calc(var(--bar) + 12px); left: 50%; right: auto; transform: translateX(-50%);
  width: max-content; max-width: 44%; box-sizing: border-box; padding: 8px 16px; text-align: center; background: rgba(1, 9, 27, .82); }
.arena .stage.th-on .cap:empty { display: none; }
@container stage (max-width: 1700px) { .arena .stage.th-on .score .runner .th-vs { display: none; } }
@container stage (max-width: 1500px) { .arena .stage.th-on .score .th-watch { display: none; } }
.arena .stage.th-on .score .runner b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* The bar: the score strip, slim and see-through, over the bottom of the picture. It starts 14% in, clear of the game's
   own health corner (bottom left); the boss bar (top centre) and the minimap (top right) stay clear. */
.arena .stage.th-on .score { position: absolute; z-index: 3; box-sizing: border-box; display: flex; align-items: center; gap: 0;
  left: calc(var(--pl) + var(--pw) * var(--skip)); top: calc(var(--pt) + var(--ph) - var(--bar));
  width: calc(var(--pw) * (1 - var(--skip))); height: var(--bar); padding: 0 8px 0 0;
  background: rgba(1, 9, 27, .58); box-shadow: none; }
.arena .stage.th-on .score > div { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 8px; min-width: 0;
  padding: 0 16px; box-shadow: none; }
.arena .stage.th-on .score .runner { flex: 0 1 auto; padding-left: 0; }
.arena .stage.th-on .score .boss { display: none; }
.arena .stage.th-on .score .th-watch { margin-left: auto; color: var(--cream); }
.arena .stage.th-on .score .runner span { display: inline-flex; }
.arena .stage.th-on .score :is(.runner b, .clock b, .beat b) { font: 24px/32px var(--px-title); }
.arena .stage.th-on .score .lbl { display: inline; color: var(--text); }
.th-onair { align-items: center; gap: 8px; align-self: stretch; padding: 0 16px; font: 16px/24px var(--px); letter-spacing: 2px;
  color: #fff; background: var(--onair); }
.arena .stage.th-on .score .runner .th-onair { color: #fff; }
.arena:not([data-join=live]):not([data-join=brb]) .stage .th-onair { display: none !important; }     /* ps-join: only while the picture moves */
.arena .stage.th-on .score .runner .th-vs { color: var(--cream); white-space: nowrap; }
.arena .stage.th-on .score .runner [data-k=try] { color: var(--teal); white-space: nowrap; }
.arena .stage.th-on .score .runner .kit { flex-wrap: nowrap; }       /* ps-build: the pips after the try, in the bar */
.arena .stage.th-on .score.idle { gap: 16px; padding: 0 8px 0 16px; }
.arena .stage.th-on .score.idle .free { flex: 0 1 auto; flex-direction: row; align-items: baseline; gap: 16px; padding: 0; }
.arena .stage.th-on .free b { font: 24px/32px var(--px-title); white-space: nowrap; }
.arena .stage.th-on .free span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.arena .stage.th-on .score.idle .first { margin: 0 0 0 auto; padding: 4px 16px; font: 16px/24px var(--px); }

/* the controls and the two calls to action ride above the bar, and fade after a few still seconds (theater.js) */
.th-on .th-ctl { bottom: calc(var(--bar) + 16px); }
.th-on .th-ui > .th-ctas { display: flex; left: 14%; bottom: calc(var(--bar) + 16px); }
.th-ui :is(.th-ctl > *, .th-ctas) { transition: opacity .3s ease; }
.th-on.th-idle { cursor: none; }
.th-on.th-idle .th-ctas, .th-on.th-idle .th-ctl > :not(.snd), .th-on.th-idle:not(.th-muted) .snd { opacity: 0; pointer-events: none; }

/* a letterbox with room under the picture (a 16:10 window, a phone held upright): the bar goes under it, solid */
@container stage ((max-aspect-ratio: 8/5) and (min-width: 768px)) or (max-aspect-ratio: 4/3) {
  .arena .stage.th-on .screen { top: calc((100cqh - var(--ph) - var(--bar)) / 2); }
  .arena .stage.th-on .score { top: calc((100cqh - var(--ph) - var(--bar)) / 2 + var(--ph)); left: var(--pl); width: var(--pw);
    background: var(--night-1); }
  .th-on .th-ctl, .th-on .th-ctas { bottom: 16px; }
}
/* a small picture (a phone on its side): the bar keeps the numbers, drops the words around them */
@container stage (max-width: 1000px) {
  .arena .stage.th-on .score > div { padding: 0 8px; }
  .arena .stage.th-on .score :is(.runner b, .clock b, .beat b, .free b) { font: 16px/24px var(--px-title); }
  .arena .stage.th-on .score :is(.clock .lbl, .th-watch, .free span, .runner [data-k=try]) { display: none; }
  .arena .stage.th-on .score { background: rgba(1, 9, 27, .78); }
  .arena .stage.th-on .score .runner b { flex: 0 1 auto; min-width: 48px; }
  .th-onair { padding: 0 8px; letter-spacing: 0; }
  .th-ui > div { gap: 8px; }
  .th-ui button, .th-ui a.button { padding: 4px 12px; }
  .th-on .th-ctl { right: 8px; }
  .th-on .th-ui > .th-ctas { left: 8px; }         /* above the health corner, which sits lower */
}

/* a phone held upright (ps-site-polish, Nov 26): the bar is 390 px wide, and the name, "vs Thornheart", the clock and
   the time to beat ran into each other ("Sta rr..." under the clock's digits). The bar keeps LIVE, the name on one
   line and the clock; the time to beat is on the strip one tap away. The buttons were wider than the picture (the
   first lost its first letters off the left edge): in theater Full screen waits on the page's own stage, where a phone
   turned on its side fills the screen by itself, and in full screen Theater goes instead, so the way out is always
   there. Be next and Share sit on their own row above the others, never on top of them. */
@container stage (max-width: 560px) {
  .arena .stage.th-on .score :is(.runner .th-vs, .beat) { display: none; }      /* (over .runner span's inline-flex) */
  /* the build (ps-build): no room in the bar, so its pips hang just under it, in the letterbox, between the Mosscaps */
  .arena .stage.th-on .score .runner .kit { position: absolute; top: calc(100% + 12px); left: 50%; transform: translateX(-50%); }
  .arena .stage.th-on .score .runner { flex: 1 1 auto; min-width: 0; }
  .arena .stage.th-on .score .runner b { display: block; flex: 0 1 auto; min-width: 0; white-space: nowrap; text-overflow: ellipsis; }
  .arena .stage.th-on:not(.th-fs) .th-full, .arena .stage.th-fs .th-theater { display: none; }
  .th-on .th-ui > .th-ctas { left: auto; right: 8px; bottom: 64px; }
}

/* Phone upright, item 1 of the Nov 28 guest-page pass: the picture sits at the top of the stage with nothing above it,
   and everything that sat on it (the caption, the sound control, Fullscreen; in theater Be next, Share, Exit theater) goes
   in rows under it. REPLAY, LIVE and the watching count stay on the picture as small tags. --rowtop is where the
   first row of buttons starts under the picture, --caph the room the replay's caption takes above it. */
@media (max-width: 560px) {      /* (a container cannot style itself: these are the stage's own, so the window's width stands in) */
  .arena .stage { --caph: 0px; --rowtop: 8px; }
  /* Nov 28, Aaron on his phone: "some margins to make that look better under the thornheart thing": 16 px above the
     caption, its three lines, 16 px before the buttons, and 16 px in from the sides like the page's own text */
  .arena[data-mode=reel] .stage { --caph: 104px; --rowtop: 0px; }
  /* the stage is one height in every face (nothing under it moves when a run starts or ends): reel and loop keep the room for
     the caption and the idle strip is shorter; live has the taller strip and less room under the picture */
  .arena .stage:not(.th-on) .screen { margin-bottom: 168px; }
  .arena[data-mode=live] .stage:not(.th-on) .screen { margin-bottom: 84px; }
  .arena .stage.th-on { --bar: 80px; }
}
@container stage (max-width: 560px) {
  .arena .stage:not(.th-on) .screen { overflow: visible; }
  .arena .stage:not(.th-on) .screen .cap { top: 100%; bottom: auto; left: 0; right: 0; height: var(--caph); padding: 16px 16px 16px; box-sizing: border-box;
    background: none; font-size: 16px; line-height: 24px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; }
  .arena .stage:not(.th-on) .screen .cap:empty { display: none; }
  .arena .stage:not(.th-on) .screen button.rplay { top: calc(100% + var(--caph) + var(--rowtop)); left: 16px; right: auto; min-height: 44px; }
  .arena .stage:not(.th-on) .th-ctl { top: calc(100% + var(--caph) + var(--rowtop)); bottom: auto; left: 16px; right: 16px; justify-content: flex-end; }
  .arena .stage:not(.th-on) .th-ctl button { min-height: 44px; }
  .arena .stage:not(.th-on) .th-ctl .snd { margin-right: auto; }
  /* /live: the picture at the top of the window, the bar under it, the rows under the bar */
  .arena .stage.th-on .screen { top: 0; overflow: visible; }
  .arena .stage.th-on .cap { top: 100%; bottom: auto; left: 0; right: 0; transform: none; width: auto; max-width: none; text-align: left; height: var(--caph); padding: 16px 16px 16px; box-sizing: border-box; background: none;
    font-size: 16px; line-height: 24px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
  .arena .stage.th-on .cap:empty { display: none; }
  .arena .stage.th-on .score { top: calc(var(--ph) + var(--caph)); left: 0; width: 100%; background: var(--night-1); padding: 0 8px; }
  .arena .stage.th-on .score .runner b { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
    overflow: hidden; overflow-wrap: anywhere; font: 16px/24px var(--px-title); }
  .arena .stage.th-on .score .clock b { font: 24px/32px var(--px-title); }
  .arena .stage.th-on .score.idle .first { min-height: 44px; display: inline-flex; align-items: center; }
  .th-on .th-ui > .th-ctas { left: 16px; right: auto; top: calc(100% + var(--caph) + var(--bar) + 16px); bottom: auto; }
  .th-on .th-ui > .th-ctl { left: 16px; right: 16px; top: calc(100% + var(--caph) + var(--bar) + 76px); bottom: auto; justify-content: flex-start; }
  .th-on .th-ui button, .th-on .th-ui a.button { min-height: 44px; display: inline-flex; align-items: center; }
  .th-on.th-idle .th-ctas, .th-on.th-idle .th-ctl > :not(.snd), .th-on.th-idle:not(.th-muted) .snd { opacity: 1; pointer-events: auto; }
}

/* /live on a phone (Nov 29 review): the theater stage fills the window, so under its rows there was a black screenful and the
   page under it could not be reached. Upright on a phone it takes only the height of its picture and rows, in the page's own
   flow, and the page scrolls: the Be next card and the footer follow it. (Not when the visitor pressed Theater on the home
   page, where the stage is the placeholder's twin and stays a full-window overlay.) */
@media (max-width: 560px) {
  .arena .stage.th-on:not(.th-fs):not(.th-ph + *) { position: relative; inset: auto; z-index: auto; width: 100%;
    height: calc(100vw * 9 / 16 + var(--caph) + 216px); }
  html.th-lock:has(.arena .stage.th-on:not(.th-fs):not(.th-ph + *)),
  html.th-lock:has(.arena .stage.th-on:not(.th-fs):not(.th-ph + *)) body { overflow: visible; }
}

/* a big screen (1440p, a TV): the bar and the buttons one step bigger, still on the 8 px grid */
@container stage (min-width: 2000px) {
  .arena .stage.th-on :is(.screen, .score) { --bar: 64px; }     /* (a container query styles what is inside the stage) */
  .arena .stage.th-on .score :is(.runner b, .clock b, .beat b, .free b) { font: 32px/40px var(--px-title); }
  .arena .stage.th-on .score :is(.lbl, .th-vs, [data-k=try], .th-watch, .free span) { font-size: 24px; line-height: 32px; }
  .th-onair { font-size: 24px; line-height: 32px; padding: 0 24px; }
  .th-onair .dot { width: 16px; height: 16px; }
  .th-ui > div { gap: 24px; }
  .th-ui button, .th-ui a.button { padding: 8px 24px; font-size: 24px; line-height: 32px; }
  .th-ui .snd { height: 48px; }
  .th-ui .snd button { padding: 0 16px; }
  .th-on .th-ctl { right: 24px; }
  .arena .stage.th-on .score.idle .first { padding: 8px 24px; font-size: 24px; line-height: 32px; }
}

/* Sharpness: the feed is 1280 x 720. Scaled up (a stage wider than that), crisp pixels read as the game's own pixel
   art; at or under 720p the browser's own smoothing (crisp pixels only help when each one gets bigger). */
@container stage (min-width: 1281px) { .stage video { image-rendering: pixelated; } }
@container stage (max-width: 1280px) { .stage #live .lv-video { image-rendering: auto; } }

@media (prefers-reduced-motion: reduce) { .th-ui :is(.th-ctl > *, .th-ctas) { transition: none; } }

/* ps-viewers, Nov 28 (Aaron: "how many viewers both as audience but even more as the live person"): "12 watching" rides
   the picture's top left corner at every size, which the game keeps free (its boss bar is top centre, the minimap top
   right). It was at the bar's right end, over the game's ability mark, and dropped in any stage up to 1500 wide (most
   laptops, every phone). The stage holds it (a size container is the box a fixed child is placed in). Under 2 it stays
   hidden (arena.js). Kept last: the same weight as the phone rule above that hid it, so this one wins. */
.arena .stage.th-on .score .th-watch:not(:empty) { display: block; position: fixed; z-index: 4; left: calc(var(--pl) + 16px);
  top: calc(var(--pt) + 16px); margin: 0; padding: 0; pointer-events: none; }
.arena .stage.th-on .score .th-watch [data-k=viewers] { display: block; padding: 4px 12px; font: 16px/24px var(--px); letter-spacing: 0;
  color: var(--cream); background: rgba(1, 9, 27, .82); white-space: nowrap; }
@container stage (min-width: 2000px) {
  .arena .stage.th-on .score .th-watch:not(:empty) { left: calc(var(--pl) + 24px); top: calc(var(--pt) + 24px); }
  .arena .stage.th-on .score .th-watch [data-k=viewers] { padding: 4px 16px; font-size: 24px; line-height: 32px; }
}
@container stage (max-width: 1000px) {
  .arena .stage.th-on .score .th-watch:not(:empty) { left: calc(var(--pl) + 8px); top: calc(var(--pt) + 8px); }
  .arena .stage.th-on .score .th-watch [data-k=viewers] { padding: 0 8px; }
}
/* player-record: "4th turn, 11 tries in all" after the try; it gives way first (before the name), and a small picture's bar
   drops it with the other words (below) */
.arena .stage.th-on .score .runner [data-k=rec] { display: inline-block; flex: 0 100 auto; min-width: 0; margin-left: 8px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
@container stage (max-width: 1000px) { .arena .stage.th-on .score .runner [data-k=rec] { display: none; } }
/* site-polish, Nov 29: a phone upright (a stage up to 560 wide) has the picture at the top of the window and the bar under it,
   so the corner above (--pt) is not where the picture is, and the game's boss bar takes most of a small picture's top: the
   count sat on the Share row. It goes in the bar, under the race clock and right-aligned with it; the clock steps up for it. */
@container stage (max-width: 560px) {
  .arena .stage.th-on .score .th-watch:not(:empty) { position: absolute; left: auto; top: auto; right: 16px; bottom: 8px; }
  .arena .stage.th-on .score .th-watch [data-k=viewers] { padding: 0; background: none; text-align: right; }
  .arena .stage.th-on .score:has(.th-watch [data-k=viewers]:not([hidden])) .clock { align-self: flex-start; padding-top: 12px; }
}
.arena .stage .score .th-watch [data-k=viewers][hidden] { display: none; }      /* under 2: nothing, not an empty tag */
