/*
  PAGES — page-specific layout: home, search, watch.
  Widget styling lives in components.css; this file only positions
  page-level blocks and handles responsive behavior.
 */

/* ---- home: hero carousel ------------------------------------------------------ */

.hero {
  position: relative;
  height: clamp(440px, 72vh, 640px);
  margin: calc(-1 * var(--space-5)) 0 var(--space-6);
  overflow: hidden;
  background: var(--color-surface);
}

.hero__slides,
.hero__slide {
  position: absolute;
  inset: 0;
}

.hero__slide {
  opacity: 0;
  visibility: hidden;
  transition: opacity 600ms ease, visibility 0s linear 600ms;
}

.hero__slide.is-active {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition: opacity 600ms ease;
}

.hero__backdrop {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.04);
  transition: transform 8s ease;
}

.hero__slide.is-active .hero__backdrop {
  transform: scale(1);
}

.hero__scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.84) 0%, rgba(0, 0, 0, 0.58) 45%, rgba(0, 0, 0, 0.22) 75%, rgba(0, 0, 0, 0.05) 100%),
    linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.18) 45%, rgba(0, 0, 0, 0.05) 100%);
}

.hero__fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%;
  background: linear-gradient(to top, var(--color-bg) 2%, color-mix(in srgb, var(--color-bg) 72%, transparent) 58%, transparent 100%);
  pointer-events: none;
}

.hero__inner {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: 100%;
  max-width: var(--container-max);
  padding: 0 var(--container-pad);
  display: flex;
  align-items: flex-end;
}

.hero__content {
  max-width: 620px;
  padding-bottom: clamp(72px, 12vh, 112px);
}

.hero__kicker {
  display: inline-block;
  margin-bottom: var(--space-3);
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero__logo {
  max-width: min(420px, 60vw);
  max-height: 140px;
  object-fit: contain;
  margin-bottom: var(--space-4);
}

.hero__title {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.4);
}

.hero__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--space-4);
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
}

.hero__rating {
  color: var(--color-star);
  font-weight: var(--font-weight-semibold);
}

.hero__dot {
  color: rgba(255, 255, 255, 0.35);
}

.hero__meta .badge {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.88);
}

.hero__overview {
  max-width: 58ch;
  margin-top: var(--space-4);
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--text-sm);
  line-height: 1.6;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.hero__play {
  padding: 10px 24px;
  font-size: var(--text-md);
}

.hero__play svg {
  width: 18px;
  height: 18px;
}

.hero__arrow {
  position: absolute;
  z-index: 3;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(10, 10, 10, 0.42);
  color: #fff;
  backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms ease, background 120ms ease;
}

.hero:hover .hero__arrow,
.hero__arrow:focus-visible {
  opacity: 1;
}

.hero__arrow:hover {
  background: rgba(10, 10, 10, 0.65);
}

.hero__arrow svg {
  width: 22px;
  height: 22px;
}

.hero__arrow--prev {
  left: 20px;
}

.hero__arrow--next {
  right: 20px;
}

.hero__dots {
  position: absolute;
  z-index: 3;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--space-5);
  display: flex;
  gap: var(--space-2);
}

.hero__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.32);
  cursor: pointer;
  transition: width 160ms ease, background 160ms ease;
}

.hero__dot.is-active {
  width: 24px;
  background: var(--color-accent);
}

/* ---- search ------------------------------------------------------------------ */

.search-bar {
  margin-bottom: var(--space-5);
}

.search-bar__form {
  display: flex;
  gap: var(--space-2);
}

.search-bar__input {
  flex: 1;
  font-size: var(--text-md);
  padding: var(--space-3) var(--space-4);
}

.search-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.search-count {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
}

/* ---- watch: player (.player-wrap + controls live in components.css) ------------- */

.player-status {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: rgba(0, 0, 0, 0.75);
  color: var(--color-text-dim);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-5);
}

.player-status h3 {
  font-size: var(--text-md);
  color: var(--color-text);
}

.player-status .spinner {
  margin-bottom: var(--space-1);
}

/* ---- watch: toolbar (source popup lives in components.css with the player) ---------- */

.watch-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-dim);
}

.watch-toolbar__source {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.watch-toolbar__spacer {
  flex: 1;
}

/* ---- settings ------------------------------------------------------------------ */

.settings {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.settings__nav {
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.settings__navlink {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-dim);
  text-align: left;
}

.settings__navlink:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

.settings__navlink.is-active {
  color: var(--color-accent-text);
  background: var(--color-accent);
}

.settings__content {
  display: grid;
  gap: var(--space-5);
  min-width: 0;
}

.settings__card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-5);
  scroll-margin-top: calc(var(--header-height) + var(--space-4));
}

.settings__card h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.settings__hint {
  color: var(--color-text-dim);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  max-width: 60ch;
}

