/* Sinema — dark, couch-friendly UI. Sizes are in rem and the root font scales with the
   screen, so a 1920×1080 TV, a 960×540 TV browser and a laptop all look the same. */
:root {
  --bg: #0a0a0d;
  --panel: #16161c;
  --panel-2: #20202a;
  --text: #f4f2ef;
  --muted: #a3a0a8;
  --accent: #e8442e;       /* ember red */
  --accent-2: #ff7a45;
  --ring: #ffffff;
  --gutter: 3.5rem;
  --card-w: 17rem;
  --radius: .5rem;
  color-scheme: dark;
}
html { font-size: calc(100vw / 120); background: var(--bg); }
@media (max-aspect-ratio: 4/3) { html { font-size: 15px; } :root { --gutter: 1rem; --card-w: 13rem; } }
@media (min-aspect-ratio: 4/3) and (max-width: 900px) { html { font-size: 12px; } :root { --gutter: 1.5rem; } }

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
:focus { outline: none; }
.muted { color: var(--muted); }
.center { text-align: center; }
.err { color: #ff8a7a; min-height: 1.4em; margin: 0; }
code { background: var(--panel-2); padding: .1em .4em; border-radius: .25em; }
.ic { width: 1.4em; height: 1.4em; fill: currentColor; flex: none; }

/* ---------- wordmark ---------- */
.wordmark {
  font-weight: 900; letter-spacing: .18em; font-size: 1.9rem; line-height: 1;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-transform: uppercase; user-select: none;
}
.wordmark.big { font-size: 3.4rem; margin-bottom: 1rem; }

/* ---------- backdrop (crossfades between two layers) ---------- */
#backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bd-img {
  position: absolute; top: 0; right: 0; width: 78%; height: 78%;
  background-size: cover; background-position: center 20%;
  opacity: 0; transition: opacity .6s ease;
}
.bd-img.on { opacity: 1; }
.bd-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, var(--bg) 22%, rgba(10,10,13,.85) 38%, rgba(10,10,13,.2) 65%, rgba(10,10,13,0) 100%),
    linear-gradient(0deg, var(--bg) 30%, rgba(10,10,13,.6) 48%, rgba(10,10,13,0) 70%);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .85rem 1.8rem; border-radius: .4rem;
  background: rgba(255,255,255,.14); color: var(--text);
  font-weight: 600; font-size: 1.15rem;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.btn.primary { background: var(--text); color: #111; }
.btn:hover { background: rgba(255,255,255,.24); }
.btn.primary:hover { background: #fff; }
.btn:focus-visible, body.keys .btn:focus { background: var(--accent); color: #fff; transform: scale(1.06); box-shadow: 0 0 0 .2rem var(--ring); }
.btn .size { font-weight: 400; opacity: .75; font-size: .9em; }

/* ---------- login ---------- */
#login { display: grid; place-items: center; background: radial-gradient(ellipse at 70% 20%, #2a1410 0, var(--bg) 60%); }
.login-box { display: flex; flex-direction: column; gap: 1rem; width: min(26rem, 90vw); align-items: stretch; text-align: center; }
.login-box input {
  padding: 1rem 1.2rem; border-radius: .4rem; border: .12rem solid #3a3a44; background: var(--panel); color: var(--text); font-size: 1.2rem;
}
.login-box input:focus { border-color: var(--ring); }
.login-box .btn { justify-content: center; }

/* ---------- layers ---------- */
.layer { position: fixed; inset: 0; z-index: 20; }
#main { position: relative; z-index: 1; height: 100vh; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 3rem;
  padding: 1.6rem var(--gutter) .6rem; flex: none;
}
#tabs { display: flex; gap: .4rem; }
.tab {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem 1rem; border-radius: 2rem; color: var(--muted); font-size: 1.1rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab .ic { width: 1.2em; height: 1.2em; }
.tab.active { color: var(--text); font-weight: 700; }
.tab:hover { color: var(--text); }
body.keys .tab:focus, .tab:focus-visible { background: var(--text); color: #111; }

/* ---------- browse: spotlight on top, rows underneath ---------- */
#browse { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#spotlight { flex: none; height: 44vh; padding: 1rem var(--gutter) 0; display: flex; align-items: flex-end; }
.sp-inner { max-width: 46rem; padding-bottom: 1.4rem; }
.sp-kicker { color: var(--accent-2); font-weight: 700; letter-spacing: .2em; font-size: .85rem; text-transform: uppercase; margin-bottom: .4rem; min-height: 1em; }
.sp-title { font-size: 3.6rem; line-height: 1.02; margin: 0 0 .7rem; font-weight: 800; letter-spacing: -.01em; text-shadow: 0 .15rem 1rem rgba(0,0,0,.5); }
.sp-meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; color: #d9d6d2; font-size: 1.05rem; margin-bottom: .8rem; }
.sp-meta .tag { border: 1px solid #77737c; padding: .05rem .45rem; border-radius: .2rem; font-size: .85rem; }
.sp-meta .score { color: #7ee08a; font-weight: 700; }
.sp-overview {
  font-size: 1.12rem; line-height: 1.5; color: #dcd9d5; margin: 0 0 1.2rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 1.5em;
}
.sp-actions { display: flex; gap: .9rem; flex-wrap: wrap; }

#rows { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding-bottom: 40vh; }
#rows::-webkit-scrollbar, .track::-webkit-scrollbar { display: none; }
.row { margin-bottom: 1.6rem; }
.row h2 { font-size: 1.35rem; font-weight: 700; margin: 0 0 .6rem; padding: 0 var(--gutter); color: #ece9e5; }
.track {
  display: flex; gap: .9rem; overflow-x: auto; scrollbar-width: none;
  padding: .7rem var(--gutter) 1rem; scroll-padding: var(--gutter);
}
body.touch .track { scroll-snap-type: x proximity; }

/* ---------- cards ---------- */
.card {
  position: relative; flex: none; width: var(--card-w); aspect-ratio: 16 / 9;
  border-radius: var(--radius); overflow: hidden; background: var(--panel);
  transition: transform .18s ease, box-shadow .18s ease; text-align: left;
  scroll-snap-align: start;
}
.card .art { position: absolute; inset: 0; background-size: cover; background-position: center 25%; }
.card .art.gen { display: flex; align-items: flex-end; padding: .9rem; }
.card .art.gen span { font-weight: 800; font-size: 1.45rem; line-height: 1.05; text-shadow: 0 .1rem .5rem rgba(0,0,0,.4); }
.card .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 1.6rem .8rem .6rem;
  background: linear-gradient(0deg, rgba(0,0,0,.85), rgba(0,0,0,0));
  font-weight: 600; font-size: 1rem; line-height: 1.2;
}
.card .label small { display: block; color: #cfcbc6; font-weight: 400; font-size: .85rem; margin-top: .1rem; }
.card .prog { position: absolute; left: .8rem; right: .8rem; bottom: .45rem; height: .22rem; background: rgba(255,255,255,.3); border-radius: 1rem; }
.card .prog i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.card:hover { transform: scale(1.04); }
.card:focus-visible, body.keys .card:focus {
  transform: scale(1.1); z-index: 2;
  box-shadow: 0 0 0 .22rem var(--ring), 0 .8rem 2rem rgba(0,0,0,.6);
}
.card.poster { aspect-ratio: 2 / 3; width: calc(var(--card-w) * .62); }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  gap: 1.6rem 1rem; padding: 1rem var(--gutter) 30vh;
}
.grid .card { width: auto; }

/* ---------- search ---------- */
#search { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.search-bar {
  display: flex; align-items: center; gap: .8rem; margin: 1.2rem var(--gutter) .6rem;
  padding: .9rem 1.2rem; border-radius: .5rem; background: var(--panel); border: .12rem solid #2c2c35;
}
.search-bar:focus-within { border-color: var(--ring); }
.search-bar input { flex: 1; background: none; border: 0; color: var(--text); font-size: 1.4rem; }

.empty { margin: 8vh var(--gutter); max-width: 44rem; }
.empty h2 { font-size: 2.2rem; margin: 0 0 .6rem; }
.empty p { font-size: 1.15rem; line-height: 1.5; color: var(--muted); }

/* ---------- details ---------- */
#details { background: var(--bg); z-index: 30; }
.dt-bg { position: absolute; inset: 0; background-size: cover; background-position: center 20%; }
.dt-bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, var(--bg) 25%, rgba(10,10,13,.8) 45%, rgba(10,10,13,.25) 75%),
    linear-gradient(0deg, var(--bg) 25%, rgba(10,10,13,0) 60%);
}
.dt-scroll { position: absolute; inset: 0; overflow-y: auto; scrollbar-width: none; padding: 12vh var(--gutter) 30vh; }
.dt-scroll::-webkit-scrollbar { display: none; }
.dt-head { max-width: 64rem; margin-bottom: 2rem; }
.dt-overview { font-size: 1.2rem; line-height: 1.55; color: #dcd9d5; margin: 0 0 1.4rem; }
.chips { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.chip {
  padding: .5rem 1.1rem; border-radius: 2rem; background: rgba(255,255,255,.1); font-weight: 600; font-size: 1.05rem;
}
.chip.active { background: rgba(255,255,255,.28); }
body.keys .chip:focus, .chip:focus-visible { background: var(--text); color: #111; }

.ep {
  display: flex; align-items: stretch; gap: .6rem; max-width: 64rem; margin-bottom: .5rem;
}
.ep-main {
  flex: 1; display: grid; grid-template-columns: 3.2rem 1fr auto; align-items: center; gap: 1.2rem;
  padding: 1rem 1.2rem; border-radius: .5rem; background: rgba(22,22,28,.8); text-align: left;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.ep-num { font-size: 1.6rem; font-weight: 800; color: #8d8993; text-align: center; }
.ep-body { display: flex; align-items: center; gap: 1.2rem; min-width: 0; }
.ep-thumb { flex: none; width: 12rem; aspect-ratio: 16 / 9; border-radius: .35rem; background: var(--panel-2) center / cover; }
.ep-text { min-width: 0; }
.ep-title { font-weight: 700; font-size: 1.15rem; }
.ep-rt { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: .4rem; }
.ep-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dl-status { color: var(--muted); font-size: 1rem; margin: -.4rem 0 1rem; display: flex; align-items: center; gap: .6rem; }
.dl-status .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--accent-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.ep-desc { color: var(--muted); font-size: .95rem; margin-top: .25rem; line-height: 1.4; }
.ep-side { color: var(--muted); font-size: .95rem; white-space: nowrap; }
.ep-prog { height: .2rem; background: rgba(255,255,255,.2); border-radius: 1rem; margin-top: .5rem; max-width: 20rem; }
.ep-prog i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.ep-dl {
  width: 4.2rem; display: grid; place-items: center; border-radius: .5rem; background: rgba(22,22,28,.8); color: var(--muted);
  transition: background .15s, color .15s;
}
.ep-main:hover, .ep-dl:hover { background: rgba(50,50,60,.9); }
body.keys .ep-main:focus, .ep-main:focus-visible { background: var(--panel-2); box-shadow: 0 0 0 .2rem var(--ring); transform: scale(1.015); }
body.keys .ep-dl:focus, .ep-dl:focus-visible { background: var(--text); color: #111; }

/* ---------- player ---------- */
#player { background: #000; z-index: 40; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
#video::cue { font-size: 1.6rem; background: rgba(0,0,0,.6); }
#pl-ui {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(180deg, rgba(0,0,0,.7) 0, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 60%, rgba(0,0,0,.85) 100%);
  transition: opacity .3s; opacity: 1;
}
#player.idle #pl-ui { opacity: 0; pointer-events: none; }
#player.idle { cursor: none; }
.pl-top { display: flex; align-items: center; gap: 1.2rem; padding: 2rem var(--gutter); }
.pl-title div:first-child { font-size: 1.5rem; font-weight: 700; }
.pl-bottom { padding: 0 var(--gutter) 2.4rem; }
.pl-timeline { display: flex; align-items: center; gap: 1.2rem; font-variant-numeric: tabular-nums; font-size: 1.1rem; margin-bottom: 1.2rem; }
.bar { position: relative; flex: 1; height: 2.2rem; }
.bar::before, .bar-buf, .bar-fill { position: absolute; left: 0; top: 50%; height: .35rem; margin-top: -.175rem; border-radius: 1rem; }
.bar::before { content: ""; right: 0; background: rgba(255,255,255,.25); }
.bar-buf { background: rgba(255,255,255,.4); width: 0; }
.bar-fill { background: var(--accent); width: 0; }
.bar-knob { position: absolute; top: 50%; width: 1.1rem; height: 1.1rem; margin: -.55rem 0 0 -.55rem; border-radius: 50%; background: var(--accent); left: 0; transition: transform .15s; }
body.keys .bar:focus .bar-knob, .bar:focus-visible .bar-knob { transform: scale(1.6); box-shadow: 0 0 0 .2rem var(--ring); }
body.keys .bar:focus::before { background: rgba(255,255,255,.4); }
.pl-buttons { display: flex; align-items: center; gap: 1.2rem; }
.pl-buttons .spacer { flex: 1; }
.icbtn { width: 3.6rem; height: 3.6rem; border-radius: 50%; display: grid; place-items: center; transition: background .15s, transform .15s; }
.icbtn .ic { width: 2rem; height: 2rem; }
.icbtn.big { width: 4.6rem; height: 4.6rem; }
.icbtn.big .ic { width: 2.8rem; height: 2.8rem; }
.icbtn:hover { background: rgba(255,255,255,.15); }
body.keys .icbtn:focus, .icbtn:focus-visible { background: var(--text); color: #111; transform: scale(1.1); }
#pl-play .i-pause { display: none; }
#player.playing #pl-play .i-pause { display: inline; }
#player.playing #pl-play .i-play { display: none; }
.pill { padding: .6rem 1.2rem; border-radius: 2rem; background: rgba(255,255,255,.14); font-weight: 600; font-size: 1.05rem; }
body.keys .pill:focus, .pill:focus-visible { background: var(--text); color: #111; }

.spinner {
  position: absolute; left: 50%; top: 50%; width: 4rem; height: 4rem; margin: -2rem;
  border: .35rem solid rgba(255,255,255,.2); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.seekhint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  padding: 1rem 1.6rem; border-radius: 1rem; background: rgba(0,0,0,.6); font-size: 1.6rem; font-weight: 700;
}
.pl-error {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 40rem;
  background: rgba(20,20,26,.95); padding: 2rem; border-radius: .8rem; line-height: 1.5; font-size: 1.15rem;
}
.upnext {
  position: absolute; right: var(--gutter); bottom: 10rem; width: 28rem;
  background: rgba(20,20,26,.95); padding: 1.4rem; border-radius: .8rem; box-shadow: 0 1rem 3rem rgba(0,0,0,.6);
}
.un-title { font-size: 1.3rem; font-weight: 700; margin: .3rem 0 1rem; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 3rem; transform: translateX(-50%); z-index: 60;
  background: var(--panel-2); padding: .9rem 1.5rem; border-radius: .6rem; font-size: 1.05rem;
  box-shadow: 0 .6rem 2rem rgba(0,0,0,.5);
}

/* ---------- phones / portrait ---------- */
@media (max-aspect-ratio: 4/3) {
  body { overflow: auto; }
  #main { height: auto; min-height: 100vh; }
  #topbar { flex-direction: column; align-items: flex-start; gap: .8rem; padding-top: 1rem; }
  #tabs { overflow-x: auto; max-width: 100%; }
  #browse { display: block; }
  #spotlight { height: auto; min-height: 52vh; }
  .sp-title { font-size: 2.2rem; }
  #rows { overflow: visible; padding-bottom: 3rem; }
  .bd-img { width: 100%; height: 60%; }
  .bd-shade { background: linear-gradient(0deg, var(--bg) 42%, rgba(10,10,13,.5) 60%, rgba(10,10,13,.1) 100%); }
  .ep-main { grid-template-columns: 2rem 1fr; }
  .ep-side { display: none; }
  .upnext { left: var(--gutter); right: var(--gutter); width: auto; bottom: 8rem; }
  .pl-buttons { gap: .4rem; flex-wrap: wrap; }
}

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