/* The Viewer interface: the category standard for streaming TV, with a broadcast-style tune-in strap.
   Direction contract: .impeccable/surfaces/src-viewer-ts.md. Served to browsers as-is. */

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/assets/fonts/onest-latin.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/assets/fonts/onest-latin-ext.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/assets/fonts/onest-cyrillic.woff2) format("woff2-variations");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/assets/fonts/onest-cyrillic-ext.woff2) format("woff2-variations");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

:root {
  color-scheme: dark;
  --black: #000;
  --charcoal-0: #0b0b0d;
  --charcoal-1: #16161a;
  --charcoal-2: #26262c;
  --ink: #f2f2f3;
  --ink-soft: #d8d8dd;
  --muted: #a6a6ae;
  --tile: #2b2b31;
  --line: rgb(255 255 255 / 0.1);
  --panel: rgb(20 20 23 / 0.9);
  --row-hover: rgb(255 255 255 / 0.07);
  --row-current: rgb(255 255 255 / 0.12);
  --button: rgb(255 255 255 / 0.14);
  --button-hover: rgb(255 255 255 / 0.22);
  /* The only red in the interface. */
  --live: #e5212b;
  --focus: #fff;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--black); color: var(--ink); }
body { font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
::selection { background: rgb(255 255 255 / 0.28); color: #fff; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button { font: inherit; color: inherit; }
* { scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 0.25) transparent; }

/* ---------- Shared pieces ---------- */

.live-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 8px; border-radius: 5px;
  background: var(--live); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; line-height: 1;
  white-space: nowrap;
}
.live-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.offline-label { color: var(--muted); font-size: 13px; white-space: nowrap; }

.tile {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 9px;
  background: var(--tile); color: var(--ink); font-size: 15px; font-weight: 700; letter-spacing: 0.02em;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.tile.has-logo { overflow: hidden; padding: 4px; }
.tile.has-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }

.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }

/* ---------- The watch page ---------- */

.screen { position: relative; width: 100vw; height: 100dvh; overflow: hidden; background: var(--black); }
.stage { position: absolute; inset: 0; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--black); }
.screen:not([data-status="live"]) video { visibility: hidden; }

.standby { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  background: radial-gradient(90% 80% at 50% 38%, var(--charcoal-2) 0%, var(--charcoal-1) 50%, var(--charcoal-0) 100%); }
.standby img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--black); }
.standby h2 { margin: 0; font-size: clamp(36px, 5vw, 64px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; }
.standby p { margin: 14px 0 0; color: var(--muted); font-size: clamp(16px, 1.6vw, 21px); text-wrap: balance; }
.standby-short { display: none; }
.screen[data-status="live"] .standby { display: none; }

.scrim { position: absolute; left: 0; right: 0; bottom: 0; height: 55%; pointer-events: none;
  background: linear-gradient(0deg, rgb(0 0 0 / 0.86) 0%, rgb(0 0 0 / 0.5) 45%, transparent 100%); }

/* The tune-in strap: the Channel's name and whether it's Live. */
.strap { position: absolute; left: max(48px, calc((100vw - 100dvh * 16 / 9) / 2 + 24px)); right: 48px; bottom: 116px; display: flex; gap: 18px; align-items: center;
  max-width: 820px; }
.strap .tile { width: 64px; height: 64px; border-radius: 12px; font-size: 20px; }
.strap > div { min-width: 0; }
.strap h1 { margin: 0; font-size: clamp(26px, 2.6vw, 36px); font-weight: 700; letter-spacing: -0.015em; line-height: 1.1;
  text-wrap: balance; }
.strap-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; color: var(--ink-soft);
  font-size: 17px; }
