/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:    #e50914;
  --red2:   #b20710;
  --bg:     #141414;
  --bg2:    #181818;
  --bg3:    #222;
  --text:   #e5e5e5;
  --muted:  #777;
  --border: #333;
  --radius: 6px;
  --font:   'Inter', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 4%;
  height: 68px;
  background: linear-gradient(to bottom, rgba(0,0,0,.9) 0%, transparent 100%);
  transition: background .3s;
}
.nav.scrolled { background: rgba(20,20,20,.98); }

.nav-logo {
  font-size: 26px;
  font-weight: 900;
  color: var(--red);
  letter-spacing: 3px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links { display: flex; gap: 20px; }
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: #b3b3b3;
  cursor: pointer;
  transition: color .2s;
}
.nav-link:hover, .nav-link.active { color: #fff; }

.nav-right { margin-left: auto; }
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,.7);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 4px;
  padding: 6px 12px;
  transition: border-color .2s;
}
.search-wrap:focus-within { border-color: #fff; }
.search-icon { width: 16px; height: 16px; color: #aaa; flex-shrink: 0; }
.search-input {
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  width: 220px;
  font-family: var(--font);
}
.search-input::placeholder { color: #888; }
.search-clear {
  background: none; border: none; color: #aaa;
  font-size: 13px; padding: 0; line-height: 1;
}
.search-clear:hover { color: #fff; }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  height: 85vh;
  min-height: 500px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  transform: scale(1.04);
  transition: background-image .5s;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    var(--bg) 0%,
    rgba(20,20,20,.7) 40%,
    rgba(20,20,20,.2) 70%,
    transparent 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 0 4% 80px;
  max-width: 600px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 3px;
  margin-bottom: 14px;
}

.hero-title {
  font-size: clamp(28px, 5vw, 56px);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 2px 2px 8px rgba(0,0,0,.8);
}

.hero-meta {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-desc {
  font-size: 15px;
  line-height: 1.6;
  color: #ccc;
  margin-bottom: 24px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  border: none;
  transition: transform .15s, opacity .15s;
}
.btn:hover { transform: scale(1.04); }
.btn:active { transform: scale(.97); }
.btn-lg { padding: 14px 32px; font-size: 16px; }

.btn-watch {
  background: var(--red);
  color: #fff;
}
.btn-watch:hover { background: var(--red2); }

.btn-info {
  background: rgba(109,109,110,.7);
  color: #fff;
  backdrop-filter: blur(4px);
}
.btn-info:hover { background: rgba(109,109,110,.5); }

/* ── Main & rows ──────────────────────────────────────────────────────────── */
.main { padding: 0 4% 80px; }

.row { margin-bottom: 40px; }

.row-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #e5e5e5;
}

.row-track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
}

/* ── Movie Card ───────────────────────────────────────────────────────────── */
.card {
  flex: 0 0 180px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform .25s, z-index 0s .25s;
  background: var(--bg3);
}

.card:hover {
  transform: scale(1.12);
  z-index: 10;
  transition: transform .25s, z-index 0s;
  box-shadow: 0 20px 40px rgba(0,0,0,.7);
}

.card-img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--bg3);
}

.card-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,.95) 0%, transparent 100%);
  padding: 40px 10px 10px;
  opacity: 0;
  transition: opacity .2s;
}
.card:hover .card-info { opacity: 1; }

.card-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}

.card-meta {
  font-size: 11px;
  color: #aaa;
  display: flex;
  gap: 8px;
}

.card-rating {
  color: #f5c518;
  font-weight: 600;
}

/* ── Search grid ──────────────────────────────────────────────────────────── */
.search-results { margin-bottom: 40px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.grid .card { flex: none; width: 100%; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-wrap[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(3px);
}

.modal {
  position: relative;
  z-index: 1;
  background: var(--bg2);
  border-radius: 12px;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.8);
  animation: modal-in .25s ease;
}

@keyframes modal-in {
  from { transform: scale(.95) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0);      opacity: 1; }
}

.modal-close {
  position: sticky;
  top: 12px;
  left: calc(100% - 48px);
  float: right;
  margin: 12px 12px 0 0;
  background: rgba(0,0,0,.7);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  transition: background .2s;
}
.modal-close:hover { background: rgba(255,255,255,.2); }

.modal-hero {
  width: 100%;
  aspect-ratio: 16/7;
  background-size: cover;
  background-position: center;
  border-radius: 12px 12px 0 0;
  margin-top: -48px;
  position: relative;
}
.modal-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg2) 0%, transparent 60%);
  border-radius: 12px 12px 0 0;
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 24px;
  padding: 0 32px 24px;
}

.modal-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #aaa;
}

.meta-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: #ccc;
}
.meta-rating { color: #f5c518; font-weight: 700; }
.meta-quality {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  font-weight: 700;
}

.modal-overview {
  font-size: 14px;
  line-height: 1.7;
  color: #ccc;
}

.modal-right {
  font-size: 13px;
  color: #aaa;
  line-height: 1.8;
}
.modal-right strong { color: #e5e5e5; }

.modal-actions {
  padding: 0 32px 24px;
  display: flex;
  gap: 12px;
}

.modal-similar { padding: 0 32px 32px; }
.modal-similar h3 { font-size: 15px; margin-bottom: 12px; color: #ccc; }
.similar-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.similar-row .card { flex: 0 0 140px; }

/* ── Fetch / Countdown Overlay ────────────────────────────────────────────── */
.fetch-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10,10,10,.96);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadein .3s;
}
.fetch-overlay[hidden] { display: none; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.fetch-box {
  text-align: center;
  max-width: 420px;
  width: 90%;
  position: relative;
}

.fetch-close {
  position: absolute;
  top: -40px; right: 0;
  background: none; border: none;
  color: #777; font-size: 22px;
}
.fetch-close:hover { color: #fff; }

.fetch-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 36px;
  color: #fff;
  line-height: 1.3;
}

/* Ring countdown */
.countdown-ring {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 28px;
}
.ring-svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: #2a2a2a;
  stroke-width: 8;
}
.ring-fill {
  fill: none;
  stroke: var(--red);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset .5s linear;
}
.countdown-time {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
}

.fetch-status {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 24px;
  min-height: 20px;
  line-height: 1.5;
  padding: 0 12px;
}

.progress-wrap { margin-top: 8px; }
.progress-bar {
  height: 4px;
  background: #2a2a2a;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--red);
  border-radius: 2px;
  width: 0%;
  transition: width .3s;
}
.progress-info {
  font-size: 12px;
  color: #666;
  display: flex;
  justify-content: space-between;
}

/* ── Video Player ─────────────────────────────────────────────────────────── */
.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: #000;
  display: flex;
  flex-direction: column;
  animation: fadein .3s;
}
.player-overlay[hidden] { display: none; }

.player-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0,0,0,.6);
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 2;
}

.player-movie-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}

.player-close {
  background: none;
  border: none;
  color: #ccc;
  font-size: 24px;
  line-height: 1;
  padding: 0;
  transition: color .2s;
}
.player-close:hover { color: #fff; }

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

/* ── Skeleton / loading ───────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #222 25%, #2a2a2a 50%, #222 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.card-skeleton {
  flex: 0 0 180px;
  aspect-ratio: 2/3;
}

/* ── Toast notification ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  color: var(--text);
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  animation: slide-in .3s ease;
}
@keyframes slide-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .search-input { width: 160px; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-right { display: none; }
  .card { flex: 0 0 140px; }
  .card-skeleton { flex: 0 0 140px; }
}
