/* Airtime HUD — the pieces the game keeps as page elements
 *
 * The drawn HUD is airtime-hud.js. This file styles what sits beside it in the page:
 * centre messages (#center, the live page's own element), and the chat / event log, the scoreboard,
 * the bar while watching a ghost and the slow motion label. Those four are built by game scripts
 * that are not in the kit, so their class names here ("ah-…") are mine: map them to the real ones.
 *
 * Load after airtime-menu.css: it uses that file's tokens (--fg, --accent, --display, --mono …).
 * Two values come from the canvas HUD every frame, so the page pieces follow its scale and never
 * sit on top of it:  --ah-u  (1 = 1080p),  --ah-log  (how far the log sits above the bottom),
 * --ah-bc  (the same for the playback bar, above the pieces stacked at the bottom centre),
 * --ah-tl  (where the top left corner's stack ends, for the rewind label)  and
 * --ah-tc  (the same at the top centre, for the centre messages).
 */

:root { --ah-u: 1; --ah-log: 22px; --ah-bc: 60px; --ah-tl: 22px; --ah-tc: 22px; }      /* overwritten every frame from hud.draw()'s return value */
#hud { --ah-m: max(12px, calc(22px * var(--ah-u))); --ah-glass: rgba(5, 8, 11, .7); --ah-glass-2: rgba(5, 8, 11, .86); text-shadow: none; }
#hud2d, #cross { image-rendering: auto; }

/* ───────── centre messages: one or two lines, any text ───────── */
#center {
  position: absolute; left: 50%; top: max(26%, calc(var(--ah-tc) + 18px * var(--ah-u))); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .32em;
  width: max-content; max-width: min(92vw, 46em); padding: .52em 2.2em .56em;
  font: 600 calc(31px * var(--ah-u)) / 1.05 var(--display); letter-spacing: .14em; text-indent: .14em; text-transform: uppercase; text-align: center;
  color: var(--fg); text-shadow: none;
  background: linear-gradient(90deg, rgba(5, 8, 11, 0), rgba(5, 8, 11, .66) 20%, rgba(5, 8, 11, .66) 80%, rgba(5, 8, 11, 0));
}
#center:empty { display: none; }
#center::before, #center::after { content: ""; position: absolute; left: 10%; right: 10%; height: 1px; background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .36) 22%, rgba(255, 255, 255, .36) 78%, rgba(255, 255, 255, 0)); }
#center::before { top: 0; }
#center::after { bottom: 0; }
#center small { font: 500 calc(11px * var(--ah-u)) / 1 var(--mono); letter-spacing: .28em; text-indent: .28em; color: var(--soft); }
#center b { font-weight: 600; font-variant-numeric: tabular-nums; }
#center i { font: 500 calc(15px * var(--ah-u)) / 1 var(--display); font-style: normal; letter-spacing: .16em; text-indent: .16em; color: var(--soft); }
#center.ah-best b, #center.ah-best small { color: var(--accent); }
#center.ah-best::before { background: linear-gradient(90deg, rgba(215, 255, 63, 0), var(--accent) 30%, var(--accent) 70%, rgba(215, 255, 63, 0)); }
#center.ah-in { animation: ah-msg-in .46s cubic-bezier(.16, 1, .3, 1) both; }
#center.ah-out { animation: ah-msg-out .4s ease-in both; }
@keyframes ah-msg-in { from { opacity: 0; transform: translateX(-50%) translateY(.5em); letter-spacing: .3em; } to { opacity: 1; transform: translateX(-50%); letter-spacing: .14em; } }
@keyframes ah-msg-out { to { opacity: 0; transform: translateX(-50%) translateY(-.3em); } }

/* ───────── chat / event log, bottom left, above whatever the canvas HUD has in that corner ───────── */
.ah-log { position: absolute; left: var(--ah-m); bottom: var(--ah-log); display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: min(44em, calc(100% - 2 * var(--ah-m) - 232px * var(--ah-u))); font: 500 calc(14px * var(--ah-u)) / 1.25 var(--body); color: var(--fg); transition: bottom .25s cubic-bezier(.16, 1, .3, 1); }
.ah-line { position: relative; padding: .34em .8em .36em .95em; background: var(--ah-glass); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); animation: ah-line-in .32s cubic-bezier(.16, 1, .3, 1) both; transition: opacity 1.4s linear; overflow-wrap: anywhere; }
.ah-line::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, .34); }
.ah-line.ah-own::before { background: var(--accent); }
.ah-line.ah-old { opacity: .42; }
.ah-line b { font-weight: 600; }
.ah-line em { font: 600 1.12em/1 var(--display); font-style: normal; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.ah-line em.ah-ok { color: var(--ok); }
.ah-line em.ah-bad { color: var(--danger); }
.ah-line i { font: 500 .72em/1 var(--mono); font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); }
.ah-way { display: inline-flex; align-items: center; gap: .42em; font: 600 1.04em/1 var(--display); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; color: var(--c, var(--fg)); }
.ah-way::before { content: ""; width: .5em; height: .5em; background: currentColor; transform: rotate(45deg); }
@keyframes ah-line-in { from { opacity: 0; transform: translateX(-.9em); } to { opacity: 1; transform: none; } }

