/* ============================================================================
 *  HarmanFlix — styles
 * ==========================================================================*/

:root {
  --bg: #0b0b0f;
  --bg-elev: #16161d;
  --surface: #1d1d27;
  --text: #f4f4f6;
  --text-dim: #a0a0ad;
  --text-faint: #6c6c78;
  --accent: #e50914;
  --accent-2: #ff3d47;
  --star: #f5c518;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  --header-h: 64px;
  --maxw: 1400px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

img { display: block; max-width: 100%; }

/* ---- Header --------------------------------------------------------------*/
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 clamp(16px, 4vw, 48px);
  z-index: 50;
  transition: background 0.25s ease, backdrop-filter 0.25s ease;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
}
.site-header.scrolled {
  background: rgba(11, 11, 15, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand {
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 0.5px;
  color: var(--accent);
  white-space: nowrap;
}
.brand span { color: var(--text); }
.nav {
  display: flex;
  gap: 20px;
  margin-right: auto;
  font-size: 0.92rem;
  color: var(--text-dim);
}
.nav a:hover, .nav a.active { color: var(--text); }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 180px;
  transition: border-color 0.2s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box input {
  background: none;
  border: none;
  color: var(--text);
  outline: none;
  width: 100%;
  font-size: 0.9rem;
}
.search-box svg { flex-shrink: 0; opacity: 0.7; }

/* ---- Hero ----------------------------------------------------------------*/
.hero {
  position: relative;
  min-height: 82vh;
  padding: 0 clamp(16px, 5vw, 60px);
  display: flex;
  align-items: flex-end;
  padding-bottom: 8vh;
  background-size: cover;
  background-position: center 20%;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.hero--ready { opacity: 1; }
.hero__inner { max-width: 620px; }
.hero__title {
  font-size: clamp(2rem, 5vw, 3.6rem);
  font-weight: 800;
  line-height: 1.05;
  margin: 0 0 16px;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
}
.hero__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  color: var(--text-dim);
}
.hero__star { color: var(--star); font-weight: 600; }
.hero__overview {
  font-size: 1.02rem;
  line-height: 1.5;
  color: #e6e6ea;
  margin: 0 0 24px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

/* ---- Buttons / pills -----------------------------------------------------*/
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 26px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: transform 0.12s ease, background 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); }
.btn--ghost {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  backdrop-filter: blur(4px);
}
.pill {
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 5px;
}

/* ---- Rows ----------------------------------------------------------------*/
main { max-width: var(--maxw); margin: 0 auto; position: relative; z-index: 2; }
/* Only the homepage main (the one right after the hero) tucks under the banner. */
.hero + main { margin-top: -5vh; }
.rows {
  padding: 0 clamp(16px, 4vw, 48px) 60px;
  position: relative;
  z-index: 2;
}
.page-rows { padding-top: calc(var(--header-h) + 24px); margin-top: 0; }
.row { margin-bottom: 34px; }
.row__title {
  font-size: 1.22rem;
  font-weight: 700;
  margin: 0 0 14px;
  padding-left: 12px;
  position: relative;
  letter-spacing: 0.2px;
}
/* accent bar before each row title */
.row__title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1.05em;
  border-radius: 3px;
  background: linear-gradient(var(--accent), var(--accent-2));
}

/* ---- Browse tabs ---------------------------------------------------------*/
.tabs {
  display: flex;
  gap: 8px;
  padding: 4px clamp(16px, 4vw, 48px) 0;
  margin: 6px 0 18px;
  position: relative;
  z-index: 2;
}
.tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s, border-color 0.18s, transform 0.12s;
}
.tab:hover { color: var(--text); transform: translateY(-1px); }
.tab.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(229, 9, 20, 0.35);
}

/* ---- Recently Watched ----------------------------------------------------*/
.recent {
  padding: 8px clamp(16px, 4vw, 48px) 0;
  position: relative;
  z-index: 2;
}
.recent[hidden] { display: none; }
.recent__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.recent__head .row__title { margin-bottom: 12px; }
.recent__clear {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--text-faint);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}
.recent__clear:hover { color: var(--accent-2); border-color: var(--accent); }
.row__track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface) transparent;
}
.row__track::-webkit-scrollbar { height: 8px; }
.row__track::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 8px; }
.row__error { color: var(--text-faint); padding: 20px 0; }

