/* ══════════════════════════════════════════════════════════════════════
   CYNEFLIX v217 — NAV MENU + WATCH PAGE REDESIGN
   ────────────────────────────────────────────────────────────────────
   1. NAV — the desktop link row is gone; every destination now lives
      inside the "Browse" panel (Home, Movies, TV Shows, Anime, Manga,
      Music, Watch Party, Watchlist).
   2. WATCH PAGE — cinematic source bar on top, "You're Watching"
      caption over the player, and a title-details rail on the right
      (poster, status, production, aired, title, description, genres,
      trailers, characters).

   Colours, the logo and the Cyneflix name are unchanged — only layout,
   structure and motion are new.
   ══════════════════════════════════════════════════════════════════════ */

/* ═══ 1. NAV ════════════════════════════════════════════════════════ */

/* The inline desktop links are removed from the DOM by js/ui.js.
   This rule is the safety net if a cached page still contains them. */
.nav-links-desktop {
  display: none !important;
}

/* Browse button — slightly larger, matches the new panel */
.nav-browse-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t);
  white-space: nowrap;
  font-family: var(--fb);
}
.nav-browse-btn:hover,
.nav-browse-wrap.open .nav-browse-btn {
  background: rgba(255, 255, 255, .13);
  color: #fff;
  border-color: rgba(255, 255, 255, .24);
}
.nav-browse-btn:active { transform: scale(.97); }
.nav-browse-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Panel — right aligned under the button, never wider than the viewport */
.nav-browse-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(420px, calc(100vw - 24px));
  max-height: min(72vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(12, 12, 12, .97);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .92), 0 4px 18px rgba(0, 0, 0, .6);
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) scale(.98);
  transform-origin: top right;
  transition: opacity .2s ease, transform .24s cubic-bezier(.22, 1, .36, 1);
  z-index: 1200;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .16) transparent;
}
.nav-browse-dropdown.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}
.nav-browse-dropdown::-webkit-scrollbar { width: 5px; }
.nav-browse-dropdown::-webkit-scrollbar-track { background: transparent; }
.nav-browse-dropdown::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 5px; }

.browse-dd-header {
  font-family: var(--fd);
  font-size: 13px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .38);
  padding: 2px 4px 12px;
  text-align: center;
}
.browse-dd-label-v73 {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .3);
  padding: 0 4px 8px;
}

