/*
  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 ------------------------------------------------------------------ */

.home-hero {
  margin: 0 0 var(--space-6);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(80% 120% at 10% 0%, color-mix(in srgb, var(--color-accent) 14%, transparent), transparent 60%),
    var(--color-surface);
}

.home-hero h1 {
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
}

.home-hero p {
  margin-top: var(--space-2);
  max-width: 56ch;
  color: var(--color-text-dim);
  font-size: var(--text-sm);
}

.home-hero .chips {
  margin-top: var(--space-4);
}

/* ---- 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: hero ------------------------------------------------------------- */

.watch-hero {
  position: relative;
  display: flex;
  gap: var(--space-5);
  align-items: flex-end;
  margin-bottom: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

.watch-hero__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.watch-hero__backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.25;
}

.watch-hero__poster {
  position: relative;
  z-index: 1;
  flex: 0 0 180px;
  width: 180px;
  aspect-ratio: var(--poster-aspect);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-2);
  background: var(--color-surface-2);
}

.watch-hero__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.watch-hero__body {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1;
}

.watch-hero__title {
  font-size: var(--text-3xl);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

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

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

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

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

/* ---- watch: player ------------------------------------------------------------- */

.player-wrap {
  position: relative;
  aspect-ratio: var(--player-aspect);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--color-border);
}

.player-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.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 + sources ---------------------------------------------------- */

.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;
}

.sources {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  margin-bottom: var(--space-6);
  overflow: hidden;
}

.sources__head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
}

.source-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  font-size: var(--text-sm);
}

.source-item:last-child {
  border-bottom: none;
}

.source-item:hover {
  background: var(--color-surface-hover);
}

.source-item--active {
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.source-item__rank {
  flex: 0 0 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-dim);
}

.source-item--active .source-item__rank {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-text);
}

.source-item__name {
  font-weight: var(--font-weight-medium);
}

.source-item__meta {
  margin-left: auto;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.loading-cell {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: var(--space-8) 0;
}

/* ---- watch: episodes --------------------------------------------------------- */

.episodes {
  margin-top: var(--space-7);
}

.episodes__toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.episodes__title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  margin-right: auto;
}

.episodes__toolbar select.field {
  width: auto;
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

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

.episode:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-hover);
}

.episode--current {
  border-color: var(--color-accent);
}

.episode__thumb {
  position: relative;
  flex: 0 0 108px;
  width: 108px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-2);
}

.episode__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.episode__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 120ms ease;
}

.episode:hover .episode__play {
  opacity: 1;
}

.episode--current .episode__play {
  opacity: 1;
  background: color-mix(in srgb, var(--color-accent) 35%, rgba(0, 0, 0, 0.35));
}

.episode__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.episode__num {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.episode__title {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode__meta {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

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

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

  .watch-hero {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-4);
  }

  .watch-hero__poster {
    flex-basis: auto;
    width: 132px;
  }

  .watch-hero__title {
    font-size: var(--text-2xl);
  }

  .home-hero h1 {
    font-size: var(--text-xl);
  }

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