.strap-meta .description { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.strap .live-badge, .strap .offline-label, .strap .tuning { display: none; }
.screen[data-status="live"] .strap .live-badge { display: inline-flex; }
.screen[data-status="offline"] .strap [data-when="offline"],
.screen[data-status="suspended"] .strap [data-when="suspended"] { display: inline; font-size: 15px; }
.screen[data-status="live"]:not([data-playing]) .strap .tuning { display: inline; color: var(--muted); font-size: 15px; }

/* The control bar. */
.bar { position: absolute; left: max(32px, calc((100vw - 100dvh * 16 / 9) / 2 + 16px));
  right: max(32px, calc((100vw - 100dvh * 16 / 9) / 2 + 16px)); bottom: 28px; display: flex; align-items: center; gap: 6px; }
.bar .spacer { flex: 1; }
.control { display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border: 0;
  text-decoration: none;
  border-radius: 10px; background: transparent; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background-color 160ms var(--ease-out); }
.control:hover { background: var(--button); }
.control.labelled { padding: 0 18px 0 14px; background: var(--button); }
/* An icon-only control names itself on hover and on keyboard focus. */
.control[data-label] { position: relative; }
.control[data-label]:hover::after, .control[data-label]:focus-visible::after {
  content: attr(data-label); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  padding: 6px 10px; border-radius: 8px;
  background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 600; white-space: nowrap; pointer-events: none; }
/* A control at the right edge keeps its label inside the screen. */
.control[data-label-align="end"]::after { left: auto; right: 0; transform: none; }
/* Touch screens have no hover and usually no keyboard: the labels (with their key hints) stay out of the way. */
@media (hover: none) { .control[data-label]::after { display: none; } }
.control.labelled:hover { background: var(--button-hover); }
.control[aria-pressed="true"] .when-off, .control[aria-pressed="false"] .when-on { display: none; }
/* The silent picture's cue: shown once the controls fade, until the Viewer first turns sound on. */
.silent-cue { position: absolute; top: max(20px, calc((100dvh - 100vw * 9 / 16) / 2 + 16px));
  right: max(24px, calc((100vw - 100dvh * 16 / 9) / 2 + 16px));
  display: none; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgb(0 0 0 / 0.55); }
.silent-cue .icon { width: 20px; height: 20px; }
.screen[data-silent][data-status="live"][data-ui="hidden"] .silent-cue { display: grid; }

/* Pause shows the icon of what pressing it does: play while paused, pause while playing. */
[data-pause][data-showing="play"] .when-playing, [data-pause][data-showing="pause"] .when-paused { display: none; }

/* The volume slider, beside the sound control. */
.volume { width: 96px; height: 48px; margin: 0 6px 0 2px; accent-color: var(--ink); cursor: pointer; background: transparent; }
/* Phones set the volume with their own buttons (iPhones ignore the page's), so they get no slider. */
@media (hover: none) { .volume { display: none; } }

/* The Captions and Audio menus open upwards from their controls. */
.track-menu { position: relative; }
.track-menu[hidden], .track-menu .menu[hidden] { display: none; }
/* Depth is tonal, like the label tags: the translucent panel, no shadow. */
.track-menu .menu { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 2;
  display: grid; min-width: 168px; padding: 6px; border-radius: 10px; background: var(--panel); }
/* Each choice is a row; the current one carries a drawn check. */
.track-menu [role="menuitemradio"] { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border: 0;
  border-radius: 10px; background: transparent; color: var(--ink); font-size: 15px; font-weight: 600; text-align: left;
  white-space: nowrap; cursor: pointer; transition: background-color 160ms var(--ease-out); }
.track-menu [role="menuitemradio"]::before { content: ""; width: 18px; height: 18px; flex: none; }
.track-menu [role="menuitemradio"][aria-checked="true"]::before { background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.track-menu [role="menuitemradio"]:hover { background: var(--button); }
.track-menu [role="menuitemradio"]:focus-visible { background: var(--button); outline-offset: -2px; }
/* An open menu doesn't also show its control's name above it. */
.track-menu:has(.menu:not([hidden])) .control::after { display: none; }

/* Nothing to hear, pause or choose while a Channel is Offline or Suspended. */
.screen:not([data-status="live"]) :is([data-sound], [data-pause], .volume, .track-menu) { display: none; }

/* Controls and strap fade away while the Viewer is just watching. */
.strap, .bar, .scrim { transition: opacity 320ms var(--ease-out), transform 320ms var(--ease-out); }
.screen[data-ui="hidden"] .strap, .screen[data-ui="hidden"] .bar, .screen[data-ui="hidden"] .scrim {
  opacity: 0; pointer-events: none; }
.screen[data-ui="hidden"] .strap { transform: translateY(8px); }
/* While a Live Channel is still tuning, its strap (with "Tuning…") stays up over the scrim. */
.screen[data-status="live"]:not([data-playing])[data-ui="hidden"] .strap,
.screen[data-status="live"]:not([data-playing])[data-ui="hidden"] .scrim { opacity: 1; transform: none; }
.screen[data-ui="hidden"] { cursor: none; }
/* The controls sit under the open Channels panel. */
.screen:has(.guide[open]) .bar, .screen:has(.guide[open]) .strap { visibility: hidden; }

/* ---------- Channels: the line-up ---------- */

.guide { position: fixed; inset: 0 auto 0 0; z-index: 2; margin: 0; padding: 24px 16px 32px; width: min(440px, 100vw);
  height: 100dvh; max-height: none; border: 0; color: var(--ink); background: var(--panel);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: 16px 0 48px rgb(0 0 0 / 0.45);
  overflow-y: auto; overscroll-behavior: contain; }
.guide-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 14px; }
.guide-header h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.guide-close { height: 36px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--button); font-size: 14px;
  font-weight: 600; cursor: pointer; }
