/* --------- Base --------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: #0a0a0a;
  color: #e5e5e5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }

/* --------- Nav --------- */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 60px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.4) 60%, transparent);
  transition: background 0.3s;
}
#nav.scrolled { background: rgba(10,10,10,0.95); backdrop-filter: blur(10px); }
.nav-left { display: flex; align-items: center; gap: 24px; }
.logo { font-weight: 900; font-size: 22px; color: #e50914; letter-spacing: -0.5px; }
.logo span { color: #e5e5e5; margin: 0 4px; }
.nav-link { font-size: 14px; color: #b3b3b3; transition: color 0.2s; padding: 6px 0; }
.nav-link:hover, .nav-link.active { color: #fff; }
.nav-right { display: flex; align-items: center; gap: 16px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-icon { color: #b3b3b3; position: absolute; left: 10px; pointer-events: none; }
#search {
  background: rgba(0,0,0,0.7); border: 1px solid #333; border-radius: 4px;
  padding: 8px 12px 8px 36px; color: #e5e5e5; width: 240px; font-size: 14px;
  transition: width 0.3s, border-color 0.2s;
}
#search:focus { outline: none; border-color: #666; width: 300px; }
#search-results {
  position: absolute; top: 42px; right: 0; width: 340px;
  background: rgba(10,10,10,0.97); border: 1px solid #333; border-radius: 4px;
  max-height: 480px; overflow-y: auto; display: none; z-index: 60;
}
#search-results.on { display: block; }
.search-item {
  display: flex; gap: 12px; padding: 10px; cursor: pointer;
  border-bottom: 1px solid #1a1a1a; transition: background 0.15s;
}
.search-item:hover { background: #1a1a1a; }
.search-item img { width: 46px; height: 68px; object-fit: cover; border-radius: 3px; }
.search-item .meta { display: flex; flex-direction: column; justify-content: center; flex: 1; }
.search-item .meta strong { font-size: 14px; color: #fff; }
.search-item .meta span { font-size: 12px; color: #888; }

/* --------- Hero --------- */
.hero { position: relative; height: 85vh; min-height: 500px; margin-bottom: 40px; }
.hero-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center top;
  transition: background-image 0.4s;
}
.hero-gradient {
  position: absolute; inset: 0;
  background:
    linear-gradient(to right, rgba(10,10,10,0.9) 0%, rgba(10,10,10,0.5) 40%, transparent 70%),
    linear-gradient(to top, #0a0a0a 5%, transparent 40%);
}
.hero-content {
  position: absolute; left: 60px; bottom: 100px; max-width: 640px; z-index: 2;
}
.hero-content h1 {
  font-size: 56px; font-weight: 900; line-height: 1.05; margin-bottom: 16px;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.7);
}
.hero-meta { display: flex; gap: 12px; margin-bottom: 12px; font-size: 14px; color: #ccc; }
.hero-meta span { padding: 2px 8px; border: 1px solid #555; border-radius: 3px; font-size: 12px; }
.hero-meta .rating { color: #46d369; border-color: #46d369; font-weight: 700; }
.hero-desc {
  font-size: 16px; line-height: 1.5; margin-bottom: 24px; color: #d9d9d9;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-actions { display: flex; gap: 12px; }

/* --------- Buttons --------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 24px; border-radius: 4px; font-size: 15px; font-weight: 600;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #fff; color: #000; }
.btn-secondary { background: rgba(109,109,110,0.7); color: #fff; }

/* --------- Rows --------- */
.rows { padding: 0 60px 60px; }
.row { margin-bottom: 40px; }
.row h2 {
  font-size: 22px; font-weight: 700; margin-bottom: 12px; color: #e5e5e5;
}
.row-track {
  display: flex; gap: 8px; overflow-x: auto; scroll-behavior: smooth;
  padding-bottom: 20px; scrollbar-width: none;
}
.row-track::-webkit-scrollbar { display: none; }
.card {
  flex: 0 0 auto; width: 220px; aspect-ratio: 16/9;
  border-radius: 4px; overflow: hidden; position: relative; cursor: pointer;
  background: #1a1a1a; transition: transform 0.25s, z-index 0s 0.25s;
}
.card:hover { transform: scale(1.15); z-index: 10; transition: transform 0.25s, z-index 0s; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .card-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 8px; background: linear-gradient(to top, rgba(0,0,0,0.95), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.card:hover .card-overlay { opacity: 1; }
.card .card-overlay .title { font-size: 13px; font-weight: 700; color: #fff; }
.card .card-overlay .meta { font-size: 11px; color: #b3b3b3; margin-top: 4px; }

/* Popular list — number style */
.card-popular {
  display: flex; align-items: center; gap: 8px; width: auto;
  aspect-ratio: auto; background: transparent; padding: 12px 0;
}
.card-popular .rank {
  font-size: 96px; font-weight: 900; color: transparent;
  -webkit-text-stroke: 3px #444; line-height: 0.8; padding-right: 16px;
}
.card-popular .title { font-size: 16px; font-weight: 600; }

/* --------- Grid view --------- */
#view-grid { display: none; padding: 80px 60px 60px; }
#view-grid.active { display: block; }
.grid-header h2 { font-size: 28px; margin-bottom: 24px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.grid .card {
  width: 100%; aspect-ratio: 2/3;
}
.grid-loader { text-align: center; padding: 40px; color: #666; }

/* --------- View toggle --------- */
.view { display: none; }
.view.active { display: block; }

/* --------- Modal --------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; overflow-y: auto; padding: 40px 0;
}
.modal.on { display: flex; }
.modal-content {
  width: 90%; max-width: 850px; background: #141414;
  border-radius: 8px; overflow: hidden; position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  width: 36px; height: 36px; border-radius: 50%; background: #181818;
  font-size: 22px; line-height: 1; color: #fff;
}
.modal-hero {
  height: 380px; background-size: cover; background-position: center;
  position: relative;
}
.modal-hero::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 50%, #141414);
}
.modal-body { padding: 24px 40px 40px; }
.modal-actions { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.modal-info { color: #d9d9d9; line-height: 1.5; margin-bottom: 30px; }
.modal-info .row-info { display: flex; gap: 24px; margin-bottom: 12px; font-size: 14px; }
.modal-info .row-info span { color: #777; }
.modal-info p { margin-top: 16px; font-size: 15px; }
.modal-episodes select {
  background: #333; color: #fff; border: 1px solid #555;
  padding: 8px 12px; border-radius: 4px; font-size: 14px;
}
.modal-recs h3 { font-size: 20px; margin-bottom: 16px; }
.modal-recs .grid { grid-template-columns: repeat(3, 1fr); }

/* --------- Player --------- */
.player {
  position: fixed; inset: 0; background: #000; z-index: 200;
  display: none; align-items: center; justify-content: center;
}
.player.on { display: flex; }
.player video { max-width: 100%; max-height: 100vh; }
.player-close {
  position: absolute; top: 20px; right: 30px; z-index: 210;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,0.7); font-size: 26px; color: #fff;
}
.player-loading {
  position: absolute; color: #fff; font-size: 18px;
}
.player-quality {
  position: absolute; bottom: 30px; left: 30px; z-index: 210;
  display: flex; gap: 8px;
}
.player-quality button {
  padding: 6px 12px; background: rgba(0,0,0,0.7); border: 1px solid #555;
  border-radius: 4px; font-size: 13px; color: #fff;
}
.player-quality button.active { background: #fff; color: #000; }

/* --------- Responsive --------- */
@media (max-width: 768px) {
  #nav { padding: 12px 20px; }
  .nav-left { gap: 12px; }
  .logo { font-size: 18px; }
  .nav-link { font-size: 13px; }
  #search { width: 140px; }
  #search:focus { width: 180px; }
  .hero { height: 70vh; }
  .hero-content { left: 20px; right: 20px; bottom: 40px; }
  .hero-content h1 { font-size: 32px; }
  .hero-desc { font-size: 14px; }
  .rows { padding: 0 20px 40px; }
  .card { width: 160px; }
  #view-grid { padding: 70px 20px 40px; }
  .modal-content { width: 95%; }
  .modal-body { padding: 16px 20px 30px; }
  .modal-hero { height: 240px; }
  .modal-recs .grid { grid-template-columns: repeat(2, 1fr); }
}