.settings__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.settings__status {
  font-size: var(--text-sm);
  min-height: 1.2em;
}

.settings__status--ok {
  color: var(--color-success);
}

.settings__status--err {
  color: var(--color-danger);
}

.provider-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.provider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: border-color 120ms ease;
}

.provider:hover {
  border-color: var(--color-border-strong);
}

.provider input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.provider__name {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- responsive ---------------------------------------------------------------- */

@media (max-width: 720px) {
  :root {
    --card-width: 132px;
  }

  .hero {
    height: clamp(360px, 58vh, 520px);
    margin-bottom: var(--space-5);
  }

  .hero__content {
    padding-bottom: 64px;
  }

  .hero__overview {
    -webkit-line-clamp: 2;
  }

  .hero__arrow {
    display: none;
  }

  .search-bar__form {
    flex-direction: column;
  }

  .settings {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .settings__nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .settings__card {
    padding: var(--space-4);
  }
}

/* ---- watch v2: full-bleed hero + overlay player -------------------------------- */

.watch-page .page--watch {
  padding-top: 0;
}

.watch-page .site-header {
  background: transparent;
  border-bottom-color: transparent;
  backdrop-filter: none;
}

.watch-page.is-scrolled .site-header {
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  border-bottom-color: var(--color-border);
  backdrop-filter: blur(12px);
}

.watch-hero {
  position: relative;
  isolation: isolate;
  margin-top: calc(var(--header-height) * -1);
  min-height: min(85svh, 900px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: var(--color-surface);
}

.watch-hero__backdrop {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  background-color: var(--color-surface);
}

.watch-hero__scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--color-bg) 20%, transparent) 0%,
      color-mix(in srgb, var(--color-bg) 55%, transparent) 55%,
      var(--color-bg) 100%
    ),
    linear-gradient(
      90deg,
      color-mix(in srgb, var(--color-bg) 85%, transparent) 0%,
      transparent 65%
    );
}

.watch-hero__inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: calc(var(--header-height) + var(--space-8)) var(--container-pad) var(--space-8);
}

.watch-hero__logo {
  max-width: min(420px, 60vw);
  max-height: 140px;
  object-fit: contain;
  margin-bottom: var(--space-4);
}

.watch-hero__title {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.watch-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
  color: var(--color-text-dim);
  font-size: var(--text-sm);
}

.watch-hero__rating {
  color: var(--color-star);
  letter-spacing: 2px;
}

.watch-hero__dot {
  color: var(--color-text-faint);
}

.watch-hero__genres {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.watch-hero__overview {
  max-width: 72ch;
  margin: var(--space-4) 0 0;
  color: var(--color-text-dim);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.watch-hero__actions {
  margin-top: var(--space-6);
  display: flex;
}

.watch-hero__actions .btn--primary {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
}

.watch-episodes {
  padding: var(--space-8) 0;
}

.watch-episodes__title {
  margin: 0 0 var(--space-4);
  font-size: var(--text-xl);
}

.season-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-5);
}

.episode-shelf {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  gap: var(--space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-2);
}

.episode-shelf__loading,
.episode-shelf__empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 180px;
}

.episode-card {
  scroll-snap-align: start;
  text-align: left;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}

.episode-card--current {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.episode-card__thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  width: 100%;
  background: var(--color-surface-2);
}

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

.episode-card__thumb--empty {
  display: grid;
  place-items: center;
  font-size: var(--text-2xl);
  color: var(--color-text-faint);
}

.episode-card__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--color-accent);
}

.episode-card__body {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3);
}

.episode-card__num {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.episode-card__title {
  font-weight: 600;
  color: var(--color-text-dim);
}

.episode-card__meta {
  color: var(--color-text-dim);
  font-size: var(--text-xs);
}

.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: grid;
  place-items: center;
}

.player-overlay[hidden] {
  display: none;
}

body.player-open {
  overflow: hidden;
}

body.player-open .player-overlay {
  display: grid;
}

.player-overlay__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 20;
  background: color-mix(in srgb, #000 60%, transparent);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 20%);
}

#playerOverlay .player-wrap {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}

#playerOverlay .watch-toolbar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--space-5);
  z-index: 2;
  background: color-mix(in srgb, #000 65%, transparent);
  border: 1px solid rgb(255 255 255 / 10%);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

@media (max-width: 720px) {
  .watch-hero {
    min-height: 70svh;
  }

  .watch-hero__inner {
    padding-bottom: var(--space-6);
  }

  .watch-hero__actions .btn--primary {
    width: 100%;
  }

  .episode-shelf {
    grid-auto-columns: minmax(160px, 80vw);
  }

  .player-overlay__close {
    top: var(--space-2);
    right: var(--space-2);
  }
}
