/* The Control Room wall (options/a.css), as on the Singers page, for the showcase pages: Corporate,
   Documentaries, Drone, Motion Graphics, TV Films & Series, Events and Post-Production. */

/* 6x4 with the program feed taking the middle 2x2: twenty cells, for the ident (its emblem
   inside it) and nineteen monitors. */
@media (min-width: 821px) and (min-aspect-ratio: 1/1) {
  :root {
    --tile: min(calc((100vw - 7 * var(--gap)) / 6), calc((100vh - 5 * var(--gap) - 4 * var(--umd)) / 4 * 16 / 9));
    /* Six across leaves height to spare on a laptop: monitors grow as far as 4:3 to use it. */
    --row: max(calc(var(--tile) * 9 / 16 + var(--umd)), min(calc(var(--tile) * 3 / 4 + var(--umd)), calc((100vh - 5 * var(--gap)) / 4)));
  }
  .wall { --h: var(--row); grid-template-columns: repeat(6, var(--tile)); }
  .pgm { grid-column: 3 / 5; grid-row: 2 / 4; }
}

/* Up to eleven films: a 4x4 wall, eleven monitors. Twelve to fifteen: 5x4, fifteen. From
   sixteen, the 6x4 above, nineteen. As on the Singers page, the ident (its emblem inside it) takes the
   top-left and the program feed sits in the middle rows. */
@media (min-width: 821px) and (min-aspect-ratio: 1/1) {
  .wall--4 {
    --tile: min(calc((100vw - 5 * var(--gap)) / 4), calc((100vh - 5 * var(--gap) - 4 * var(--umd)) / 4 * 16 / 9));
    --h: calc(var(--tile) * 9 / 16 + var(--umd));
    grid-template-columns: repeat(4, var(--tile));
  }
  .wall--4 .pgm { grid-column: 2 / 4; grid-row: 2 / 4; }
  .wall--5 {
    --tile: min(calc((100vw - 6 * var(--gap)) / 5), calc((100vh - 5 * var(--gap) - 4 * var(--umd)) / 4 * 16 / 9));
    --h: max(calc(var(--tile) * 9 / 16 + var(--umd)), min(calc(var(--tile) * 3 / 4 + var(--umd)), calc((100vh - 5 * var(--gap)) / 4)));
    grid-template-columns: repeat(5, var(--tile));
  }
  .wall--5 .pgm { grid-column: 3 / 5; grid-row: 2 / 4; }
}

/* ---- Emblem: the section's 3D object or animation, small, in the ident's top-right corner --
   The ident is a two-column grid: logo, title and line on the left at their own width, the
   emblem in whatever is left on the right, capped so it stays a corner piece. That frees its old
   cell for one more monitor. */
.ident { display: grid; grid-template-columns: max-content minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; align-content: stretch; column-gap: 12px; padding-right: clamp(10px, 1.2vw, 18px); }
.ident > :not(.emblem) { grid-column: 1; }
.ident > .ident__tc, .ident > .ident__back { grid-column: auto; }
.emblem { --emblem: clamp(64px, 10vw, 170px); grid-column: 2; grid-row: 1 / -1; justify-self: end; align-self: start; position: relative; width: min(100%, var(--emblem)); height: min(var(--emblem), 100% - 30px); min-height: 0; }
.emblem canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 500ms var(--ease); }
.emblem canvas.is-ready { opacity: 1; }
/* An animated picture in place of a 3D object: whole, centred, on the same black. */
.ident .emblem img { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; object-fit: contain; }

/* The whole program monitor is the link, not just its strip. */
.pgm__take::after { content: ""; position: absolute; inset: 0; z-index: 2; }

/* ---- Source monitors: name on the left, the film on the right -------------------- */
.src__umd > :first-child { flex: none; }
.src__key { min-width: 0; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: 0.02em; }

/* ---- Ident ------------------------------------------------------------------------ */
.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); }
}

/* ---- A film on air: the program monitor, at full size ----------------------------- */
.air { width: min(calc(100vw - 32px), calc((100vh - 76px) * 16 / 9)); max-width: none; max-height: none; margin: auto; padding: 0; border: 0; outline: 3px solid var(--red); outline-offset: -3px; background: #000; color: #fff; overflow: hidden; }
.air::backdrop { background: rgba(8, 8, 10, 0.88); }
.air[open] { animation: air-in 260ms var(--ease); }
.air[open]::backdrop { animation: air-fade 200ms linear; }
@keyframes air-in { from { opacity: 0; transform: scale(0.94); } }
@keyframes air-fade { from { opacity: 0; } }
.air__screen { aspect-ratio: 16 / 9; background: #000; }
.air__screen iframe { display: block; width: 100%; height: 100%; border: 0; }
.air__take { display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 12px; height: 44px; padding: 0 7px; background: var(--red); }
.air__out { font-size: 16px; white-space: nowrap; }
.air__close { width: 32px; height: 32px; padding: 0; border: 0; background: none; color: #fff; font: 600 24px/1 "Barlow Condensed", "Arial Narrow", sans-serif; cursor: pointer; }
@media (hover: hover) { .air__close:hover { background: rgba(0, 0, 0, 0.22); } }

@media (prefers-reduced-motion: reduce) {
  .air[open], .air[open]::backdrop { animation: none; }
}

/* Narrow walls: the strips keep the essentials. */
@media (max-width: 1180px) {
  .src__key, .pgm__brands { display: none; }
  .pgm__take { grid-template-columns: auto 1fr auto; }
  .pgm__name { overflow: hidden; text-overflow: ellipsis; }
  .ident__sub, .ident__tc { display: none; }
}
/* Small screens: the ident, emblem on its right, runs across the top row, above the pinned program feed. */
@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  .ident { grid-column: 1 / -1; order: -1; align-items: center; row-gap: 6px; padding-right: 10px; }
  .ident__back { position: static; }
  .ident > .ident__back { grid-column: 1; }
  .emblem { --emblem: 88px; height: var(--emblem); }
  .air__take .pgm__brands { display: none; }
  .air__take { grid-template-columns: auto 1fr auto auto; }
}

/* ---- Showcase films: one still per film, and the film itself on program ----------- */
/* Titles are longer than singers' names: the title gives way, the year stays. */
.src__umd > :first-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.src__umd > .src__key { flex: none; font-variant-numeric: tabular-nums; }
.pgm__still, .src__screen img { transform-origin: 50% 50%; }
.pgm__feed { position: absolute; top: 50%; left: 50%; translate: -50% -50%; border: 0; pointer-events: none; opacity: 0; transition: opacity 400ms linear; }
.pgm__feed.is-on { opacity: 1; }

/* An input with nothing on it. */
.src--off .src__screen { display: grid; place-items: center; background: repeating-linear-gradient(0deg, #0b0b0d 0 2px, #0e0e11 2px 4px); }
.src__nosig { color: #3a3a40; font-size: 15px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.src--off .src__umd { color: #4a4a50; }
@media (max-width: 820px), (max-aspect-ratio: 1/1) { .src--off { display: none; } }
