/* ============================================
   Reelix.tv — Master Stylesheet v2
   Single source of truth for ALL pages.
   index.html / browse.html / search.html / watch.html
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&family=DM+Serif+Display:ital@0;1&display=swap');

/* ══════════════════════════════════════════
   TOKENS
══════════════════════════════════════════ */
:root {
  --bg:          #0a0b0f;
  --bg-card:     #111318;
  --bg-elevated: #181b22;
  --border:      rgba(255,255,255,0.07);
  --text:        #e8e8f0;
  --text-muted:  #7a7a9a;
  --text-faint:  #3a3a55;
  --accent:      #e5173a;
  --accent-dim:  rgba(229,23,58,0.15);
  --accent-glow: rgba(229,23,58,0.4);
  --blue:        #4a8fff;
  --nav-h:       68px;
  --radius:      8px;
  --radius-lg:   14px;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.5);
  --trans:       0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ══════════════════════════════════════════
   RESET
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Film grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: .025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}

/* Skip-to-content — keyboard / screen readers */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}
.skip-link:focus { left: 16px; }

/* Global focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ══════════════════════════════════════════
   NAV
   — No hamburger. 3 pages only (Home, Browse + icon).
   — Search handled entirely by the icon; no text link.
   — CTA hides on mobile to save space; links compress inline.
══════════════════════════════════════════ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 clamp(16px, 4vw, 48px);
  gap: 24px;
  transition: background var(--trans), backdrop-filter var(--trans);
}
.nav.scrolled {
  background: rgba(10,11,15,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.nav-logo-mark {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  color: #fff;
  letter-spacing: 0.5px;
}
.nav-logo-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--text);
}
.nav-logo-text span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.nav-link {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--trans), background var(--trans);
  white-space: nowrap;
}
.nav-link:hover,
.nav-link.active { color: var(--text); background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--accent); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}
.nav-search-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: color var(--trans), background var(--trans);
}
.nav-search-btn:hover { color: var(--text); background: rgba(255,255,255,0.08); }

.nav-cta {
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: opacity var(--trans), transform var(--trans);
}
.nav-cta:hover { opacity: 0.88; transform: translateY(-1px); }

/* Mobile — inline links, no hamburger, no dropdown */
@media (max-width: 768px) {
  .nav { gap: 0; padding: 0 12px; }
  .nav-logo { margin-right: auto; }
  .nav-links { flex: none; gap: 0; }
  .nav-link { padding: 6px 10px; font-size: 13px; }
  .nav-cta { display: none; }
  .nav-actions { gap: 4px; margin-left: 8px; }
}
@media (max-width: 380px) {
  .nav-link { padding: 6px 7px; font-size: 12px; }
}

/* ══════════════════════════════════════════
   FOOTER
══════════════════════════════════════════ */
footer {
  margin-top: 80px;
  border-top: 1px solid var(--border);
  padding: 48px clamp(16px, 4vw, 48px) 32px;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 40px;
}
.footer-brand .nav-logo { margin-bottom: 14px; }
.footer-brand p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 240px;
}
.footer-col h4 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 16px;
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.footer-col a { font-size: 14px; color: var(--text-muted); transition: color var(--trans); }
.footer-col a:hover { color: var(--text); }
.footer-bottom {
  max-width: 1400px;
  margin: 32px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-bottom p { font-size: 12px; color: var(--text-faint); }
.footer-accent { color: var(--accent); }

@media (max-width: 900px) { .footer-inner { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) {
  .footer-inner { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; text-align: center; }
}

/* ══════════════════════════════════════════
   LAYOUT UTILITIES
══════════════════════════════════════════ */
.page-wrap { padding-top: var(--nav-h); min-height: 100vh; }
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px);
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(20px, 2.5vw, 26px);
  font-weight: 400;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: '';
  display: block;
  width: 3px; height: 22px;
  background: var(--accent);
  border-radius: 2px;
}
.section-link { font-size: 13px; font-weight: 500; color: var(--text-muted); transition: color var(--trans); }
.section-link:hover { color: var(--accent); }

/* ══════════════════════════════════════════
   STATS BAR
══════════════════════════════════════════ */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 32px;
  margin-bottom: 60px;
  position: relative;
  overflow: hidden;
}
.stats-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(to right, transparent, var(--accent), transparent);
}
.stat-item { text-align: center; }
.stat-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 38px;
  letter-spacing: 1px;
  color: var(--accent);
  line-height: 1;
}
.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.stat-div { width: 1px; height: 44px; background: var(--border); }
@media (max-width: 500px) { .stat-div { display: none; } }

/* ══════════════════════════════════════════
   MOVIE CARDS
══════════════════════════════════════════ */

/* Grid (browse page) */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