/* ───────── scoreboard (hold Tab) ───────── */
.ah-score { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(46em, calc(100% - 2 * var(--ah-m))); max-height: calc(100% - 6em); overflow: hidden; font: 500 calc(15px * var(--ah-u)) / 1.2 var(--body); color: var(--fg); background: rgba(5, 8, 11, .84); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 1.6em 4em rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); animation: ah-score-in .22s cubic-bezier(.16, 1, .3, 1) both; }
.ah-score::before { content: ""; position: absolute; left: 0; top: 0; width: 3px; height: 4.3em; background: var(--accent); }
.ah-score header { display: flex; align-items: flex-end; gap: 1.4em; padding: 1em 1.4em .9em 1.5em; border-bottom: 1px solid rgba(255, 255, 255, .13); }
.ah-score header div { flex: 1; min-width: 0; }
.ah-score header small { display: block; margin-bottom: .5em; font: 500 .68em/1 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--soft); }
.ah-score header b { display: block; font: 600 2em/1 var(--display); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ah-score header span { font: 500 .7em/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; color: var(--soft); }
.ah-score table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.ah-score th { padding: .7em .6em .55em; font: 500 .66em/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; text-align: left; color: var(--dim); }
.ah-score td { padding: .44em .6em .46em; border-top: 1px solid rgba(255, 255, 255, .07); white-space: nowrap; }
/* both tables (players, ghosts) take their column widths from the same <col>s, so their columns line up */
.ah-score .ah-c-rk { width: 4em; }
.ah-score .ah-c-way { width: 7.4em; }
.ah-score .ah-c-run { width: 5em; }
.ah-score .ah-c-best { width: 7.4em; }
.ah-score .ah-c-ping { width: 5em; }
.ah-score th:first-child, .ah-score td:first-child { padding-left: 1.5em; }
.ah-score th:nth-child(2), .ah-score td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
.ah-score th:nth-child(n + 4), .ah-score td:nth-child(n + 4) { text-align: right; }
.ah-score th:last-child, .ah-score td:last-child { padding-right: 1.4em; }
.ah-score .ah-rk { font: 500 .78em/1 var(--mono); color: var(--dim); }
.ah-score .ah-nm { font: 600 1.14em/1 var(--display); letter-spacing: .08em; text-transform: uppercase; }
.ah-score .ah-nm i { display: inline-block; width: .5em; height: .5em; margin-right: .6em; vertical-align: .08em; }
.ah-score .ah-nm em { margin-left: .7em; padding: .14em .5em .12em; font: 500 .6em/1 var(--mono); font-style: normal; letter-spacing: .16em; color: var(--accent); box-shadow: inset 0 0 0 1px rgba(215, 255, 63, .5); vertical-align: .14em; }
.ah-score .ah-tm { font: 600 1.14em/1 var(--display); letter-spacing: .04em; }
.ah-score .ah-bst { color: var(--soft); }
.ah-score .ah-pg { font: 500 .82em/1 var(--mono); color: var(--soft); }
.ah-score tr.ah-you td { background: rgba(215, 255, 63, .09); }
.ah-score tr.ah-you .ah-nm { color: var(--accent); }
.ah-score h4 { display: flex; align-items: baseline; gap: 1em; margin: 0; padding: 1em 1.4em .5em 1.5em; border-top: 1px solid rgba(255, 255, 255, .13); font: 600 1em/1 var(--display); letter-spacing: .16em; text-transform: uppercase; }
.ah-score h4 span { font: 500 .66em/1 var(--mono); letter-spacing: .16em; color: var(--dim); }
.ah-score footer { padding: .7em 1.4em .8em 1.5em; border-top: 1px solid rgba(255, 255, 255, .13); font: 500 .68em/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--dim); }
.ah-score kbd, .ah-playbar kbd { display: inline-block; min-width: 1.5em; margin-right: .5em; padding: .28em .5em .24em; font: 600 1.1em/1 var(--display); letter-spacing: .08em; text-align: center; color: var(--fg); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
@keyframes ah-score-in { from { opacity: 0; transform: translate(-50%, -48.5%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* ───────── watching a ghost: who, at the top; playback, at the bottom ───────── */
.ah-watch { position: absolute; left: 50%; top: var(--ah-m); transform: translateX(-50%); display: flex; align-items: center; gap: .9em; height: 2.3em; padding: 0 1.1em; font: 500 calc(14px * var(--ah-u)) / 1 var(--body); white-space: nowrap; color: var(--fg); background: var(--ah-glass-2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .13); }
.ah-watch::before { content: ""; width: .5em; height: .5em; background: var(--danger); border-radius: 50%; animation: ah-blink 1.4s steps(1) infinite; }
.ah-watch small { font: 500 .72em/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--soft); }
.ah-watch b { font: 600 1.2em/1 var(--display); letter-spacing: .1em; text-transform: uppercase; }
.ah-watch b i { display: inline-block; width: .46em; height: .46em; margin-right: .5em; vertical-align: .1em; }
.ah-watch > span { display: inline-flex; align-items: center; gap: .6em; font: 500 .96em/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--soft); }
.ah-playbar { position: absolute; left: 50%; bottom: calc(var(--ah-bc) + 6px * var(--ah-u)); transform: translateX(-50%); box-sizing: border-box; display: flex; align-items: center; gap: 1em; width: min(64em, calc(100% - 2 * var(--ah-m))); height: 2.5em; padding: 0 1.1em; font: 500 calc(13px * var(--ah-u)) / 1 var(--mono); letter-spacing: .08em; white-space: nowrap; color: var(--fg); background: var(--ah-glass-2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .13); }
.ah-pb-state { width: 1.2em; color: var(--accent); }
.ah-pb-time { font-variant-numeric: tabular-nums; }
.ah-pb-track { position: relative; flex: 1 1 10em; min-width: 6em; height: 4px; background: rgba(255, 255, 255, .14); }
.ah-pb-track i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--fg); }
.ah-pb-track i::after { content: ""; position: absolute; right: -1px; top: -4px; bottom: -4px; width: 2px; background: var(--accent); }
.ah-pb-rate { color: var(--soft); }
.ah-pb-keys { flex: 0 1 auto; min-width: 0; overflow: hidden; font-size: .78em; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.ah-pb-keys kbd { margin: 0 .3em 0 .9em; }
@keyframes ah-blink { 50% { opacity: .25; } }

/* ───────── hold-to-rewind's label (the live page's #vcr): below the top left corner's stack, not on it ───────── */
#vcr { left: var(--ah-m); top: calc(var(--ah-tl) + 14px * var(--ah-u)); font-size: clamp(22px, calc(40px * var(--ah-u)), 54px); }

/* ───────── slow motion ───────── */
.ah-slowmo { position: absolute; left: 50%; top: calc(var(--ah-m) + 46px * var(--ah-u)); transform: translateX(-50%); display: flex; align-items: baseline; gap: .8em; padding: .5em 1em .46em; background: var(--ah-glass-2); box-shadow: inset 0 0 0 1px rgba(255, 178, 36, .5); color: var(--warn); white-space: nowrap; }
.ah-slowmo small { font: 500 calc(10px * var(--ah-u)) / 1 var(--mono); letter-spacing: .24em; text-transform: uppercase; }
.ah-slowmo b { font: 600 calc(20px * var(--ah-u)) / 1 var(--display); letter-spacing: .06em; font-variant-numeric: tabular-nums; }

/* the menu's "bring the menu back" button (see-through mode) moves up, clear of the HUD's bottom centre */
.ax-peek-exit { bottom: calc(var(--ah-bc) + 14px + env(safe-area-inset-bottom, 0px)); }

/* ───────── small screens ───────── */
@media (max-width: 1100px) { .ah-pb-keys { display: none; } }
@media (max-width: 760px) {
  #center { top: max(22%, calc(var(--ah-tc) + 14px)); padding-left: 1.2em; padding-right: 1.2em; }
  .ah-log { font-size: 12px; }
  .ah-pb-keys { display: none; }
  .ah-score { font-size: 13px; }
  .ah-score header span:first-of-type { display: none; }
  .ah-score .ah-c-rk { width: 2.9em; }
  .ah-score .ah-c-way { width: 5.2em; }
  .ah-score .ah-c-run { width: 3.4em; }
  .ah-score .ah-c-best { width: 5.4em; }
  .ah-score .ah-c-ping { width: 3.2em; }
  .ah-score th:first-child, .ah-score td:first-child { padding-left: 1em; }
  .ah-score th, .ah-score td { padding-left: .3em; padding-right: .3em; }
  .ah-score th:last-child, .ah-score td:last-child { padding-right: 1em; }
  .ah-score header { padding-left: 1em; padding-right: 1em; }
  .ah-score h4, .ah-score footer { padding-left: 1em; padding-right: 1em; }
}
@media (prefers-reduced-motion: reduce) {
  #center.ah-in, #center.ah-out, .ah-line, .ah-score, .ah-watch::before { animation-duration: .01s; }
}
