:root {
  /* Default Theme: Flixio Dark */
  --bg-color: #050505;
  --surface-color: #141414;
  --accent-color: #E50914; /* Deep Red */
  --text-primary: #FFFFFF;
  --text-secondary: #B3B3B3;
  --transition-speed: 0.3s;
  --card-radius: 8px;
}

/* Theme Presets applied via JS to the <body> tag */
body[data-theme="midnight"] {
  --bg-color: #020813;
  --surface-color: #0B192C;
  --accent-color: #3B82F6; 
}
body[data-theme="cyber"] {
  --bg-color: #0A0A0A;
  --surface-color: #111111;
  --accent-color: #00FF9D; 
}
body[data-theme="crimson"] {
  --bg-color: #1A0505;
  --surface-color: #2D0A0A;
  --accent-color: #FF4444; 
}
body[data-theme="forest"] {
  --bg-color: #040D06;
  --surface-color: #0A1C0E;
  --accent-color: #10B981; 
}
body[data-theme="sunset"] {
  --bg-color: #170800;
  --surface-color: #2E1000;
  --accent-color: #F97316; 
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, sans-serif; }

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Loading Screen */
#loader {
  position: fixed; inset: 0;
  background: var(--bg-color);
  display: flex; justify-content: center; align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}
.flixio-logo { font-size: 3rem; font-weight: 900; letter-spacing: 2px; color: var(--accent-color); }

/* Navigation */
header {
  position: fixed; top: 0; width: 100%;
  padding: 15px 20px;
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
  z-index: 100;
}

/* Horizontal Scroll Rows */
.row { padding: 0 20px; margin-bottom: 30px; }
.row h2 { font-size: 1.2rem; margin-bottom: 10px; font-weight: 600; }
.row-posters {
  display: flex; gap: 10px;
  overflow-y: hidden; overflow-x: scroll;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
}
.row-posters::-webkit-scrollbar { display: none; }
.card {
  flex: 0 0 auto; width: 120px;
  border-radius: var(--card-radius);
  overflow: hidden; cursor: pointer;
  position: relative;
  transition: transform var(--transition-speed);
}
.card:hover { transform: scale(1.05); }
.card img { width: 100%; height: 180px; object-fit: cover; }
.watched-badge {
  position: absolute; top: 5px; right: 5px;
  background: var(--accent-color); font-size: 0.7rem;
  padding: 2px 6px; border-radius: 4px; font-weight: bold;
}

/* Bottom Nav (Mobile) */
.bottom-nav {
  position: fixed; bottom: 0; width: 100%;
  background: var(--surface-color);
  display: flex; justify-content: space-around;
  padding: 15px 0; border-top: 1px solid rgba(255,255,255,0.1);
  z-index: 100;
  transition: transform 0.3s ease;
}
.bottom-nav.hidden { transform: translateY(100%); }
.nav-item { color: var(--text-secondary); text-decoration: none; font-size: 0.8rem; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.nav-item.active { color: var(--accent-color); }

/* Card enhancements: ratings, captions, watched badges */
.card { display: flex; flex-direction: column; }
.card img { border-radius: var(--card-radius); }
.rating-badge {
  position: absolute; top: 5px; left: 5px;
  background: rgba(0,0,0,0.75); color: gold;
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  display: flex; align-items: center; gap: 3px;
}
.rating-badge i { width: 10px; height: 10px; }
.card-caption {
  font-size: 0.75rem; color: var(--text-secondary);
  padding-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-caption .card-year { color: #666; }
.card.no-anim { transition: none !important; }
.card.no-anim:hover { transform: none !important; }
.card.reduced-anim { transition: transform 0.15s ease; }
.card.reduced-anim:hover { transform: scale(1.02); }

/* Loading spinner used across rows */
.row-loading { padding: 30px; text-align: center; color: #888; font-size: 0.85rem; }
.spin { animation: spin-anim 1s linear infinite; }
@keyframes spin-anim { to { transform: rotate(360deg); } }

/* Reduced motion: kill transitions/animations globally */
body.reduced-motion * { animation: none !important; transition: none !important; }

/* Compact mode: tighter cards & spacing */
body.compact-mode .row { margin-bottom: 18px; }
body.compact-mode .card { width: 92px; }
body.compact-mode .card img { height: 138px; }
body.compact-mode .row h2 { font-size: 1rem; margin-bottom: 6px; }

/* Large text mode: scale the ROOT font-size, since virtually every element
   across the app sets its own fixed rem size in its page-local <style>
   block. Setting body{font-size} as em did nothing because em only affects
   direct children that don't already declare their own size, and rem units
   are relative to the <html> root, not body — so it never actually reached
   any of the rem-sized headings/text throughout the site. Scaling :root
   makes every rem value in the entire app grow proportionally. */
html.large-text { font-size: 118%; }
body.large-text .nav-item { font-size: 0.95rem; }

/* No background/cinematic effects */
body.no-bg-effects .hero-banner,
body.no-bg-effects .backdrop { filter: none !important; }
body.no-bg-effects .bg-blur, body.no-bg-effects .grain { display: none !important; }

/* Search density */
.results-grid.density-compact { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }

/* Player overlay */
.player-overlay {
  position: fixed; inset: 0; background: #000; z-index: 5000;
  display: flex; flex-direction: column;
}
.player-topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5001;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
}
.player-close {
  background: rgba(0,0,0,0.6); border-radius: 50%; padding: 8px;
  display: flex; cursor: pointer;
}
.player-server-switch {
  display: flex; gap: 6px;
}
.player-server-switch button {
  background: rgba(255,255,255,0.12); color: #fff; border: none;
  padding: 6px 12px; border-radius: 16px; font-size: 0.75rem; font-weight: 600; cursor: pointer;
}
.player-server-switch button.active { background: var(--accent-color); }
.player-frame-wrap { flex: 1; }