/* ============================================
   CineFree — Professional free movie site
   5-year polished dark cinema UI
   ============================================ */

:root {
  --bg: #0a0a0a;
  --bg-elevated: #121212;
  --bg-card: #1a1a1a;
  --bg-hover: #222;
  --border: #2a2a2a;
  --text: #f0f0f0;
  --text-muted: #a0a0a0;
  --text-dim: #666;
  --accent: #e50914;
  --accent-hover: #f40612;
  --rating: #ffd700;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0,0,0,.45);
  --header-h: 64px;
  --transition: .2s ease;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ========== HEADER ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(10,10,10,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -.02em;
  flex-shrink: 0;
}

.logo-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  font-size: .85rem;
  color: #fff;
}

.search-form {
  flex: 1;
  max-width: 480px;
  display: flex;
  position: relative;
}

.search-form input {
  width: 100%;
  padding: .65rem 2.8rem .65rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color var(--transition);
}

.search-form input:focus {
  border-color: var(--accent);
}

.search-form input::placeholder { color: var(--text-dim); }

.search-form button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}

.search-form button:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.nav {
  display: flex;
  gap: 1.25rem;
  font-weight: 500;
  font-size: .95rem;
}

.nav a {
  color: var(--text-muted);
  transition: color var(--transition);
}

.nav a:hover { color: var(--text); }

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: var(--transition);
}

.mobile-nav {
  display: none;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.mobile-nav a {
  font-weight: 500;
  font-size: 1.05rem;
  padding: .4rem 0;
}

.mobile-nav .search-form {
  max-width: none;
  flex-direction: column;
  gap: .5rem;
}

.mobile-nav .search-form input {
  border-radius: var(--radius);
}

.mobile-nav .search-form button {
  position: static;
  transform: none;
  width: 100%;
  height: 42px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
}

.mobile-nav.open { display: flex; }

/* ========== HERO SLIDER ========== */
.hero-slider {
  position: relative;
  height: 72vh;
  min-height: 420px;
  max-height: 640px;
  overflow: hidden;
  background: #0a0a0a;
}

.hero-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: 0;
  visibility: hidden;
  transition: opacity .7s ease, visibility .7s ease;
  display: flex;
  align-items: flex-end;
}

.hero-slide.active {
  opacity: 1;
  visibility: visible;
  z-index: 1;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(10,10,10,.97) 0%,
    rgba(10,10,10,.85) 35%,
    rgba(10,10,10,.35) 65%,
    rgba(10,10,10,.15) 100%
  ),
  linear-gradient(
    0deg,
    rgba(10,10,10,.9) 0%,
    transparent 45%
  );
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
  padding-bottom: 4.5rem;
  padding-top: 2rem;
}

.hero-text {
  max-width: 540px;
}

.hero-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(229,9,20,.15);
  border: 1px solid rgba(229,9,20,.4);
  padding: .25rem .6rem;
  border-radius: 4px;
  margin-bottom: .85rem;
}

.hero-slide h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.12;
  margin-bottom: .6rem;
  text-shadow: 0 2px 20px rgba(0,0,0,.5);
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: .85rem;
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: .85rem;
}

.hero-meta .score {
  color: var(--rating);
  font-weight: 600;
}

.hero-overview {
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.55;
  margin-bottom: 1.5rem;
  max-width: 48ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .8rem 1.6rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.hero-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(229,9,20,.35);
}

.hero-btn.secondary {
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
}

.hero-btn.secondary:hover {
  background: rgba(255,255,255,.2);
  box-shadow: none;
}

.hero-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
  transition: background var(--transition), border-color var(--transition);
  opacity: 0;
}

.hero-slider:hover .hero-nav { opacity: 1; }

.hero-nav:hover {
  background: rgba(0,0,0,.7);
  border-color: rgba(255,255,255,.35);
}

.hero-nav.prev { left: 1rem; }
.hero-nav.next { right: 1rem; }

.hero-dots {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  gap: .5rem;
}

.hero-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  transition: background var(--transition), transform var(--transition);
  padding: 0;
}

.hero-dot.active {
  background: var(--accent);
  transform: scale(1.25);
}

.hero-dot:hover { background: rgba(255,255,255,.7); }

