/* Lightbox — TV-first, 10-foot UI.
 * Performance rules (LG webOS 24 = Chromium 108 on a modest SoC):
 *  - animate only transform + opacity (compositor-only, no layout/paint)
 *  - no backdrop-filter, no animated box-shadow (shadow = pre-painted ::after, opacity only)
 *  - one static blurred backdrop, rasterised small then scaled by the compositor
 *  - everything sized in rem; rem tracks the viewport so 1920×1080 = 20px
 */

:root {
  --bg: #08080b;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-2: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text-2: rgba(235, 235, 245, 0.62);
  --text-3: rgba(235, 235, 245, 0.38);
  --focus: #ffffff;
  --on-focus: #0b0b0f;
  --ok: #4cd97b;
  --warn: #ffb340;
  --bad: #ff5a5f;
  --radius: 0.9rem;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: 4rem;
  color-scheme: dark;
}

html {
  font-size: clamp(13px, 1.0417vw, 40px); /* 20px at 1920 wide */
  background: var(--bg);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: transparent; /* html paints the colour, so the fixed backdrop shows through */
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "LG Smart UI", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; }
:focus { outline: none; }
[hidden] { display: none !important; }

/* ── top bar ─────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 5.2rem;
  padding: 0 var(--gutter);
  background: linear-gradient(to bottom, rgba(8, 8, 11, 0.92), rgba(8, 8, 11, 0));
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.topbar.away { opacity: 0; transform: translateY(-1.5rem); pointer-events: none; }
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; color: var(--text-2); }
.brand b { color: var(--text); }
.tabs { display: flex; gap: 0.4rem; padding: 0.3rem; border-radius: 99rem; background: var(--surface); }
.tab {
  border: 0;
  background: transparent;
  padding: 0.55rem 1.4rem;
  border-radius: 99rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: transform 0.18s var(--ease);
}
.tab.active { color: var(--text); background: var(--surface-2); }
.tab:focus { background: var(--focus); color: var(--on-focus); transform: scale(1.06); }

/* ── layout ──────────────────────────────────────────────────────── */
.app { padding: 6rem 0 4rem; min-height: 100vh; }
.section { padding: 0 var(--gutter); margin-top: 2.4rem; }
.section-title { font-size: 1.35rem; font-weight: 700; margin: 0 0 0.9rem; }
.section-sub { color: var(--text-2); font-size: 0.9rem; margin: -0.6rem 0 1rem; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }

/* ── backdrop + hero ─────────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
/* Rasterised at 1/8 size with a small blur, then scaled up by the GPU: a
   full-screen blur for the cost of a thumbnail. */
.backdrop img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12.5vw;
  height: 12.5vh;
  object-fit: cover;
  filter: blur(4px) saturate(1.3);
  transform: translate(-50%, -50%) scale(8.6);
  opacity: 0.55;
  will-change: transform;
  animation: fade 0.6s var(--ease);
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(8, 8, 11, 0.96) 0%, rgba(8, 8, 11, 0.7) 45%, rgba(8, 8, 11, 0.35) 100%),
    linear-gradient(to top, var(--bg) 0%, rgba(8, 8, 11, 0) 55%);
}

.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2.6rem;
  align-items: end;
  padding: 2rem var(--gutter) 0;
  min-height: 24rem;
}
.hero.text-only { grid-template-columns: 1fr; min-height: 20rem; }
.hero .poster { width: 13rem; border-radius: var(--radius); overflow: hidden; position: relative; background: var(--surface); }
.hero h1 { font-size: 2.8rem; line-height: 1.08; margin: 0 0 0.8rem; font-weight: 800; letter-spacing: -0.01em; max-width: 40ch; }
.hero .lead { color: var(--text-2); font-size: 1.05rem; max-width: 52ch; margin: 0 0 1.4rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.6rem;
  border-radius: 0.45rem;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tag.solid { background: var(--text); color: var(--on-focus); }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); }
.tag.bad { color: var(--bad); }

/* ── buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border: 0;
  padding: 0.85rem 1.7rem;
  border-radius: 0.8rem;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.18s var(--ease);
}
.btn.primary { background: rgba(255, 255, 255, 0.88); color: var(--on-focus); }
.btn:focus { background: var(--focus); color: var(--on-focus); transform: scale(1.07); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn .chev { opacity: 0.6; font-size: 0.8em; }

/* ── tiles (posters, episodes) ───────────────────────────────────── */
.rail {
  display: flex;
  gap: 1.4rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1.2rem var(--gutter) 2rem;
  margin: -1.2rem calc(-1 * var(--gutter)) -1.2rem;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 2rem 1.4rem;
}

