/* Everything is sized in rem and the root scales with the viewport, so the
   layout is identical on a 1080p TV, a 4K TV and a laptop window. 96rem = full width. */
:root {
  --bg: #07070a;
  --text: #f5f5f7;
  --dim: #b4b4bd;
  --faint: #7a7a86;
  --accent: #ffc94d;
  --ring: #ffffff;
  --glass: rgba(255, 255, 255, .13);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html { font-size: min(calc(100vw / 96), calc(100vh / 54)); background: var(--bg); }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  color: var(--text); background: var(--bg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
body.nocursor, body.nocursor * { cursor: none !important; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ---------- stage: backdrop + trailer ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; background: #000; }
.bd {
  position: absolute; inset: 0 0 0 18%;
  background-size: cover; background-position: center top;
  opacity: 0; transition: opacity .9s ease;
}
.bd.on { opacity: 1; animation: kenburns 40s ease-out forwards; }
@keyframes kenburns { from { transform: scale(1.0); } to { transform: scale(1.12); } }
/* Trailer covers the full screen (a 16:9 video on a 16:9 TV = no side crop);
   the left vignette keeps the text readable. A slight overscan hides YouTube's edge chrome. */
#trailer { position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s ease; pointer-events: none; overflow: hidden; }
#stage.playing #trailer { opacity: 1; }
#stage.playing .bd { opacity: 0; transition-duration: 1.4s; }
#trailer iframe {
  position: absolute; top: 50%; left: 50%; border: 0; pointer-events: none;
  width: max(100vw, 177.78vh); height: max(56.25vw, 100vh);
  transform: translate(-50%, -50%) scale(1.04);
}
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, var(--bg) 0%, rgba(7,7,10,.96) 18%, rgba(7,7,10,.7) 34%, rgba(7,7,10,.15) 58%, transparent 75%),
    linear-gradient(0deg, var(--bg) 0%, rgba(7,7,10,.9) 30%, rgba(7,7,10,.2) 55%, transparent 70%),
    linear-gradient(180deg, rgba(7,7,10,.7) 0%, transparent 16%);
  transition: background .4s, opacity .35s ease;
}
body[data-screen="detail"] .vignette, body[data-screen="search"] .vignette, body[data-screen="rate"] .vignette {
  background:
    linear-gradient(90deg, var(--bg) 0%, rgba(7,7,10,.95) 30%, rgba(7,7,10,.6) 52%, rgba(7,7,10,.1) 75%),
    linear-gradient(0deg, var(--bg) 0%, rgba(7,7,10,.85) 32%, transparent 60%),
    linear-gradient(180deg, rgba(7,7,10,.7) 0%, transparent 16%);
}
body[data-screen="player"] #stage { visibility: hidden; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 4.6rem; z-index: 5;
  display: flex; align-items: center; gap: 2rem; padding: 0 4rem;
  transition: opacity .3s;
}
body[data-screen="player"] #topbar { opacity: 0; }
body:not([data-screen="home"]) #topnav { opacity: 0; pointer-events: none; }
.brand { font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em; }
.brand b { color: var(--accent); font-weight: 800; }
#topnav { display: flex; gap: .5rem; }
.tbtn {
  background: none; border: 0; padding: .45rem 1rem; border-radius: 99rem;
  color: var(--dim); font-size: 1rem; font-weight: 500; cursor: pointer;
}
button:focus, button:focus-visible { outline: none; }   /* tvOS draws focus itself (.focus) */
.tbtn:hover { color: var(--text); }
.tbtn.focus { background: var(--ring); color: #000; }
.spacer { flex: 1; }
#clock { font-size: 1.25rem; font-weight: 600; color: var(--dim); font-variant-numeric: tabular-nums; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; transition: opacity .35s ease; }
body:not([data-screen="home"]) #home { opacity: 0; pointer-events: none; }
.screen.under { opacity: 0; pointer-events: none; }   /* a screen with another one open on top */

/* hero info */
.hinfo { position: absolute; left: 4rem; top: 6.2rem; width: 42rem; height: 23rem; display: flex; flex-direction: column; justify-content: flex-end; }
.kicker { color: var(--accent); font-weight: 700; font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .7rem; }
/* fixed height: a logo loading in must not resize (= jump) the info block */
.logo { display: block; width: auto; max-width: 26rem; height: 7.5rem; object-fit: contain; object-position: left bottom; margin-bottom: .9rem; filter: drop-shadow(0 .2rem 1rem rgba(0,0,0,.6)); }
.htitle { font-size: 3.3rem; line-height: 1.02; font-weight: 800; letter-spacing: -.03em; margin: 0 0 .8rem; text-shadow: 0 .2rem 1.2rem rgba(0,0,0,.5); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; color: var(--dim); font-size: 1.05rem; font-weight: 500; }
.meta .score { color: var(--text); font-weight: 700; }
.meta .cert { border: .09rem solid var(--faint); border-radius: .25rem; padding: 0 .4rem; font-size: .85rem; }
.epline { margin-top: .6rem; font-size: 1.05rem; font-weight: 600; }
.epline .tag { color: #000; background: var(--accent); border-radius: .25rem; padding: .05rem .45rem; margin-right: .6rem; font-size: .8rem; font-weight: 800; letter-spacing: .05em; }
.ov { margin: .7rem 0 0; color: #dcdce2; font-size: 1.1rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.libline { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .8rem; min-height: 2rem; }
.libline:empty { display: none; }
.chip { background: var(--glass); border-radius: 99rem; padding: .2rem .8rem; font-size: .9rem; font-weight: 600; color: var(--text); backdrop-filter: blur(6px); }
.chip.fav { background: rgba(255, 90, 110, .22); color: #ff9fb0; }
.chip.lib { background: rgba(120, 220, 160, .18); color: #9ff0bf; }
.chip.next { background: rgba(255, 201, 77, .2); color: var(--accent); }
.chip.drop { background: rgba(255,255,255,.08); color: var(--faint); }
.prov { display: flex; align-items: center; gap: .45rem; }
.prov .lbl { color: var(--faint); font-size: .85rem; font-weight: 600; margin-right: .2rem; }
.prov img { width: 2rem; height: 2rem; border-radius: .45rem; }
.libline .prov { margin-left: .4rem; }

/* rows */
#rows, #frows { position: absolute; left: 0; right: 0; top: 30.5rem; transition: transform .45s var(--ease); }
.row { padding: 0 0 1.3rem 4rem; transition: opacity .35s ease; }
.row.past { opacity: 0; }
.row h2 { font-size: 1.3rem; font-weight: 700; margin: 0 0 .7rem; letter-spacing: -.01em; }
.track { position: relative; display: flex; gap: .9rem; padding: .5rem 0; transition: transform .4s var(--ease); }
.card {
  position: relative; flex: none; width: 18rem; aspect-ratio: 16 / 9; border-radius: .6rem;
  overflow: hidden; background: #1a1a22; cursor: pointer;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), opacity .3s;
  box-shadow: 0 .3rem 1rem rgba(0,0,0,.4);
}
.row:not(.cur) .card { opacity: .75; }
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card img.poster { object-position: center 20%; }
.card .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2.2rem .9rem .65rem;
  background: linear-gradient(0deg, rgba(0,0,0,.88), rgba(0,0,0,.5) 55%, transparent);
}
.card .ct { font-weight: 700; font-size: 1.05rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cs { font-size: .82rem; color: var(--dim); font-weight: 500; margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .badge {
  position: absolute; top: .6rem; left: .6rem; background: var(--accent); color: #000;
  font-size: .72rem; font-weight: 800; letter-spacing: .06em; padding: .12rem .45rem; border-radius: .25rem;
}
.card .badge.soon { background: rgba(0,0,0,.65); color: var(--accent); backdrop-filter: blur(4px); }
.card .mark {
  position: absolute; top: .55rem; right: .6rem; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 800;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
}
.card .mark.fav { color: #ff8fa3; }
.card .mark.lib { color: #8ff0b5; }
.card .mark.next { color: var(--accent); }
.card.focus { transform: scale(1.08); box-shadow: 0 0 0 .22rem var(--ring), 0 1rem 2.5rem rgba(0,0,0,.7); opacity: 1 !important; z-index: 2; }
.card.poster-card { width: 9rem; aspect-ratio: 2 / 3; }
.card.person { opacity: 1; }

/* ---------- detail ---------- */
/* flex column: info on top, "More like this" pinned to the bottom — never overlapping */
#detail { display: flex; flex-direction: column; padding-top: 5.5rem; transition: opacity .35s ease, transform .45s var(--ease); }
.dinfo { flex: none; margin-left: 4rem; width: 52rem; }
.dinfo .ov { -webkit-line-clamp: 4; font-size: 1.15rem; }
.credits { margin-top: .8rem; color: var(--faint); font-size: .95rem; line-height: 1.5; }
.credits b { color: var(--dim); font-weight: 600; }
.dinfo .libline { margin-top: 1rem; }
.btns { display: flex; gap: .8rem; margin-top: 1.4rem; flex-wrap: nowrap; }
.btn {
  display: inline-flex; align-items: center; gap: .55rem; white-space: nowrap;
  background: var(--glass); border: 0; border-radius: .5rem; padding: .75rem 1.4rem;
  font-size: 1.1rem; font-weight: 600; cursor: pointer; backdrop-filter: blur(8px);
  transition: transform .18s var(--ease);   /* focus snaps (no background crossfade = no double highlight mid-move) */
}
.btn .ic { font-size: 1.15rem; width: 1.2rem; text-align: center; }
.btn.on { color: var(--accent); }
.btn.dim { opacity: .45; }   /* e.g. Trailer while none is found (yet) — present, so nothing shifts */
.btn.focus { background: var(--ring); color: #000; transform: scale(1.05); }
.btn.rate { min-width: 3.4rem; justify-content: center; padding: .75rem 1rem; }
#drow, #srow { flex: none; margin-top: auto; padding-top: 1.2rem; }
.rhint { color: var(--dim); font-size: 1rem; margin: .8rem 0 0; }

/* ---------- rate ("have you seen it?") ---------- */
#rate { display: flex; flex-direction: column; padding: 5.5rem 0 3rem; }
#rate .dinfo .ov { -webkit-line-clamp: 3; }
.rpanel { flex: none; margin: auto 0 0 4rem; }
.rq { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }
.rpanel .btns { margin-top: 1rem; }
.btn.star { width: 4.1rem; justify-content: center; padding: .85rem 0; font-size: 1.35rem; font-weight: 700; }
.rstats { margin-top: 1.4rem; color: var(--faint); font-size: .95rem; }

/* ---------- search ---------- */
#search { display: flex; flex-direction: column; padding-top: 5.6rem; }
.sbox {
  flex: none; margin-left: 4rem; width: 52rem; display: flex; align-items: center; gap: 1rem;
  background: rgba(255,255,255,.1); border-radius: .8rem; padding: .9rem 1.4rem;
  box-shadow: 0 0 0 .15rem transparent; transition: box-shadow .15s, background .15s; backdrop-filter: blur(10px);
}
.sbox.focus { box-shadow: 0 0 0 .2rem var(--ring); background: rgba(255,255,255,.16); }
.sicon { font-size: 2rem; color: var(--dim); line-height: 1; }
.sbox input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 1.8rem; font-weight: 600; }
.sbox input::placeholder { color: var(--faint); }
.sbox input { cursor: text; }
#skb { flex: none; margin: 1.1rem 0 0 4rem; display: flex; flex-direction: column; gap: .5rem; }
.kbrow { display: flex; gap: .45rem; }
.btn.key { width: 3.4rem; height: 3rem; padding: 0; justify-content: center; font-size: 1.15rem; border-radius: .45rem; }
.btn.key.wide { width: auto; padding: 0 1rem; }
.btn.key.focus { transform: scale(1.12); }
.sinfo { flex: none; margin: 1.4rem 0 0 4rem; width: 52rem; }
.sinfo .logo { height: 4.5rem; margin-bottom: .6rem; }
.sinfo .htitle { font-size: 2.3rem; margin-bottom: .5rem; }
.sinfo .ov { -webkit-line-clamp: 2; }

/* ---------- mouse affordances (body.mouse is set by real pointer movement) ---------- */
.row { position: relative; }
.rarrow {
  position: absolute; top: 2.4rem; bottom: 1.3rem; width: 3.8rem; z-index: 3; border: 0; padding: 0;
  display: none; align-items: center; justify-content: center; cursor: pointer;
  font-size: 3.4rem; line-height: 1; color: #fff; opacity: .8;
}
.rarrow.l { left: 0; background: linear-gradient(90deg, rgba(7,7,10,.92), rgba(7,7,10,.4) 70%, transparent); }
.rarrow.r { right: 0; background: linear-gradient(270deg, rgba(7,7,10,.92), rgba(7,7,10,.4) 70%, transparent); }
.rarrow:hover { opacity: 1; color: var(--accent); }
body.mouse .row.can-l .rarrow.l, body.mouse .row.can-r .rarrow.r { display: flex; }
#backBtn { display: none; }
body.mouse:not([data-screen="home"]) #backBtn { display: inline-flex; }
body.mouse[data-screen="player"] #topbar { opacity: 1; z-index: 9; }
#player { cursor: pointer; }
body { touch-action: none; }

/* ---------- cinema mode (body.cinema): shortly after a trailer starts → UI fades reeeal slowly, returns fast ---------- */
:root { --cinema-fade: 20s; --cinema-curve: cubic-bezier(.45, 0, .55, 1); }   /* gentle start, gentle landing */
.screen > * { transition: opacity .35s ease; }
#rows, #frows { transition: transform .45s var(--ease), opacity .35s ease; }
body.cinema .screen > *, body.cinema #topbar, body.cinema #toast { opacity: 0; transition: opacity var(--cinema-fade) var(--cinema-curve); }
body.cinema #rows, body.cinema #frows { transition: transform .45s var(--ease), opacity var(--cinema-fade) var(--cinema-curve); }
body.cinema .vignette { opacity: .3; transition: opacity var(--cinema-fade) var(--cinema-curve); }
body.cinema, body.cinema * { cursor: none !important; }

/* ---------- quick menu (overlay) ---------- */
#menu { z-index: 7; display: flex; align-items: center; justify-content: center; background: rgba(4, 4, 8, .6); backdrop-filter: blur(3px); }
.mpanel { width: 27rem; background: rgba(26, 26, 34, .97); border-radius: 1rem; padding: 1.6rem; box-shadow: 0 1.5rem 4rem rgba(0,0,0,.6); }
.mkind { color: var(--accent); font-size: .85rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.mtitle { font-size: 1.7rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; margin: .3rem 0 1.2rem; }
#mlist { display: flex; flex-direction: column; gap: .5rem; }
.mrow .btn { width: 100%; justify-content: flex-start; }
.mrow .btn.focus { transform: scale(1.02); }
.card.nope:not(.focus) { opacity: .35 !important; }

/* ---------- player ---------- */
#player { background: #000; z-index: 8; }
.pframe { position: absolute; inset: 0; }
.pframe iframe {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(100vw, 177.78vh); height: min(56.25vw, 100vh); border: 0; pointer-events: none;
}
.osd {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6rem 4rem 2.6rem;
  background: linear-gradient(0deg, rgba(0,0,0,.9), transparent); opacity: 0; transition: opacity .4s;
}
#player.osd-on .osd, #player.paused .osd { opacity: 1; }
.ptitle { font-size: 1.8rem; font-weight: 700; margin-bottom: 1rem; }
.bar { height: .35rem; background: rgba(255,255,255,.25); border-radius: 99rem; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s linear; }
.prow { display: flex; justify-content: space-between; margin-top: .7rem; color: var(--dim); font-size: 1rem; font-variant-numeric: tabular-nums; }

/* ---------- splash / toast ---------- */
#splash {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem;
  transition: opacity .6s ease;
}
#splash .brand { font-size: 4rem; }
#splashMsg { color: var(--faint); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
#splash.gone { opacity: 0; pointer-events: none; }
#toast {
  position: fixed; left: 50%; bottom: 3rem; transform: translateX(-50%); z-index: 30;
  background: rgba(30,30,38,.92); backdrop-filter: blur(10px); border-radius: 99rem;
  padding: .8rem 1.8rem; font-size: 1.15rem; font-weight: 600; box-shadow: 0 .6rem 2rem rgba(0,0,0,.5);
}