.guide-close:hover { background: var(--button-hover); }
.guide-group { margin: 14px 12px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.guide-list { list-style: none; margin: 0; padding: 0; }
.guide-list a { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 10px 12px; border-radius: 10px; text-decoration: none; transition: background-color 160ms var(--ease-out); }
.guide-list a:hover { background: var(--row-hover); }
.guide-list a:focus-visible { outline-offset: -2px; }
.guide-list [aria-current="true"] a { background: var(--row-current); }
.guide-text { display: grid; gap: 3px; min-width: 0; }
.guide-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 16px; font-weight: 600; }
.guide-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watching { flex: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.guide-description { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-list :not([data-status="live"]) .tile { color: var(--muted); }
.guide-list :not([data-status="live"]) .guide-name { color: var(--ink-soft); }
.guide-empty { margin: 0; padding: 8px 12px; color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .guide[open] { animation: guide-in 260ms var(--ease-out); }
  @keyframes guide-in { from { transform: translateX(-28px); opacity: 0.4; } }
  .screen[data-tuned] .strap { animation: strap-in 420ms var(--ease-out); }
  @keyframes strap-in { from { transform: translateY(14px); opacity: 0; } }
  .screen[data-playing] video { animation: picture-in 600ms var(--ease-out); }
  @keyframes picture-in { from { opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) {
  .strap, .bar, .scrim { transition: none; }
}

/* ---------- Phone, portrait: picture on top, the line-up beneath ---------- */

@media (max-width: 760px) and (orientation: portrait) {
  .screen { height: auto; min-height: 100dvh; overflow: visible; display: flex; flex-direction: column; }
  .stage { position: relative; inset: auto; flex: none; aspect-ratio: 16 / 9; overflow: hidden; }
  .standby h2 { font-size: 28px; }
  .standby p { margin-top: 8px; font-size: 14px; }
  .scrim { height: 60%; }
  .bar { left: 8px; right: 8px; bottom: 6px; gap: 2px; }
  .control { height: 40px; padding: 0 10px; }
  .bar [data-open-guide] { display: none; }
  /* Menus near the right edge stay on screen. */
  .track-menu .menu { left: auto; right: 0; transform: none; }
  .track-menu [role="menuitemradio"] { height: 40px; font-size: 14px; }
  .strap { position: static; padding: 16px 18px 14px; gap: 14px; border-bottom: 1px solid var(--line); max-width: none; }
  .strap .tile { width: 48px; height: 48px; font-size: 15px; border-radius: 9px; }
  .strap h1 { font-size: 22px; }
  .strap-meta { font-size: 14px; margin-top: 6px; }
  .strap-meta { flex-wrap: nowrap; }
  .strap-meta .description { min-width: 0; }
  .silent-cue { top: 10px; right: 10px; }
  .standby-long { display: none; }
  .standby-short { display: inline; }
  /* The strap stays put; only the controls over the picture fade. */
  .screen[data-ui="hidden"] .strap { opacity: 1; transform: none; pointer-events: auto; }
  .screen[data-ui="hidden"] { cursor: auto; }
  .screen:has(.guide[open]) .bar, .screen:has(.guide[open]) .strap { visibility: visible; }
  /* The Channels list is always there, beneath the picture. */
  .guide, .guide:not([open]) { display: block; position: static; inset: auto; z-index: auto; width: auto; height: auto;
    padding: 4px 6px 32px; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none;
    overflow: visible; animation: none; }
  .guide-header { display: none; }
}

/* ---------- Short screens: a phone on its side ---------- */

@media (max-height: 500px) and (orientation: landscape) {
  .strap { bottom: 68px; gap: 12px; right: 24px; }
  .strap .tile { width: 44px; height: 44px; font-size: 14px; border-radius: 9px; }
  .strap h1 { font-size: 20px; }
  .strap-meta { margin-top: 4px; font-size: 14px; }
  .bar { bottom: 10px; }
  .control { height: 40px; padding: 0 10px; font-size: 14px; }
  .control.labelled { padding: 0 14px 0 10px; }
  .scrim { height: 70%; }
  .silent-cue { top: 12px; }
}

/* ---------- Pages around the player ---------- */

.page { min-height: 100dvh; padding: 48px 24px 64px;
  background: radial-gradient(120% 60% at 50% 0%, var(--charcoal-1) 0%, var(--black) 70%); }
.page-narrow { max-width: 560px; margin: 0 auto; }
.page h1 { margin: 0 12px 10px; font-size: 32px; font-weight: 700; letter-spacing: -0.015em; }
.page .guide-page { position: static; width: auto; height: auto; padding: 0; background: none; box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none; overflow: visible; }

.notice { display: grid; place-items: center; min-height: 100dvh; padding: 24px; text-align: center;
  background: radial-gradient(90% 80% at 50% 38%, var(--charcoal-2) 0%, var(--charcoal-1) 50%, var(--charcoal-0) 100%); }
.notice h1 { margin: 0; font-size: clamp(32px, 5vw, 56px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; }
.notice p { margin: 14px 0 0; color: var(--muted); font-size: 18px; }
.notice .action { display: inline-flex; align-items: center; height: 48px; margin-top: 28px; padding: 0 20px;
  border-radius: 10px; background: var(--button); font-weight: 600; text-decoration: none; }
.notice .action:hover { background: var(--button-hover); }

/* The Feed Spec: a document Broadcasters read. */
.doc { max-width: 68ch; margin: 0 auto; padding: 16px 0 48px; }
.doc h1 { margin: 0 0 16px; font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.doc .lede { margin: 0 0 40px; color: var(--ink-soft); font-size: 19px; line-height: 1.55; }
.doc h2 { margin: 40px 0 10px; font-size: 20px; font-weight: 650; }
.doc ul { margin: 0; padding-left: 1.2em; color: var(--ink-soft); line-height: 1.65; }
.doc li { margin: 4px 0; font-variant-numeric: tabular-nums; }
.doc li::marker { color: var(--muted); }