.tile {
  position: relative;
  flex: 0 0 auto;
  display: block;
  width: 10.5rem;
  border: 0;
  padding: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.grid .tile { width: auto; }
.tile .art {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transform: translateZ(0);
  transition: transform 0.2s var(--ease);
}
/* Shadow is painted once; focus only fades it in (opacity = compositor). */
.tile .art::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0.15rem rgba(255, 255, 255, 0.9);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.tile:focus .art { transform: scale(1.09) translateZ(0); }
.tile:focus .art::after { opacity: 1; }
.tile .label { margin-top: 0.7rem; font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: transform 0.2s var(--ease); }
.tile .sub { color: var(--text-2); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: transform 0.2s var(--ease); }
.tile:focus .label, .tile:focus .sub { transform: translateY(0.55rem); }
.tile.dim { opacity: 0.45; }

.poster { aspect-ratio: 2 / 3; }
.poster img, .wide img { position: relative; width: 100%; height: 100%; object-fit: cover; }
.letter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-3);
}
.wide { aspect-ratio: 16 / 9; }
.tile.episode { width: 16rem; }
.episode .art { display: grid; align-content: end; padding: 1rem 1.1rem; background: #1a1a20; }
.episode .art > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; opacity: 0.5; }
.episode .art::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(8, 8, 11, 0.92) 10%, rgba(8, 8, 11, 0.15) 75%); }
.episode .num { position: absolute; top: 0.2rem; right: 1rem; font-size: 3.6rem; font-weight: 800; color: rgba(255, 255, 255, 0.28); }
.episode .ep-title { font-weight: 700; font-size: 1.05rem; position: relative; }
.episode .ep-sub { color: var(--text-2); font-size: 0.8rem; position: relative; margin-bottom: 0.4rem; }
.progress { position: absolute; left: 0.8rem; right: 0.8rem; bottom: 0.7rem; height: 0.28rem; border-radius: 1rem; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.progress i { display: block; height: 100%; background: #fff; transform-origin: left; }

/* ── version picker ──────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin-bottom: 1.2rem; }
.menu-btn { padding: 0.7rem 1.2rem; }
.menu-btn .k { opacity: 0.6; font-weight: 500; }
.versions { display: grid; gap: 0.7rem; max-width: 80rem; }
.version {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  gap: 1.3rem;
  align-items: center;
  width: 100%;
  border: 0;
  padding: 0.9rem 1.3rem;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s var(--ease);
}
.version:focus { background: var(--focus); color: var(--on-focus); transform: scale(1.025); }
.version:focus .tag { background: rgba(0, 0, 0, 0.1); color: var(--on-focus); }
.version:focus .muted { color: rgba(11, 11, 15, 0.65); }
.version.selected { box-shadow: inset 0 0 0 0.15rem rgba(255, 255, 255, 0.55); }
.version .res { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.version .line1 { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; font-weight: 650; }
.version .line2 { font-size: 0.85rem; margin-top: 0.25rem; }
.version .go { font-weight: 650; opacity: 0.7; white-space: nowrap; }

.list { display: grid; gap: 0.6rem; max-width: 60rem; }
.row-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  border: 0;
  padding: 1rem 1.3rem;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s var(--ease);
}
.row-btn:focus { background: var(--focus); color: var(--on-focus); transform: scale(1.02); }
.row-btn:focus .tag { background: rgba(0, 0, 0, 0.1); color: var(--on-focus); }
.row-btn:disabled { opacity: 0.4; }

/* ── search ──────────────────────────────────────────────────────── */
.search-box form { display: flex; gap: 0.8rem; max-width: 56rem; }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0.9rem;
  padding: 1rem 1.4rem;
  background: var(--surface-2);
  font-size: 1.3rem;
  transition: transform 0.18s var(--ease);
}
.search-box input:focus { background: #fff; color: var(--on-focus); transform: scale(1.015); }
.search-box input::placeholder { color: var(--text-3); }
.search-box input:focus::placeholder { color: rgba(11, 11, 15, 0.45); }
.search-box .hint { margin-top: 0.8rem; }

/* ── states ──────────────────────────────────────────────────────── */
.center-state { display: grid; place-items: center; gap: 1rem; padding: 5rem var(--gutter); text-align: center; color: var(--text-2); }
.center-state h2 { color: var(--text); margin: 0; font-size: 1.6rem; }
.spinner {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 0.22rem solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-text { color: #ffb4b6; }

/* ── layers (menus, dialogs) ─────────────────────────────────────── */
.layer { position: fixed; inset: 0; z-index: 50; animation: fade 0.18s var(--ease); }
.layer.dim { background: rgba(0, 0, 0, 0.72); display: grid; place-items: center; }
@keyframes fade { from { opacity: 0; } }
.menu {
  position: absolute;
  min-width: 15rem;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.5rem;
  border-radius: 1.1rem;
  background: #232328;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.6);
  animation: pop 0.2s var(--ease);
  scrollbar-width: none;
}
@keyframes pop { from { opacity: 0; transform: translateY(-0.6rem) scale(0.97); } }
.menu button {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  border: 0;
  padding: 0.75rem 1rem;
  border-radius: 0.7rem;
  background: none;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}
.menu button .check { width: 1rem; opacity: 0; }
.menu button.on .check { opacity: 1; }
.menu button .count { margin-left: auto; padding-left: 2rem; color: var(--text-3); font-weight: 500; }
.menu button:focus { background: var(--focus); color: var(--on-focus); }
.menu button:focus .count { color: rgba(11, 11, 15, 0.55); }
.dialog {
  width: min(36rem, 90vw);
  padding: 2.2rem;
  border-radius: 1.4rem;
  background: #1c1c21;
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.6);
  animation: pop 0.22s var(--ease);
}
.dialog h3 { margin: 0 0 0.4rem; font-size: 1.4rem; }
.dialog .step { color: var(--text-2); min-height: 1.4em; margin: 0; }
.dialog .head { display: flex; gap: 1.2rem; align-items: center; }
.dialog .actions { display: flex; gap: 0.8rem; margin-top: 1.6rem; justify-content: flex-end; }
.dialog pre { white-space: pre-wrap; font-family: inherit; font-size: 0.9rem; color: #ffb4b6; max-height: 10rem; overflow: auto; margin: 1rem 0 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 3rem;
  z-index: 80;
  max-width: 80vw;
  padding: 0.8rem 1.4rem;
  border-radius: 99rem;
  background: rgba(40, 40, 46, 0.96);
  font-weight: 600;
  transform: translateX(-50%);
  animation: rise 0.22s var(--ease);
}
.toast.error { color: #ffb4b6; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 1rem); } }

/* ── player ──────────────────────────────────────────────────────── */
body.playing { overflow: hidden; }
body.playing .topbar, body.playing .backdrop { display: none; }
.player { position: fixed; inset: 0; z-index: 30; background: #000; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player .busy { position: absolute; left: 50%; top: 50%; margin: -1.3rem 0 0 -1.3rem; }
.chrome { position: absolute; inset: 0; transition: opacity 0.3s var(--ease); }
.chrome.hidden { opacity: 0; pointer-events: none; }
.chrome.hidden * { cursor: none; }
.chrome .top { position: absolute; inset: 0 0 auto; padding: 2.4rem var(--gutter) 5rem; background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0)); }
.chrome .top h2 { margin: 0; font-size: 1.6rem; }
.chrome .top .muted { margin-top: 0.2rem; }
.chrome .bottom { position: absolute; inset: auto 0 0; padding: 6rem var(--gutter) 2.4rem; background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0)); }
.scrub { position: relative; height: 0.45rem; border-radius: 1rem; background: rgba(255, 255, 255, 0.22); cursor: pointer; transition: transform 0.18s var(--ease); }
.scrub:focus { transform: scaleY(1.6); }
.scrub i { position: absolute; inset: 0; border-radius: inherit; transform-origin: left; transform: scaleX(0); }
.scrub .buf { background: rgba(255, 255, 255, 0.3); }
.scrub .played { background: #fff; }
.scrub .marker {
  position: absolute;
  top: -0.55rem;
  bottom: -0.55rem;
  left: 0;
  width: 0.2rem;
  margin-left: -0.1rem;
  border-radius: 0.2rem;
  background: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}
.scrub.scrubbing .marker { opacity: 1; }
.times { display: flex; justify-content: space-between; margin-top: 0.8rem; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.times .target { color: #fff; }
.pbar { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.3rem; }
.pbar .btn { padding: 0.65rem 1.2rem; background: rgba(255, 255, 255, 0.14); }
.pbar .btn:focus { background: var(--focus); }
.pmsg { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.7); }

/* ── small screens (phone / laptop) ──────────────────────────────── */
@media (max-width: 760px) {
  :root { --gutter: 1rem; }
  html { font-size: 14px; }
  .topbar { grid-template-columns: 1fr; height: 4.2rem; }
  .brand { display: none; }
  .tabs { justify-self: center; }
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero .poster { width: 8rem; }
  .hero h1 { font-size: 1.8rem; }
  .version { grid-template-columns: 4.5rem 1fr; }
  .version .go { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 1.2rem 0.8rem; }
  .tile.episode { width: 12rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .rail { scroll-behavior: auto; }
}
