:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-alt: #f1f3f7;
  --red: #e50914;
  --red-hover: #b80710;
  --red-soft: rgba(229, 9, 20, 0.08);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 16px 32px rgba(229, 9, 20, 0.22);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--text-primary);
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

/* ============================================================
   TOP BAR (No Navbar links - Pure brand & sleek search)
============================================================ */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 72px;
  padding: 0 4.5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

.logo {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s ease;
}

.logo:hover {
  transform: scale(1.02);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border: 1.5px solid transparent;
  padding: 8px 16px;
  border-radius: 9999px;
  width: min(340px, 50vw);
  transition: all 0.25s ease;
}

.search-box:focus-within {
  background: var(--surface);
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}

.search-icon {
  width: 17px;
  height: 17px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.search-box:focus-within .search-icon {
  color: var(--red);
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* ============================================================
   CONTENT ROWS (Starts straight with the movies like Netflix)
============================================================ */
.content-rows {
  padding: 24px 0 60px;
  min-height: calc(100vh - 72px);
}

.row {
  margin-bottom: 34px;
  position: relative;
}

.row-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4.5% 12px;
}

.row-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--red);
  border-radius: 2px;
}

.track-wrapper {
  position: relative;
}

.track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 10px 4.5% 20px;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.track::-webkit-scrollbar {
  display: none;
}

/* Row scroll arrows */
.arrow {
  position: absolute;
  top: 10px;
  bottom: 20px;
  width: 4.5%;
  z-index: 10;
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, rgba(248, 249, 251, 0.95), transparent);
  color: var(--text-primary);
  font-size: 28px;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  user-select: none;
}

.arrow.r {
  right: 0;
  background: linear-gradient(-90deg, rgba(248, 249, 251, 0.95), transparent);
}

.arrow:hover {
  color: var(--red);
}

.track-wrapper:hover .arrow {
  opacity: 1;
}

/* Search Results Grid */
.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px 16px;
  padding: 0 4.5%;
}

/* ============================================================
   POSTER CARD (Cinematic white & red hover card)
============================================================ */
.card {
  flex: 0 0 auto;
  width: clamp(140px, 15vw, 210px);
  aspect-ratio: 2 / 3;
  position: relative;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.28s ease;
  outline: none;
}

.grid-view .card {
  width: auto;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-6px) scale(1.05);
  box-shadow: var(--shadow-hover);
  border-color: var(--red);
  z-index: 8;
}

.card:focus-visible {
  outline: 3px solid var(--red);
}

.card .poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Placeholder for movies without poster */
.card .poster-ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  color: #ffffff;
  position: relative;
}

.card .poster-ph b {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.card .poster-ph small {
  margin-top: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

/* Overlay that appears on hover */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(15, 23, 42, 0.94) 85%);
  opacity: 0;
  transition: opacity 0.22s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px;
  color: #ffffff;
}

.card:hover .card-overlay,
.card:focus-visible .card-overlay {
  opacity: 1;
}

.overlay-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.btn-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-circle.play {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

.btn-circle:hover {
  transform: scale(1.12);
}

.overlay-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overlay-meta {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 3px;
}

/* Progress bar for resume watching */
.resume-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(226, 232, 240, 0.8);
}

.resume-bar i {
  display: block;
  height: 100%;
  background: var(--red);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 12vh 6%;
}

.empty-state h3 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ============================================================
   DETAILS MODAL (Clean White & Red)
============================================================ */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 40px 16px;
}

.backdrop.open {
  display: flex;
}

.modal {
  position: relative;
  width: min(780px, 100%);
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.2);
  border: 1px solid var(--border);
  animation: modalIn 0.22s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s, background 0.2s;
}

.modal-close:hover {
  background: var(--surface);
  transform: scale(1.08);
}

.modal-banner {
  position: relative;
  height: min(44vw, 360px);
  background: #1e293b center/cover no-repeat;
  display: flex;
  align-items: flex-end;
}

.modal-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.1) 0%, rgba(15, 23, 42, 0.85) 100%);
}

.modal-banner-info {
  position: relative;
  z-index: 2;
  padding: 24px 36px;
  width: 100%;
  color: #ffffff;
}

.modal-banner-info h2 {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-play {
  height: 44px;
  padding: 0 24px;
  background: var(--red);
  color: #ffffff;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(229, 9, 20, 0.35);
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn-play:hover {
  background: var(--red-hover);
  transform: translateY(-1px);
}

.btn-fav {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: background 0.2s, border-color 0.2s;
}

.btn-fav:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: #ffffff;
}

.modal-details {
  padding: 24px 36px 36px;
}

.modal-meta {
  display: flex;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 12px;
}

.modal-meta span {
  color: var(--text-secondary);
  font-weight: 500;
}

.modal-details p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 24px;
}

.season-heading {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 24px 0 10px;
}

.episode-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.18s ease;
}

.episode-row:hover {
  background: var(--surface-alt);
}

.episode-row .ep-num {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-muted);
  width: 28px;
  text-align: center;
}

.episode-row:hover .ep-num {
  color: var(--red);
}

.episode-row .ep-info b {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
}

.episode-row .ep-info small {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ============================================================
   VIDEO PLAYER (Cinematic Fullscreen for TV & PC)
============================================================ */
.player {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: #000000;
  display: none;
}

.player.open {
  display: block;
}

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

.player-back {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: background 0.2s ease, transform 0.15s ease;
}

.player-back:hover {
  background: var(--red);
  transform: scale(1.08);
}

.player-title {
  position: absolute;
  top: 32px;
  left: 80px;
  z-index: 10;
  color: #ffffff;
  font-size: 17px;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Toast alert */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 14px);
  background: var(--text-primary);
  color: #ffffff;
  padding: 11px 22px;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Mobile & TV responsive */
@media (max-width: 768px) {
  .top-bar {
    height: 62px;
    padding: 0 16px;
  }
  .logo {
    font-size: 21px;
  }
  .search-box {
    width: 170px;
    padding: 6px 12px;
  }
  .card {
    width: 38vw;
  }
  .card:hover {
    transform: none;
  }
  .arrow {
    display: none;
  }
  .modal-details {
    padding: 18px 20px 28px;
  }
  .modal-banner-info {
    padding: 18px 20px;
  }
}