/* Scroll row */
.movie-row-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.movie-row-scroll::-webkit-scrollbar { height: 3px; }
.movie-row-scroll .movie-card { flex-shrink: 0; width: 140px; }
@media (min-width: 480px) { .movie-row-scroll .movie-card { width: 160px; } }
@media (min-width: 600px) { .movie-row-scroll .movie-card { width: 180px; } }
@media (min-width: 1024px) { .movie-row-scroll .movie-card { width: 200px; } }

/* Row arrow buttons — desktop hover, hidden on touch */
.row-outer { position: relative; }
.row-arrow {
  position: absolute;
  top: 38%; transform: translateY(-50%);
  z-index: 10;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(10,11,15,0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: background .2s, border-color .2s, opacity .2s, transform .2s;
}
.row-outer:hover .row-arrow { opacity: 1; }
.row-arrow:hover { background: var(--accent); border-color: var(--accent); transform: translateY(-50%) scale(1.07); }
.row-arrow.left  { left: -16px; }
.row-arrow.right { right: -16px; }
@media (hover: none) { .row-arrow { display: none; } }

/* Card */
.movie-card {
  scroll-snap-align: start;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  transition: transform var(--trans), box-shadow var(--trans);
  position: relative;
  text-decoration: none;
  display: block;
}
.movie-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 12px 40px rgba(0,0,0,0.6); }
.movie-card:hover .movie-card-overlay { opacity: 1; }

.movie-card-poster {
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--bg-elevated);
  position: relative;
}
.movie-card-poster img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.movie-card:hover .movie-card-poster img { transform: scale(1.05); }

.movie-card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(10,11,15,0.9) 0%, transparent 50%);
  display: flex; align-items: flex-end;
  padding: 12px;
  opacity: 0;
  transition: opacity var(--trans);
}
/* SVG play icon — no ▶ character, consistent everywhere */
.play-btn-sm {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  flex-shrink: 0;
}

.movie-card-info { padding: 10px 12px 12px; }
.movie-card-title {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.movie-card-meta {
  font-size: 11px; color: var(--text-muted);
  display: flex; gap: 6px; align-items: center;
}
.movie-card-meta .dot { opacity: 0.4; }
.genre-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  font-size: 10px; color: var(--text-muted);
  font-weight: 500; letter-spacing: 0.3px;
}

/* Poster placeholder when image fails/missing */
.poster-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-card));
  color: var(--text-faint);
  font-size: 28px;
}

/* ══════════════════════════════════════════
   SKELETON LOADER
   Shown immediately while data is fetching.
══════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, #1e2130 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s infinite;
  border-radius: var(--radius);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  flex-shrink: 0; width: 140px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}
@media (min-width: 480px) { .skeleton-card { width: 160px; } }
@media (min-width: 600px) { .skeleton-card { width: 180px; } }
@media (min-width: 1024px) { .skeleton-card { width: 200px; } }
.skeleton-poster    { aspect-ratio: 2/3; width: 100%; }
.skeleton-line      { height: 13px; margin: 10px 12px 6px; border-radius: 4px; }
.skeleton-line-sm   { height: 10px; margin: 0 12px 12px; width: 60%; border-radius: 4px; }

/* ══════════════════════════════════════════
   SPINNER
══════════════════════════════════════════ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px; font-weight: 400; margin-bottom: 8px;
}
.empty-state p { font-size: 14px; color: var(--text-muted); }

/* ══════════════════════════════════════════
   ERROR BANNER
   Shown when Supabase fetch fails — with retry.
══════════════════════════════════════════ */
.error-banner {
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(229,23,58,0.1);
  border: 1px solid rgba(229,23,58,0.3);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 32px;
}
.error-banner.show { display: flex; }
.error-banner p { flex: 1; font-size: 14px; color: rgba(255,255,255,0.75); }
.error-retry {
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.error-retry:hover { opacity: 0.88; }

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px; color: var(--text);
  box-shadow: var(--shadow-card);
  transform: translateY(80px);
  opacity: 0;
  transition: transform var(--trans), opacity var(--trans);
  z-index: 9999;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ══════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes kenburns {
  0%   { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.08) translate(-1.5%, 1%); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.8); }
}
@keyframes scrollLine {
  0%   { transform: scaleY(0); transform-origin: top; opacity: 1; }
  45%  { transform: scaleY(1); transform-origin: top; opacity: 1; }
  46%  { transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; opacity: 0; }
}

/* ══════════════════════════════════════════
   REDUCED MOTION
   Respects the OS "reduce motion" setting.
══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .hero-bg img,
  .hero-badge-dot,
  .hero-scroll-line,
  .skeleton              { animation: none; }
  .hero-badge,
  .hero-title,
  .hero-meta,
  .hero-desc,
  .hero-actions          { animation: none; opacity: 1; transform: none; }
  .section               { opacity: 1 !important; animation: none !important; }
}
