/*
 * Marquee: a cinema's lit sign. Deep indigo dark (for video contrast), warm
 * ivory type like marquee lettering, and one accent: the amber of a marquee
 * bulb, used for actions and for the glow around whatever has focus.
 *
 * Kept within Chrome 80 (older Android TV browsers): no `inset`, no
 * `aspect-ratio`, no `gap` on flex containers, `:focus-visible` in its own rules.
 */
:root {
  color-scheme: dark;
  --bg: #101018;
  --surface: #181826;
  --surface-2: #222235;
  --line: #2c2c42;
  --text: #f2ede4;
  --muted: #aaa6b9;
  --bulb: #ffc861;
  --bulb-ink: #221603;
  --glow: rgba(255, 200, 97, 0.45);
  --radius: 0.5rem;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --display: "Bahnschrift", "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --tile-w: clamp(13rem, 21vw, 21rem);
  --pad: clamp(1rem, 4vw, 3.5rem);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; color: var(--text); font: 1rem/1.5 var(--sans); min-height: 100vh; overflow-x: hidden; }
img { display: block; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--bulb); outline-offset: 3px; }

/* ── Header ── */
.top {
  position: absolute; top: 0; right: 0; left: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem var(--pad);
  background: linear-gradient(rgba(16, 16, 24, 0.85), transparent);
}
.brand { display: flex; align-items: center; text-decoration: none; font: 700 1.35rem/1 var(--display); font-stretch: condensed; letter-spacing: 0.02em; }
.brand img { width: 2rem; height: 2rem; margin-right: 0.6rem; }
.chip {
  font: inherit; font-size: 0.875rem; color: var(--text); cursor: pointer;
  padding: 0.45rem 0.9rem; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(24, 24, 38, 0.7);
}
.chip:hover { border-color: var(--muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1.4rem; border-radius: var(--radius); border: 0; cursor: pointer;
  font: 600 1rem/1.2 var(--sans); text-decoration: none; white-space: nowrap;
  background: rgba(242, 237, 228, 0.14); color: var(--text);
}
.btn:hover { background: rgba(242, 237, 228, 0.22); }
.btn.play { background: var(--bulb); color: var(--bulb-ink); }
.btn.play:hover { filter: brightness(1.06); }
.btn.quiet { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn[disabled] { opacity: 0.7; cursor: default; }

/* Focus from the remote or keyboard: the bulb glow. */
.is-focused {
  outline: 0;
  box-shadow: 0 0 0 0.18rem var(--bulb), 0 0 1.4rem 0.25rem var(--glow);
}
.btn:focus-visible, .chip:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.18rem var(--bulb), 0 0 1.4rem 0.25rem var(--glow);
}

/* ── Banner ── */
.banner { position: relative; height: min(56.25vw, 82vh); min-height: 24rem; overflow: hidden; }
/* The media layer is its own stacking context (z-index 0), so a playing trailer stays under the scrim (1) and the text (2). */
.banner .media { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 0; }
.backdrop { width: 100%; height: 100%; object-fit: cover; }
.backdrop.missing { visibility: hidden; }
.banner::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(16, 16, 24, 0.92) 0%, rgba(16, 16, 24, 0.55) 38%, transparent 70%),
    linear-gradient(0deg, var(--bg) 0%, transparent 32%);
}
.banner-body {
  position: absolute; z-index: 2; left: var(--pad); bottom: clamp(2.5rem, 9vh, 6rem);
  width: min(36rem, 46vw);
}
.banner-title { margin: 0 0 1rem; font: 700 clamp(2rem, 4.5vw, 3.75rem)/1.05 var(--display); font-stretch: condensed; }
.banner-title .logo { max-width: min(28rem, 38vw); max-height: 9rem; object-fit: contain; object-position: left bottom; }
.desc { margin: 0.75rem 0 1.25rem; color: var(--text); opacity: 0.9; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.actions { display: flex; flex-wrap: wrap; margin-bottom: -0.75rem; }
.actions > * { margin: 0 0.75rem 0.75rem 0; }
.meta { display: flex; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.95rem; }
.meta li { margin: 0 1.1rem 0.35rem 0; }
.meta li:first-child { color: var(--text); }

/* Trailers fade in only once they actually play. */
.media { position: relative; overflow: hidden; }
.media .trailer {
  position: absolute; z-index: 1; border: 0; pointer-events: none; opacity: 0;
  top: 50%; left: 50%; width: 100%; height: 100%; transform: translate(-50%, -50%) scale(1.18);
}
.banner .media .trailer { width: max(100%, 177.78vh); height: max(100%, 56.25vw); }
.media.is-playing .trailer { opacity: 1; }

/* ── Rows ── */
.status { margin: 1.5rem var(--pad); color: var(--muted); }
.status:empty { display: none; }
.status .btn { margin-left: 0.75rem; }
.rows { position: relative; z-index: 3; margin-top: -3rem; padding-bottom: 4rem; }
.row { margin: 0 0 1.75rem; }
.row-title { margin: 0 var(--pad) 0.35rem; font: 700 1.3rem/1.2 var(--display); font-stretch: condensed; letter-spacing: 0.01em; }
.strip {
  display: flex; overflow-x: auto; overscroll-behavior-x: contain;
  padding: 1rem var(--pad) 1.5rem; scroll-padding-inline: var(--pad);
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip > .tile + .tile { margin-left: 0.75rem; }

.tile {
  position: relative; flex: 0 0 var(--tile-w); height: calc(var(--tile-w) * 9 / 16); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; overflow: hidden;
  transform-origin: center; outline: 0;
}
.tile .media { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.tile .face {
  position: absolute; right: 0; bottom: 0; left: 0; z-index: 2; padding: 2.5rem 0.8rem 0.7rem;
  background: linear-gradient(transparent, rgba(16, 16, 24, 0.85));
}
.tile .face .logo { max-width: 62%; max-height: 2.75rem; object-fit: contain; object-position: left bottom; }
.tile .face .name { font: 700 1.05rem/1.2 var(--display); font-stretch: condensed; }
.tile .info {
  position: absolute; right: 0; bottom: 0; left: 0; z-index: 3; padding: 2rem 0.8rem 0.65rem; opacity: 0;
  background: linear-gradient(transparent, rgba(16, 16, 24, 0.95) 45%);
}
.tile .info strong { display: block; font-size: 0.95rem; line-height: 1.25; }
.tile .info .meta { font-size: 0.8rem; }
.tile .info .meta li { margin: 0 0.75rem 0.2rem 0; }
.tile.is-previewing { z-index: 4; transform: scale(1.08); box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.55); }
.tile.is-previewing .info { opacity: 1; }
.tile.is-previewing .face { opacity: 0; }
.tile.is-focused { transform: scale(1.08); }

/* ── Details ── */
.details {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20; display: grid; place-items: center;
  padding: 1.5rem; background: rgba(6, 6, 12, 0.78); overflow-y: auto;
}
.details-open body { overflow: hidden; }
.panel { position: relative; width: min(58rem, 100%); background: var(--surface); border-radius: 0.9rem; overflow: hidden; box-shadow: 0 2rem 4rem rgba(0, 0, 0, 0.6); }
.panel .media { height: 0; padding-top: 56.25%; }
.panel .media .backdrop { position: absolute; top: 0; left: 0; }
.panel .media::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: linear-gradient(0deg, var(--surface) 0%, transparent 40%); pointer-events: none; z-index: 2; }
.details-body { padding: 0 clamp(1.25rem, 4vw, 2.5rem) 2rem; margin-top: -3.5rem; position: relative; z-index: 3; }
.details-title { margin: 0 0 0.75rem; font: 700 clamp(1.75rem, 3.5vw, 2.75rem)/1.05 var(--display); font-stretch: condensed; }
.details-title .logo { max-width: min(22rem, 70%); max-height: 6.5rem; object-fit: contain; object-position: left bottom; }
.details .desc { -webkit-line-clamp: unset; display: block; max-width: 44rem; }
.credits { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; margin: 0 0 1.5rem; color: var(--muted); font-size: 0.95rem; }
.credits dt { color: var(--text); }
.credits dd { margin: 0; }
.icon-close {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 4; width: 2.5rem; height: 2.5rem;
  border-radius: 50%; border: 0; background: rgba(16, 16, 24, 0.7); color: var(--text); font-size: 1rem; cursor: pointer;
}

/* ── Phones ── */
@media (max-width: 40rem) {
  :root { --tile-w: 72vw; }
  .banner { height: 78vh; }
  .banner-body { width: auto; right: var(--pad); }
  .banner-title .logo { max-width: 75vw; }
  .chip { font-size: 0.8rem; padding: 0.4rem 0.75rem; }
}

/* ── TV: read from the couch ── */
html.tv { font-size: clamp(18px, 1.55vw, 30px); }
html.tv { --tile-w: clamp(14rem, 23vw, 22rem); }
html.tv .row-title { font-size: 1.4rem; }
html.tv .is-focused { box-shadow: 0 0 0 0.22rem var(--bulb), 0 0 1.8rem 0.4rem var(--glow); }
html.tv .strip { padding-block: 1.4rem 1.8rem; }
html.tv .banner-body { bottom: 4.5rem; }
html.tv .rows { margin-top: -1.5rem; }

@media (prefers-reduced-motion: no-preference) {
  .tile { transition: transform 0.18s ease, box-shadow 0.18s ease; }
  .tile .info, .tile .face, .media .trailer { transition: opacity 0.35s ease; }
  .btn, .chip { transition: background-color 0.15s, box-shadow 0.15s, filter 0.15s; }
}