/* ========== PAGE HEADER ========== */
.page-header {
  padding: 2.5rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-header p {
  color: var(--text-muted);
  margin-top: .35rem;
}

/* ========== SECTIONS ========== */
.section {
  padding: 2.5rem 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.see-all {
  font-size: .9rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition);
}

.see-all:hover { color: var(--accent); }

/* ========== MOVIE GRID ========== */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .movie-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.5rem; }
}

@media (min-width: 1024px) {
  .movie-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

.movie-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  transition: transform var(--transition), box-shadow var(--transition);
}

.movie-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.poster-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--bg-elevated);
  overflow: hidden;
}

.poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}

.movie-card:hover .poster-wrap img {
  transform: scale(1.05);
}

.rating {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,.75);
  color: var(--rating);
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .45rem;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.card-info {
  padding: .7rem .75rem .85rem;
}

.card-title {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .15rem;
}

.card-year {
  font-size: .8rem;
  color: var(--text-dim);
}

/* ========== GENRE GRID ========== */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.genre-card {
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.genre-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ========== WATCH PAGE ========== */
.watch-section {
  padding-bottom: 3rem;
}

.player-wrap {
  background: #000;
  width: 100%;
}

.player-container {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.watch-meta {
  padding-top: 1.5rem;
}

.server-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.server-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.servers {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.server-btn {
  padding: .45rem .9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  transition: all var(--transition);
}

.server-btn:hover {
  border-color: var(--text-muted);
}

.server-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.movie-header h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: .6rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.meta-row .score {
  color: var(--rating);
  font-weight: 600;
}

.meta-row .genres a {
  color: var(--text-muted);
  margin-right: .5rem;
  transition: color var(--transition);
}

.meta-row .genres a:hover { color: var(--accent); }

.overview {
  color: var(--text-muted);
  max-width: 70ch;
  margin-bottom: 1.25rem;
  line-height: 1.65;
}

.crew {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.crew strong { color: var(--text); }

.trailer-section,
.cast-section,
.similar-section {
  margin-top: 2.5rem;
}

.trailer-section h3,
.cast-section h3,
.similar-section h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.trailer-wrap {
  position: relative;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.trailer-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
}

.cast-card {
  text-align: center;
}

.cast-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  margin-bottom: .4rem;
}

.cast-name {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cast-role {
  display: block;
  font-size: .75rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== PAGINATION ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.page-btn {
  padding: .5rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: .9rem;
  transition: all var(--transition);
}

.page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-info {
  font-size: .9rem;
  color: var(--text-muted);
}

/* ========== EMPTY / ERROR ========== */
.empty,
.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.empty p,
.error-page p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.error-page h1 {
  font-size: 2rem;
  margin-bottom: .75rem;
}

.btn {
  display: inline-block;
  padding: .7rem 1.5rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.btn:hover { background: var(--accent-hover); }

/* ========== FOOTER ========== */
.footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .85rem;
  color: var(--text-dim);
}

.footer .disclaimer {
  margin-top: .4rem;
  font-size: .75rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ========== MOBILE ========== */
@media (max-width: 768px) {
  .nav { display: none; }
  .menu-toggle { display: flex; }
  .search-form:not(.mobile) { display: none; }

  .header-inner { gap: 1rem; }
  .hero-slider {
    height: 58vh;
    min-height: 340px;
    max-height: 480px;
  }
  .hero-overlay {
    background: linear-gradient(
      180deg,
      rgba(10,10,10,.55) 0%,
      rgba(10,10,10,.75) 40%,
      rgba(10,10,10,.95) 100%
    );
  }
  .hero-content {
    padding-bottom: 3.5rem;
    text-align: left;
  }
  .hero-text { max-width: 100%; }
  .hero-slide h1 { font-size: 1.7rem; }
  .hero-overview { font-size: .88rem; max-width: 100%; }
  .hero-nav { opacity: 1; width: 38px; height: 38px; font-size: 1.3rem; }
  .hero-nav.prev { left: .5rem; }
  .hero-nav.next { right: .5rem; }
  .hero-dots { bottom: 1rem; }

  .section { padding: 1.75rem 0; }

  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
  }

  .card-info { padding: .55rem .5rem .7rem; }
  .card-title { font-size: .82rem; }

  .server-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .cast-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: .75rem;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .movie-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
  }
  .genre-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
