/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: var(--z-header);
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-base) var(--ease);
}
.header.is-scrolled { border-bottom-color: var(--border); }

/* Over the hero: transparent with a soft top shade, turns solid after scrolling */
.header--overlay { position: fixed; inset-inline: 0; background: transparent; transition: background-color var(--dur-slow) var(--ease), border-color var(--dur-slow) var(--ease); }
.header--overlay::before { content: ""; position: absolute; inset: 0 0 -40px; z-index: -1; pointer-events: none; background: linear-gradient(to bottom, rgba(0, 0, 0, .7), rgba(0, 0, 0, 0)); transition: opacity var(--dur-slow) var(--ease); }
.header--overlay.is-scrolled { background: var(--bg); }
.header--overlay.is-scrolled::before { opacity: 0; }
.header--overlay:not(.is-scrolled) .nav__link { color: rgba(255, 255, 255, .78); }
.header--overlay:not(.is-scrolled) .nav__link:hover,
.header--overlay:not(.is-scrolled) .nav__link[aria-current="page"],
.header--overlay:not(.is-scrolled) .nav__item.is-open > .nav__link { color: #fff; background: rgba(255, 255, 255, .1); }
.header--overlay:not(.is-scrolled) .icon-btn { color: rgba(255, 255, 255, .85); }
.header--overlay:not(.is-scrolled) .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.header--overlay:not(.is-scrolled) .logo__name { color: #fff; }
.header--overlay:not(.is-scrolled) .header-search .input { background: rgba(0, 0, 0, .35); border-color: rgba(255, 255, 255, .18); color: #fff; }
.header--overlay:not(.is-scrolled) .header-search .input::placeholder { color: rgba(255, 255, 255, .6); }
.header--overlay:not(.is-scrolled) .btn--secondary { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .2); color: #fff; }
.header--overlay:not(.is-scrolled) .icon-btn .dot { border-color: transparent; }
.header__inner { height: 100%; display: flex; align-items: center; gap: var(--sp-6); }

/* Logo */
.logo { display: inline-flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.logo__mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.logo__mark svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.logo__name { font-size: 20px; font-weight: 800; letter-spacing: -.2px; }

/* Primary nav */
.nav { display: flex; align-items: center; gap: var(--sp-1); height: 100%; }
.nav__item { position: relative; height: 100%; display: flex; align-items: center; }
.nav__link {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  height: 40px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-md); background: none;
  color: var(--text-2); font-size: var(--fs-14); font-weight: 500;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.nav__link:hover, .nav__item.is-open > .nav__link { color: var(--text-1); background: var(--surface-1); }
.nav__link[aria-current="page"] { color: var(--text-1); font-weight: 700; }
.nav__link .chev { width: 14px; height: 14px; transition: transform var(--dur-base) var(--ease); }
.nav__item.is-open .chev { transform: rotate(180deg); }

/* Mega menu */
.mega {
  position: absolute; top: calc(100% - 6px); inset-inline-start: 0;
  width: 640px; padding: var(--sp-5);
  display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--sp-5);
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, .55);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), visibility 0s linear var(--dur-base);
}
.nav__item.is-open .mega { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.mega__title { font-size: var(--fs-12); font-weight: 700; color: var(--text-3); margin-bottom: var(--sp-2); }
.mega__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mega__list--cols { grid-template-columns: 1fr 1fr; column-gap: var(--sp-3); }
.mega__list a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: 6px var(--sp-2); margin-inline: calc(var(--sp-2) * -1); border-radius: var(--r-sm);
  font-size: var(--fs-14); color: var(--text-1);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.mega__list a:hover { background: var(--surface-2); color: var(--accent-text); }
.mega__list small { color: var(--text-3); font-size: var(--fs-12); }
.mega__foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding-top: var(--sp-4); border-top: 1px solid var(--border); font-size: var(--fs-13); color: var(--text-2); }
.mega__foot a { color: var(--accent-text); font-weight: 700; display: inline-flex; align-items: center; gap: var(--sp-1); }

/* Actions (search, icons, login) */
.header__actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }
.header-search { position: relative; width: 300px; }
.header-search .input { height: 40px; font-size: var(--fs-14); padding-inline-end: 64px; background: var(--surface-1); border-color: var(--border); }
.header-search .input:hover { border-color: var(--border-strong); }
.header-search kbd {
  position: absolute; inset-inline-end: var(--sp-3); top: 50%; transform: translateY(-50%);
  font-family: var(--font); font-size: 11px; color: var(--text-3);
  border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 6px; line-height: 20px; unicode-bidi: isolate;
}
.icon-btn {
  position: relative; width: 40px; height: 40px; border: 0; border-radius: var(--r-md);
  display: inline-grid; place-items: center; background: none; color: var(--text-2);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--surface-1); color: var(--text-1); }
.icon-btn .dot {
  position: absolute; top: 9px; inset-inline-end: 10px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); box-sizing: content-box;
}

/* Popover (notifications, theme) */
.pop-wrap { position: relative; }
.popover {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: 340px;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, .55);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), visibility 0s linear var(--dur-base);
}
.popover.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.popover__head { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.popover__head b { font-size: var(--fs-14); }
.popover__head button { background: none; border: 0; color: var(--accent-text); font-size: var(--fs-12); font-weight: 700; }
.notif { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); transition: background-color var(--dur-fast) var(--ease); }
.notif:hover { background: var(--surface-2); }
.notif:last-of-type { border-bottom: 0; }
.notif__thumb { width: 40px; height: 56px; border-radius: var(--r-sm); background: var(--surface-3); flex-shrink: 0; }
.notif__body { min-width: 0; font-size: var(--fs-13); line-height: 1.6; }
.notif__body b { display: block; font-size: var(--fs-14); }
.notif__body span { color: var(--text-2); }
.notif__body small { display: block; color: var(--text-3); font-size: var(--fs-12); margin-top: 2px; }
.notif.is-unread .notif__body b::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-inline-end: 6px; vertical-align: middle; }
.popover__foot { display: block; text-align: center; padding: var(--sp-3); font-size: var(--fs-13); font-weight: 700; color: var(--text-2); border-top: 1px solid var(--border); }
.popover__foot:hover { color: var(--text-1); }

