@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --bg-primary: #0a0d14;
  --bg-secondary: #121826;
  --bg-card: #182234;
  --accent-primary: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.35);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: #f3f4f6;
  overflow-x: hidden;
}

/* Hard guard against horizontal leaks on small screens.
   `clip` (unlike `hidden`) keeps position:sticky working. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

@supports not (overflow: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}

/* Custom modern scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #0d111a;
}

::-webkit-scrollbar-thumb {
  background: #27354a;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

/* Glassmorphism */
.glass-panel {
  background: rgba(18, 24, 38, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-nav {
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

/* Movie Card Poster Aspect Ratio */
.aspect-poster {
  aspect-ratio: 2 / 3;
}

.aspect-backdrop {
  aspect-ratio: 16 / 9;
}

/* Line clamps */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Long episode/playlist rows: skip rendering off-screen rows.
   Big win on series pages with hundreds of episodes. */
.episode-row {
  content-visibility: auto;
  contain-intrinsic-size: auto 64px;
}

/* SubtitlesOctopus (ASS) overlay canvas */
.libassjs-canvas-parent {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
  z-index: 10 !important;
}

.libassjs-canvas {
  pointer-events: none !important;
  z-index: 10 !important;
}

.player-container:fullscreen .libassjs-canvas-parent,
.player-container:-webkit-full-screen .libassjs-canvas-parent {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
  z-index: 2147483647 !important;
}

/* Container-level fullscreen: fill the screen, video keeps aspect */
.player-container:fullscreen,
.player-container:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  background: #000 !important;
}

.player-container:fullscreen video,
.player-container:-webkit-full-screen video {
  width: 100% !important;
  height: 100% !important;
  max-height: 100vh !important;
}

/* Native <track> cue styling (VTT subtitles, incl. fullscreen) */
#main-video-player::cue {
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  border-radius: 4px;
}

.player-container:fullscreen #main-video-player::cue,
.player-container:-webkit-full-screen #main-video-player::cue {
  font-size: 1.4rem;
}

/* Hide scrollbars while keeping scrollability (filter pills, etc.) */
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}

/* Slim scrollbars (episode sidebar, etc.) */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: #27354a #0d111a;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: #0d111a;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: #27354a;
  border-radius: 9999px;
}

/* Readability shadow over hero/backdrop images */
.text-shadow {
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

/* Custom in-player control buttons */
.player-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px;
  border-radius: 8px;
  color: #e2e8f0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.player-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.player-menu-btn.active {
  background: rgba(99, 102, 241, 0.4);
  color: #fff;
}

.player-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  border-radius: 8px;
  transition: background 0.12s;
}

/* In-player settings popup.
   Phones: fixed bottom-sheet over the whole screen — the inline portrait
   player is far too short for a floating panel, and `fixed` escapes the
   player's overflow clipping (also works inside fullscreen, where the
   fullscreen element contains it).
   Tablets/desktops: small floating panel anchored near the opener. */
#player-menu {
  position: fixed;
  z-index: 60;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#player-menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.6);
}

#player-menu .player-menu-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  background: rgba(15, 23, 42, 0.97);
  border-bottom: 1px solid rgba(51, 65, 85, 0.8);
}

@media (min-width: 768px) {
  #player-menu {
    position: absolute;
    left: auto;
    right: 8px;
    width: 240px;
    top: auto;
    bottom: auto;
    max-height: 288px;
    border-radius: 12px;
    padding-bottom: 0;
  }

  #player-menu.menu-top {
    top: 56px;
  }

  #player-menu.menu-bottom {
    bottom: 80px;
  }

  #player-menu-scrim {
    display: none;
  }
}

.player-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.player-menu-item.active {
  background: rgba(99, 102, 241, 0.25);
  color: #fff;
}

#player-seekbar:active {
  cursor: grabbing;
}

/* Double-tap skip flash (touch gesture feedback) */
.skip-flash {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scale(0.85);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 64px;
  height: 64px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.skip-flash.show {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Caption strip for native VTT subtitles: sits above the control bar
   while it is visible, drops to the bottom edge when it hides. */
#player-caption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(14px + var(--pic-gap, 0px));
  z-index: 15;
  text-align: center;
  pointer-events: none;
  transition: bottom 0.3s;
}

#player-caption:empty {
  display: none;
}

#player-caption .cap {
  display: inline-block;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: clamp(13px, 2.4vmin, 19px);
  font-weight: 600;
  line-height: 1.45;
}

.player-container.controls-shown #player-caption {
  bottom: calc(88px + var(--pic-gap, 0px));
}

/* Lift the ASS canvas by the same amount so styled subs clear the bar too */
.libassjs-canvas-parent {
  transition: transform 0.3s;
}

.player-container.controls-shown .libassjs-canvas-parent {
  transform: translateY(-68px);
}

/* Card hover animation */
.movie-card {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.movie-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 30px -10px rgba(0, 0, 0, 0.7), 0 0 20px -5px var(--accent-glow);
}

/* Shimmer Skeleton */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #182234 25%, #233149 50%, #182234 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite;
}

/* Video Player Wrapper */
.player-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 40px -15px rgba(0,0,0,0.8);
}

.player-container video {
  width: 100%;
  height: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
}

.hero-slide {
  will-change: opacity;
}

.hero-content {
  animation: modalFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hero Background Gradient Overlay */
.hero-gradient {
  background: linear-gradient(0deg, #0a0d14 0%, rgba(10, 13, 20, 0.8) 40%, rgba(10, 13, 20, 0.2) 100%);
}

.hero-gradient-side {
  background: linear-gradient(90deg, #0a0d14 0%, rgba(10, 13, 20, 0.85) 45%, rgba(10, 13, 20, 0) 100%);
}

#toast-container {
  isolation: isolate;
}

#toast-container > div {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Modal animation */
.modal-enter {
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