/* ---- Card ----------------------------------------------------------------*/
.card {
  flex: 0 0 auto;
  width: 158px;
  scroll-snap-align: start;
  transition: transform 0.18s ease;
}
.card:hover { transform: translateY(-4px); }
.card__poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}
.card__poster img { width: 100%; height: 100%; object-fit: cover; }
.card__noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.7);
  padding: 3px 6px;
  border-radius: 4px;
  color: #fff;
}
.card__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.card:hover .card__overlay { opacity: 1; }
.card__play {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
  padding-left: 3px;
}
.card__meta { padding: 8px 2px 0; }
.card__title {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card__sub {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-faint);
  margin-top: 3px;
}
.card__star { color: var(--star); }
.card--skeleton {
  width: 158px;
  height: 237px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 30%, #262633 50%, var(--surface) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Details page --------------------------------------------------------*/
.detail-backdrop {
  position: absolute;
  inset: 0;
  height: 80vh;
  background-size: cover;
  background-position: center 15%;
  z-index: 0;
}
.detail {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(var(--header-h) + 6vh) clamp(16px, 4vw, 48px) 60px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.detail--ready { opacity: 1; }
.detail__top {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.detail__poster {
  flex: 0 0 240px;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--surface);
}
.detail__poster img { width: 100%; height: 100%; object-fit: cover; }
.detail__noposter {
  display: flex; align-items: center; justify-content: center;
  height: 100%; padding: 16px; text-align: center; color: var(--text-dim);
}
.detail__info { flex: 1 1 340px; min-width: 280px; }
.detail__title { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 800; margin: 0 0 8px; }
.detail__tagline { color: var(--text-dim); font-style: italic; margin: 0 0 14px; }
.detail__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  color: var(--text-dim); font-size: 0.95rem; margin-bottom: 20px;
}
.detail__star { color: var(--star); font-weight: 700; }
.detail__overview { font-size: 1.05rem; line-height: 1.6; max-width: 720px; color: #e2e2e8; }
.detail__error { padding: 30vh 24px; text-align: center; color: var(--text-dim); }
.detail__error a { color: var(--accent-2); }

/* ---- Player --------------------------------------------------------------*/
.player {
  margin: 10px 0 44px;
}
.player__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.player__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Loader overlay shown until the iframe fires its load event */
.player__loader {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(120% 120% at 50% 40%, #14141b 0%, #000 100%);
}
.player__loader[hidden] { display: none; }
.player__spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 24px rgba(229, 9, 20, 0.35);
}
.player__loader-text {
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* Actions under the player */
.player__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 12px;
}
.player__newtab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.18s, border-color 0.18s, transform 0.12s;
}
.player__newtab:hover {
  background: rgba(229, 9, 20, 0.16);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.player__newtab[hidden] { display: none; }
.player__hint { font-size: 0.8rem; color: var(--text-faint); }
.player__notice {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
}
.player__notice svg { opacity: 0.6; }
.player__notice code {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--accent-2);
  font-size: 0.9rem;
}
.section-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 16px; }

/* ---- Season / episode picker --------------------------------------------*/
.ep-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
/* Respect the hidden attribute (movies) — a plain [hidden] rule loses to the
   .ep-picker class above, so scope it to the same class to win. */
.ep-picker[hidden] { display: none; }
.ep-picker__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.ep-picker__field select {
  appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a0ad' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 11px 34px 11px 12px;
  font-size: 0.92rem;
  min-width: 150px;
  max-width: 260px;
  cursor: pointer;
}
.ep-picker__field select:focus { outline: none; border-color: var(--accent); }
.ep-picker__play { padding: 11px 22px; }

/* ---- Cast ----------------------------------------------------------------*/
.cast {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 10px;
}
.cast__member { flex: 0 0 auto; width: 96px; text-align: center; }
.cast__photo {
  width: 96px; height: 96px; border-radius: 50%;
  overflow: hidden; background: var(--surface); margin: 0 auto 8px;
}
.cast__photo img { width: 100%; height: 100%; object-fit: cover; }
.cast__noimg {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 1.6rem; font-weight: 700; color: var(--text-dim);
}
.cast__name { display: block; font-size: 0.8rem; font-weight: 600; }
.cast__role { display: block; font-size: 0.72rem; color: var(--text-faint); margin-top: 2px; }

.detail-section { margin-bottom: 40px; }

/* ---- Search --------------------------------------------------------------*/
.search-page { padding: calc(var(--header-h) + 40px) clamp(16px, 4vw, 48px) 60px; }
.search-page h1 { font-size: 1.8rem; margin: 0 0 8px; }
.search-status { color: var(--text-dim); margin-bottom: 24px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px 14px;
}
.grid .card { width: 100%; }
.grid .card__poster { width: 100%; }

/* ---- Footer --------------------------------------------------------------*/
.site-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 28px clamp(16px, 4vw, 48px);
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
}
.site-footer a { color: var(--text-dim); }
.site-footer__tmdb { margin-top: 6px; font-size: 0.78rem; opacity: 0.75; }
.site-footer__tmdb a { color: var(--text-faint); }
.site-footer__tmdb a:hover { color: var(--text-dim); }

/* ---- Responsive ----------------------------------------------------------*/
@media (max-width: 900px) {
  .hero { min-height: 70vh; }
  .detail__top { gap: 22px;margin-bottom:0px!important; }
}

@media (max-width: 640px) {
  :root { --header-h: 58px; }

  /* Header collapses to brand + search; nav lives in the footer/home instead. */
  .site-header { gap: 12px; padding: 0 14px; }
  .brand { font-size: 1.2rem; }
  .nav { display: none; }
  .search-box { min-width: 0; flex: 1; max-width: 220px; margin-left: auto; }

  /* Hero */
  .hero { min-height: 66vh; padding-bottom: 6vh; background-position: center top; }
  .hero__overview { -webkit-line-clamp: 3; font-size: 0.95rem; }
  .btn { padding: 11px 22px; font-size: 0.95rem; }

  /* Rows / cards — smaller posters, tighter gaps, momentum scroll */
  .rows { padding: 0 14px 48px; }
  .row__track { gap: 10px; -webkit-overflow-scrolling: touch; }
  .card { width: 130px; }
  .card--skeleton { width: 130px; height: 195px; }

  /* Details */
  .detail { padding: calc(var(--header-h) + 4vh) 16px 48px; }
  .detail__top { flex-direction: column; align-items: center; text-align: center; }
  .detail__poster { flex-basis: auto; width: 150px; }
  .detail__info { text-align: center; }
  .detail__meta { justify-content: center; }
  .detail__overview { text-align: left; }

  /* Season / episode picker stacks and fills the width */
  .ep-picker { gap: 10px; }
  .ep-picker__field { flex: 1 1 100%; }
  .ep-picker__field select { max-width: none; width: 100%; }
  .ep-picker__play { width: 100%; }

  /* Search grid — more columns on small screens */
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 14px 10px; }
}

@media (max-width: 380px) {
  .card { width: 118px; }
  .card--skeleton { width: 118px; height: 177px; }
  .brand { font-size: 1.05rem; }
}