.theme-pop { width: 220px; padding: var(--sp-2); }
.theme-opt { width: 100%; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 0; border-radius: var(--r-md); background: none; color: var(--text-1); font-size: var(--fs-14); text-align: start; }
.theme-opt:hover { background: var(--surface-2); }
.theme-opt i { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; }
.theme-opt .icon { margin-inline-start: auto; color: var(--accent-text); visibility: hidden; }
.theme-opt[aria-checked="true"] .icon { visibility: visible; }

/* Mobile-only controls */
.header__mobile { display: none; }

/* ---------- Drawer (mobile menu) ---------- */
.scrim { position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--overlay); opacity: 0; visibility: hidden; transition: opacity var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow); }
.scrim.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: var(--z-drawer);
  width: min(320px, 86vw); background: var(--surface-1); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; transform: translateX(100%); visibility: hidden;
  transition: transform var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow);
}
.drawer.is-open { transform: none; visibility: visible; transition-delay: 0s; }
.drawer__head { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-5); }
.drawer__link, .drawer__acc > button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: 48px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-md); background: none;
  color: var(--text-1); font-size: var(--fs-16); font-weight: 500; text-align: start;
}
.drawer__link:hover, .drawer__acc > button:hover { background: var(--surface-2); }
.drawer__link[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
.drawer__acc > button .chev { width: 18px; height: 18px; color: var(--text-3); transition: transform var(--dur-base) var(--ease); }
.drawer__acc > button[aria-expanded="true"] .chev { transform: rotate(180deg); }
.drawer__sub { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: var(--sp-1) var(--sp-3) var(--sp-3); }
.drawer__sub a { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-14); color: var(--text-2); }
.drawer__sub a:hover { background: var(--surface-2); color: var(--text-1); }
.drawer__sep { height: 1px; background: var(--border); margin: var(--sp-3) var(--sp-3); }
.drawer__label { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-12); font-weight: 700; color: var(--text-3); }
.drawer__themes { display: flex; gap: var(--sp-2); padding: 0 var(--sp-3); }
.drawer__themes button { flex: 1; height: 40px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-13); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.drawer__themes button i { width: 12px; height: 12px; border-radius: 50%; }
.drawer__themes button[aria-checked="true"] { border-color: var(--accent); color: var(--text-1); }
.drawer__foot { padding: var(--sp-4); border-top: 1px solid var(--border); }

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar { display: none; }

@media (max-width: 1180px) {
  .header-search { width: 220px; }
  .nav__item--wide { display: none; }
}

@media (max-width: 960px) {
  :root { --header-h: 56px; }
  .nav, .header-search, .header__actions .hide-mobile { display: none; }
  .header__inner { gap: var(--sp-3); }
  .header__mobile { display: inline-grid; }
  .logo__name { font-size: 19px; }
  .tabbar {
    position: fixed; inset: auto 0 0; z-index: var(--z-header);
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface-1); border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none; color: var(--text-3); font-size: 11px; font-weight: 500;
    transition: color var(--dur-fast) var(--ease);
  }
  .tabbar .icon { width: 22px; height: 22px; }
  .tabbar [aria-current="page"] { color: var(--accent-text); font-weight: 700; }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
}

/* ---------- Footer ---------- */
.footer { margin-top: var(--sp-8); border-top: 1px solid var(--border); background: var(--surface-1); }
.footer__grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: var(--sp-6); padding-block: var(--sp-7) var(--sp-6); }
.footer__brand p { margin-top: var(--sp-3); max-width: 40ch; font-size: var(--fs-14); color: var(--text-2); }
.footer__trust { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.footer__trust span { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--sp-3); border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-12); font-weight: 700; color: var(--text-2); }
.footer__trust .icon { color: var(--accent-text); }
.footer__col h3 { font-size: var(--fs-14); margin-bottom: var(--sp-3); }
.footer__col a { display: block; padding: 5px 0; font-size: var(--fs-14); color: var(--text-2); transition: color var(--dur-fast) var(--ease); }
.footer__col a:hover { color: var(--accent-text); }
.footer__bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); padding-block: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); font-size: var(--fs-12); color: var(--text-3); }
.footer__tmdb a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 960px) {
  .footer__grid { grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); padding-block: var(--sp-6) var(--sp-5); }
  .footer__brand { grid-column: 1 / -1; }
}
@media (max-width: 480px) { .footer__grid { grid-template-columns: repeat(2, 1fr); } }

/* account button in the header */
.hdr-account.is-user { display: inline-flex; align-items: center; gap: var(--sp-2); padding-inline: 6px var(--sp-3); }
.hdr-account img, .hdr-account .hdr-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.hdr-account .hdr-avatar { display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 800; }
.drawer__foot .hdr-account.is-user { justify-content: center; }
@media (max-width: 1180px) { .header__actions [data-plans-cta].hide-mobile { display: none; } }

/* site announcement (set in admin settings) */
.announce { position: fixed; z-index: 45; bottom: var(--sp-5); left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); background: var(--accent); color: var(--on-accent); font-size: var(--fs-14); font-weight: 700; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .6); }
.announce span { flex: 1; }
.announce button { width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .18); color: inherit; font-size: 18px; line-height: 1; }
@media (max-width: 960px) { .announce { bottom: calc(72px + env(safe-area-inset-bottom)); } }
