/* The AI page is the TV commercials control room (options/a.css) with live monitors:
   every source is a shot from one of the films, and the program feed plays the films. */
:root {
  --bg: #08080a;
  --panel: #131316;
  --ink: #f2efe8;
  --mute: #8f8c85;
  --red: #e0202c;    /* on air */
  --green: #12b35b;  /* next up */
  --gap: 3px;
  --umd: 30px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  /* Four 16:9 tiles across, four rows down, each row carrying its label strip. */
  --tile: min(calc((100vw - 5 * var(--gap)) / 4), calc((100vh - 5 * var(--gap) - 4 * var(--umd)) / 4 * 16 / 9));
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font: 600 15px/1 "Barlow Condensed", "Arial Narrow", sans-serif; letter-spacing: 0.03em; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img, video, canvas, iframe { display: block; }
:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* ---- The wall: a 4x4 multiviewer with the program feed taking 2x2 ---------------- */
.wall {
  --h: calc(var(--tile) * 9 / 16 + var(--umd));
  display: grid;
  grid-template-columns: repeat(4, var(--tile));
  grid-template-rows: repeat(4, var(--h));
  grid-auto-rows: var(--h);  /* more than eleven films: the wall grows rows below */
  gap: var(--gap);
  width: max-content;
  min-height: 100vh;
  align-content: center;
  margin: 0 auto;
  padding: var(--gap);
}

/* ---- Program monitor ------------------------------------------------------------ */
.pgm { grid-column: 2 / 4; grid-row: 1 / 3; display: flex; flex-direction: column; min-width: 0; outline: 3px solid var(--red); outline-offset: -3px; position: relative; z-index: 2; background: #000; }
.pgm__screen { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.pgm__still, .pgm__video, .pgm__resolve, .pgm__player, .pgm__player iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.pgm__video { opacity: 0; }
.pgm__video.is-on { opacity: 1; }
.pgm__resolve { opacity: 0; image-rendering: pixelated; pointer-events: none; transition: opacity 180ms ease-out; }
.pgm__resolve.is-on { opacity: 1; transition: none; }
.pgm__player { background: #000; z-index: 1; }
.pgm__take { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 12px; height: 44px; padding: 0 14px 0 7px; background: var(--red); color: #fff; }
.pgm__name { font-size: 25px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pgm__meta { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.86; font-variant-numeric: tabular-nums; }
.pgm__enter { font-size: 16px; font-weight: 600; white-space: nowrap; padding: 8px 0; }
.pgm__enter span { display: inline-block; transition: transform 200ms var(--ease); }
@media (hover: hover) { .pgm__enter:hover span { transform: translateX(4px); } }
.tally { display: inline-block; padding: 4px 6px 3px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; line-height: 1; }
.tally--pgm { background: #fff; color: var(--red); }
.is-watching .tally--pgm { animation: rec 1.6s steps(1) infinite; }
@keyframes rec { 50% { background: transparent; color: #fff; } }

/* ---- Source monitors: one shot each, playing live -------------------------------- */
.src { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.src__screen { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #000; }
.src__screen video, .src__screen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.src__screen video { transform: scale(var(--fill, 1)); }
.src__umd { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: var(--umd); padding: 0 8px; background: var(--panel); text-transform: uppercase; font-size: 17px; white-space: nowrap; }
.src__umd > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.src__key { color: var(--mute); font-size: 14px; font-weight: 500; }
.src::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 0 transparent; transition: box-shadow 90ms linear; }
.src.is-pvw::after { box-shadow: inset 0 0 0 3px var(--green); }
.src.is-pvw .src__umd { background: var(--green); color: #fff; }
.src.is-pgm::after { box-shadow: inset 0 0 0 3px var(--red); }
.src.is-pgm .src__umd { background: var(--red); color: #fff; }
.src.is-pvw .src__key, .src.is-pgm .src__key { color: #fff; }

/* ---- Ident tile, top left: the AI icon beside the title ------------------------------ */
.ident { position: relative; display: flex; flex-direction: column; justify-content: flex-start; gap: 10px; padding: clamp(14px, 1.6vw, 24px) clamp(14px, 1.7vw, 26px) 0; background: #000; min-width: 0; }
.ident p { margin: 0; }
.ident__head { display: flex; align-items: center; gap: clamp(10px, 1vw, 16px); }
.ident__icon { --icon: clamp(52px, min(5.4vw, 7.4vh), 84px); width: var(--icon); height: var(--icon); object-fit: cover; border-radius: 3px; }
.ident h1 { margin: 0; font-size: clamp(54px, min(6vw, 8.2vh), 96px); font-weight: 700; line-height: 0.8; letter-spacing: 0.01em; padding-top: 0.06em; }
.ident__sub { color: var(--mute); font-size: 17px; font-weight: 500; line-height: 1.15; }
.ident__tc { position: absolute; right: 8px; bottom: 8px; color: var(--mute); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ident__back { position: absolute; left: clamp(14px, 1.7vw, 26px); bottom: 8px; color: var(--mute); font-size: 15px; font-weight: 500; transition: color 150ms linear; }
.ident__back span { display: inline-block; transition: transform 200ms var(--ease); }
@media (hover: hover) {
  .ident__back:hover { color: var(--ink); }
  .ident__back:hover span { transform: translateX(-3px); }
}

/* The logo sits above the big AI title, so the line under it goes on short screens. */
@media (max-height: 880px) { .ident__sub { display: none; } }

/* ---- Small screens: the program feed pins to the top, monitors run two across ------ */
@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  :root { --tile: calc((100vw - 3 * var(--gap)) / 2); }
  html, body { height: auto; }
  .wall { grid-template-columns: repeat(2, var(--tile)); grid-template-rows: none; grid-auto-rows: auto; align-content: start; }
  .pgm { grid-column: 1 / -1; grid-row: auto; position: sticky; top: 0; z-index: 5; }
  .pgm__screen { flex: none; aspect-ratio: 16 / 9; }
  .pgm__meta { display: none; }
  .pgm__take { grid-template-columns: auto 1fr auto; }
  .pgm__name { font-size: 21px; }
  .src__screen { flex: none; aspect-ratio: 16 / 9; }
  .ident { grid-column: 1 / -1; order: -1; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; }
  .ident__icon { --icon: 44px; }
  .src:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .ident h1 { font-size: 48px; }
  .ident__sub, .ident__tc, .ident__back, .src__key { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .is-watching .tally--pgm { animation: none; }
}
