/* Series player — Netflix-style, embed-first */
:root {
  --bg: #000;
  --panel: #141414;
  --panel-2: #1a1a1a;
  --ink: #fff;
  --muted: #b3b3b3;
  --line: rgba(255, 255, 255, 0.12);
  /* Match player.css — series :root was overriding controls to Netflix red */
  --accent: #ff9000;
  --accent-hi: #ffa42a;
  --accent-soft: rgba(255, 144, 0, 0.18);
  --brand: #ff9000;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --rail-w: min(360px, 100%);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  max-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
/* Fill iframe / mobile viewport without scroll jank */
html.is-embed-root,
body.is-series-demo {
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  overscroll-behavior: none;
}
@supports (height: 100dvh) {
  html.is-embed-root,
  body.is-series-demo {
    height: 100dvh !important;
    max-height: 100dvh !important;
  }
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden;
}

/* Series icons sit in .embed-chrome-top — inherit the same idle fade as title */
body.is-series-demo .embed-chrome-top {
  padding: 14px 14px 48px;
  padding-right: 96px; /* hamburger + copy */
}
body.is-series-demo .embed-chrome-top:has(#btnHomeBack:not([hidden])) {
  padding-left: 10px;
  gap: 10px;
}
body.is-series-demo .embed-title {
  max-width: 100%;
}
/* Idle: don't leave a clickable home hit-target */
.player.is-playing.idle .embed-back {
  pointer-events: none !important;
}
.player.rail-open .embed-back,
.shell.rail-drawer.rail-open .embed-back {
  pointer-events: auto !important;
}
.series-chrome {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
.series-chrome > * { pointer-events: auto; }
/* Idle: don't leave invisible icon hit-targets */
.player.is-playing.idle .series-chrome,
.player.is-playing.idle .series-chrome > * {
  pointer-events: none !important;
}
/* Keep title+icons while browsing the episodes drawer */
.player.rail-open .embed-chrome-top,
.shell.rail-drawer.rail-open .embed-chrome-top {
  opacity: 1 !important;
  transform: none !important;
}
.player.rail-open .series-chrome > *,
.shell.rail-drawer.rail-open .series-chrome > * {
  pointer-events: auto !important;
}
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 13, 18, 0.55);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.icon-btn.is-on {
  background: var(--accent);
  border-color: transparent;
}

/* Real player fills stage (override embed 100vh sizing) */
body.is-series-demo .watch-main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex;
  flex-direction: column;
}
body.is-series-demo .player-band,
body.is-series-demo .player-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100% !important;
  height: 100% !important;
}
body.is-series-demo .player {
  position: relative;
  flex: 1 1 auto;
  min-height: 160px !important;
  height: 100% !important;
  width: 100% !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  overflow: hidden;
}

/* Layout — player full-bleed; episode rail overlays (never side-resize) */
.shell {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 0;
  min-width: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail-scrim {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 45;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.shell.rail-open > .rail-scrim,
#player.rail-open > .rail-scrim {
  display: block;
}

/* Ep nav — Netflix-style row above seek, same inset as .crow */
body.is-series-demo .controls {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 40px 12px 10px;
}
.controls > .series-ep-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0 0 2px;
  padding: 0;
  flex: 0 0 auto;
  pointer-events: auto;
}
.ep-nav-spacer { flex: 1 1 auto; min-width: 8px; }
.ep-nav-btn {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  background: rgba(10, 13, 18, 0.38);
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
  box-shadow: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ep-nav-btn:hover {
  background: rgba(10, 13, 18, 0.55);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.ep-nav-btn.ep-nav-next {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
  font-weight: 700;
}
.ep-nav-btn.ep-nav-next:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.4);
}
.ep-nav-btn.is-disabled {
  opacity: 0.28;
  pointer-events: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.is-series-demo .controls > .progress-wrap {
  margin-top: 0;
}
body.is-series-demo .controls > .crow {
  margin-top: 2px;
}
@media (max-width: 420px) {
  .ep-nav-btn { padding: 6px 11px; font-size: 0.75rem; }
}

/* Episode rail — overlay panel on the player */
.rail {
  display: none;
  background: var(--panel);
  border-left: 1px solid var(--line);
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.shell.rail-open > .rail,
#player.rail-open > .rail {
  display: flex;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 92vw);
  max-width: 100%;
  z-index: 50;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.55);
}
#player > .rail {
  display: none;
}
#player.rail-open > .rail {
  display: flex;
}
/* Full-bleed drawer on narrow portrait */
@media (orientation: portrait) and (max-width: 520px) {
  .shell.rail-open > .rail,
  #player.rail-open > .rail {
    width: 100%;
    max-width: 100%;
    border-left: 0;
  }
}
/* Short iframe / landscape phone: keep player usable */
@media (max-height: 420px) {
  body.is-series-demo .player {
    min-height: 120px !important;
  }
  .icon-btn {
    width: 32px;
    height: 32px;
  }
  body.is-series-demo .embed-title {
    font-size: 14px;
  }
}

.rail-tabs {
  display: flex;
  flex: 0 0 auto;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}
.rail-tabs [role="tab"] {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 12px 8px;
  cursor: pointer;
}
.rail-tabs [role="tab"].is-on {
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.rail-close {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  align-self: center;
  width: 32px;
  height: 32px;
  margin: 0 8px 0 2px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.rail-close:hover { background: rgba(255, 255, 255, 0.2); }

.rail-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.rail-panel[hidden] { display: none !important; }

.rail-head {
  flex: 0 0 auto;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
}
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.chips .chip {
  flex: 0 0 auto;
  padding: 6px 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}
.chips .chip.is-on,
.chips .chip:hover {
  background: #fff;
  color: #111;
  border-color: #fff;
}
.season-now {
  margin: 8px 0 0;
  display: flex;
  align-items: baseline;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.season-now strong {
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.season-now-sep { opacity: 0.55; flex-shrink: 0; }
.season-now > span:last-child { flex-shrink: 0; }

.rail-list {
  flex: 1;
  overflow: auto;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}

/* Seasons tab cards — portrait poster thumb (TMDB season posters are 2:3) */
.season-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel-2);
}
.season-card:hover { border-color: rgba(255,255,255,.18); }
.season-card.is-on {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-soft);
}
.season-art {
  width: 72px;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  background: #222 center / cover no-repeat;
  flex-shrink: 0;
}
.season-body { min-width: 0; padding-top: 2px; }
.season-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
  line-height: 1.25;
}
.season-body p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.season-meta {
  color: #ddd;
  font-size: 0.72rem;
  font-weight: 700;
}

.ep {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px 8px;
  border-radius: 6px;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.ep.has-still {
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: center;
}
.ep-still {
  width: 88px;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  background: #1a1a1a center / cover no-repeat;
  flex-shrink: 0;
}
.ep:hover { background: rgba(255,255,255,.06); }
.ep.is-on {
  background: rgba(255,255,255,.1);
  border-color: transparent;
}
.ep .n {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: right;
  padding-top: 1px;
}
.ep.is-on .n {
  color: #fff;
  font-weight: 600;
}
.ep .ep-num {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}
.ep.is-on .ep-num { color: rgba(255, 255, 255, 0.75); }
.ep h3 {
  margin: 0 0 2px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}
.ep p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ep .rt {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-top: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(10px);
  background: #fff;
  color: #111;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