/* Tile grid — 4 columns on desktop, 3 on tablet, 2 on small screens */
.browse-dd-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.browse-dd-icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  padding: 12px 6px 10px;
  border-radius: 13px;
  color: rgba(255, 255, 255, .74);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  text-decoration: none;
  transition: background .22s cubic-bezier(.34, 1.56, .64, 1),
              color .22s ease, border-color .22s ease, transform .22s cubic-bezier(.34, 1.56, .64, 1);
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .06);
  text-align: center;
  min-height: 88px;
}
.browse-dd-icon-item:hover,
.browse-dd-icon-item:focus-visible {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, .16);
  outline: none;
}
.browse-dd-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: box-shadow .22s ease, transform .22s ease;
}
.browse-dd-icon-item:hover .browse-dd-icon-box {
  box-shadow: 0 6px 20px rgba(0, 0, 0, .55);
  transform: scale(1.06);
}
.bdd-home   .browse-dd-icon-box { background: linear-gradient(135deg,#1c1c1e,#2a2a2e); border: 1px solid rgba(255,255,255,.1); }
.bdd-movies .browse-dd-icon-box { background: linear-gradient(135deg,#3a0a0a,#5c1212); border: 1px solid rgba(229,9,20,.28); }
.bdd-series .browse-dd-icon-box { background: linear-gradient(135deg,#2a0a0c,#4a0e12); border: 1px solid rgba(229,9,20,.3); }
.bdd-anime  .browse-dd-icon-box { background: linear-gradient(135deg,#2a0305,#550509); border: 1px solid rgba(240,15,27,.3); }
.bdd-manga  .browse-dd-icon-box { background: linear-gradient(135deg,#2a0a0c,#4a0e12); border: 1px solid rgba(229,9,20,.3); }
.bdd-music  .browse-dd-icon-box { background: linear-gradient(135deg,#2a0a0c,#4a0e12); border: 1px solid rgba(229,9,20,.28); }
.bdd-party  .browse-dd-icon-box { background: linear-gradient(135deg,#2a0a0c,#4a0e12); border: 1px solid rgba(229,9,20,.3); }
.bdd-wl     .browse-dd-icon-box { background: linear-gradient(135deg,#2a0a0c,#4a0e12); border: 1px solid rgba(229,9,20,.3); }

/* Phones: the top bar keeps ONLY the Browse button, so every
   destination stays reachable from the same panel on every device
   (the bottom nav + "More" drawer keep working as before). */
@media (max-width: 768px) {
  .nav-right { display: flex !important; margin-left: auto; }
  .nav-right > *:not(.nav-browse-wrap) { display: none !important; }
  .nav-browse-wrap { display: block !important; }
  .nav-browse-btn { height: 36px; padding: 0 12px; }
  .nav-browse-dropdown {
    position: fixed;
    top: calc(var(--nav-h) + 6px);
    right: 10px;
    left: auto;
    width: min(420px, calc(100vw - 20px));
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* Tablet */
@media (max-width: 1100px) {
  .browse-dd-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Small screens */
@media (max-width: 560px) {
  .nav-browse-dropdown { width: min(320px, calc(100vw - 20px)); padding: 12px; }
  .browse-dd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .browse-dd-icon-item { min-height: 80px; padding: 10px 4px 8px; }
}

/* ═══ 2. WATCH PAGE ═════════════════════════════════════════════════ */

/* ── Layout: source bar on top, player + details rail below ───── */
#watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  align-items: start;
}
@media (min-width: 1080px) {
  #watch-layout {
    grid-template-columns: minmax(0, 1fr) 348px;
    column-gap: 0;
  }
  #watch-main { grid-column: 1; grid-row: 1; }
  #watch-side { grid-column: 2; grid-row: 1; }
}

/* The body is a scroll container (overflow-x:hidden turns overflow-y into
   "auto"), which silently kills every position:sticky inside it. On the watch
   page the sticky source bar + sticky details rail must work, so the body
   keeps its overflow visible (the <html> still clips horizontal overflow). */
body.watch-page {
  overflow-x: clip;
  overflow-y: visible;
}

/* ── Source bar (v217) ─────────────────────────────────────────── */
.srv-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 0 0 0 var(--px);
  margin-bottom: 2px;
  background: linear-gradient(180deg, rgba(10, 10, 10, .96), rgba(10, 10, 10, .72));
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  position: sticky;
  /* #main-nav is fixed and the page already reserves its height in normal flow.
     The sticky scrollport begins below that reserved nav area, so a second
     var(--nav-h) offset shifts this bar down over the player. */
  top: 0;
  z-index: 60;
  will-change: transform;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.srv-bar-scroll {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.srv-bar-scroll::-webkit-scrollbar { display: none; }

.srv-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 13px;
  background: none;
  border: 0;
  color: rgba(255, 255, 255, .48);
  font-family: var(--fb);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s ease, background .2s ease;
}
.srv-tab:hover { color: rgba(255, 255, 255, .82); background: rgba(255, 255, 255, .04); }
.srv-tab::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .26s cubic-bezier(.22, 1, .36, 1);
}
.srv-tab.active { color: #fff; }
.srv-tab.active::after { transform: scaleX(1); }
.srv-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.srv-tab-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 19px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .2px;
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .6);
  transition: background .2s ease, color .2s ease;
}
.srv-tab.active .srv-tab-num {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(229, 9, 20, .45);
}
.srv-tab-name { display: inline-block; }
.srv-tab-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, .35);
}
.srv-tab.active .srv-tab-sub { color: rgba(255, 255, 255, .55); }

.srv-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--px) 0 12px;
  flex: 0 0 auto;
}
.srv-bar-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .05);
  color: rgba(255, 255, 255, .55);
  white-space: nowrap;
}
.srv-bar-badge--shield { color: rgba(221,60,68, .85); border-color: rgba(221,60,68, .28); background: rgba(221,60,68, .08); }
.srv-bar-info {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .5);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s ease;
}
.srv-bar-info:hover { color: #fff; border-color: rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .1); }
@media (max-width: 760px) {
  .srv-bar-badge--shield { display: none; }
  .srv-tab { padding: 12px 12px 11px; font-size: 12px; }
}
/* Phones: all three source tabs must fit without being cut off */
@media (max-width: 560px) {
  .srv-bar { gap: 4px; }
  .srv-bar-badge { display: none; }
  .srv-bar-right { padding: 0 8px 0 2px; }
  .srv-tab { padding: 12px 8px 11px; font-size: 11.5px; gap: 6px; }
  .srv-tab-num { min-width: 19px; height: 18px; padding: 0 5px; font-size: 10px; }
  .srv-bar-info { width: 26px; height: 26px; }
}

/* ── "You're watching" caption over the player ───────────────── */
.player-shell {
  position: relative;
  width: 100%;
}
.player-cap {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 20px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .58), rgba(0, 0, 0, .28));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: none;
  text-align: center;
  max-width: min(88%, 520px);
  animation: v217-cap-in .6s cubic-bezier(.22, 1, .36, 1) both;
}
.player-cap-kicker {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .58);
}
.player-cap-title {
  font-family: var(--fd);
  font-size: clamp(16px, 2.4vw, 25px);
  letter-spacing: .6px;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
@keyframes v217-cap-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) }
}
@media (max-width: 640px) {
  .player-cap { top: 8px; padding: 5px 12px; border-radius: 9px; }
  .player-cap-kicker { font-size: 9px; letter-spacing: 1.4px; }
  .player-cap-title { font-size: 15px; }
}

/* ── Title details rail ───────────────────────────────────────── */
#watch-side {
  display: none;
  position: sticky;
  top: calc(var(--nav-h) + 54px);
  max-height: calc(100vh - var(--nav-h) - 54px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 18px 28px;
  background: linear-gradient(180deg, #0d0d0d, #0a0a0a);
  border-left: 1px solid rgba(255, 255, 255, .07);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .14) transparent;
}
#watch-side::-webkit-scrollbar { width: 5px; }
#watch-side::-webkit-scrollbar-track { background: transparent; }
#watch-side::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 5px; }
@media (min-width: 1080px) {
  #watch-side { display: block; }
}

.ws-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.ws-poster {
  position: relative;
  flex: 0 0 108px;
  width: 108px;
  border-radius: 12px;
  overflow: hidden;
  background: #141414;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .8);
  aspect-ratio: 2 / 3;
}
.ws-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ws-rating {
  position: absolute;
  top: 6px; right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 800;
  color: #f11c27;
  background: rgba(0, 0, 0, .74);
  border: 1px solid rgba(241,28,39, .3);
  backdrop-filter: blur(6px);
}
.ws-rows {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-row { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.ws-k {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .32);
}
.ws-v { color: rgba(255, 255, 255, .82); font-weight: 600; line-height: 1.4; }
.ws-title {
  font-family: var(--fd);
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: .4px;
  color: #fff;
  margin: 18px 0 0;
}
.ws-desc {
  margin: 14px 0 0;
  padding: 13px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .055);
  font-size: 12.5px;
  line-height: 1.62;
  color: rgba(255, 255, 255, .62);
}
.ws-genres { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ws-chip {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .3px;
  color: rgba(255, 255, 255, .78);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
}
.ws-sec { margin-top: 22px; }
.ws-sec-h {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .42);
  margin: 0 0 10px;
}
.ws-sec-h span { font-size: 10.5px; color: rgba(255, 255, 255, .28); letter-spacing: .4px; }
.ws-trailer {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .85);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  text-decoration: none;
}
.ws-trailer:hover { background: rgba(229, 9, 20, .16); border-color: rgba(229, 9, 20, .4); color: #fff; }
.ws-chars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; }
.ws-char { text-align: center; }
.ws-char img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  background: #161616;
  border: 1px solid rgba(255, 255, 255, .07);
  display: block;
}
.ws-char-name {
  display: block;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, .72);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-char-role {
  display: block;
  font-size: 9.5px;
  color: rgba(255, 255, 255, .34);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Cast strip: keep long names inside their chip (fixes legacy
      -webkit-box + nowrap overflow that made names run together) ── */
.cast-name,
.cast-char {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: unset;
}

/* ── Main column vs. details rail (wide screens) ─────────────────
   The rail already shows poster · rating · status · title · description ·
   genres, so the duplicated block in the main column is hidden there.
   The <h1> stays in the DOM (visually hidden) for SEO / a11y. */
@media (min-width: 1080px) {
  .watch-header { display: block; }
  .watch-poster { display: none !important; }
  .watch-meta,
  .watch-overview { display: none !important; }
  #watch-title {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .watch-detail { width: 100%; }
  .watch-info { padding-top: 4px; }
}

/* The episode list lives under the player on wide screens now */
@media (min-width: 1080px) {
  #ep-section {
    display: block !important;
    padding: 18px var(--px) 10px !important;
  }
  #ep-sidebar { display: none !important; }
}
@media (min-width: 900px) and (max-width: 1079px) {
  #ep-sidebar.ep-sidebar--active { display: flex !important; }
}
