/* ============================================================
   CinemaHub — Основные стили (тёмная тема, Netflix/YouTube стиль)
   CSS Grid + Flexbox, полностью адаптивная вёрстка
   ============================================================ */

:root {
  --bg: #0f0f14;
  --bg-elevated: #1a1a24;
  --bg-card: #1e1e2a;
  --text: #f1f1f5;
  --text-muted: #9a9ab0;
  --accent: #e50914;       /* фирменный красный Netflix-стиль */
  --accent-hover: #ff2b3a;
  --border: #2a2a3a;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  --transition: 0.25s ease;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===================== ШАПКА ===================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.header__logo span { color: var(--accent); }

.header__search {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  transition: var(--transition);
}
.header__search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.2);
}

.header__search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
}

.header__search-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0 1.2rem;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
}
.header__search-btn:hover { color: var(--text); }

.header__back {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
}
.header__back:hover { color: var(--text); }

/* ===================== HERO БАННЕР ===================== */
.hero {
  position: relative;
  min-height: 65vh;
  display: flex;
  align-items: flex-end;
  padding: 3rem 2rem;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-elevated);
  margin-bottom: 1rem;
}

.hero__fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(15, 15, 20, 0.95) 0%,
    rgba(15, 15, 20, 0.6) 45%,
    rgba(15, 15, 20, 0.1) 100%
  );
}

.hero__content {
  position: relative;
  z-index: 2;
  max-width: 620px;
}

.hero__title {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  margin-bottom: 1rem;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}

.hero__description {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero__actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ===================== КНОПКИ ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.8rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); transform: translateY(-2px); }

.btn--ghost {
  background: rgba(255,255,255,0.12);
  color: var(--text);
  backdrop-filter: blur(6px);
}
.btn--ghost:hover { background: rgba(255,255,255,0.22); }

/* ===================== ОСНОВНОЙ КОНТЕНТ ===================== */
.main {
  padding: 1rem 2rem 3rem;
}

.content { display: flex; flex-direction: column; gap: 2rem; }

/* Секция-категория */
.category { margin-bottom: 0.5rem; }

.category__title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-left: 0.25rem;
}

/* Горизонтальная лента карточек */
.category__row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 180px;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scroll-snap-type: x mandatory;
}
.category__row::-webkit-scrollbar { height: 6px; }
.category__row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Сетка карточек (для результатов поиска) */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2rem;
}

/* ===================== КАРТОЧКА ФИЛЬМА ===================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  scroll-snap-align: start;
  position: relative;
}
.card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow);
  z-index: 5;
}

.card__poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--bg-elevated);
}

.card__poster--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-muted);
}

.card__body { padding: 0.7rem 0.8rem; }

.card__title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.card__rating {
  color: #ffc107;
  font-weight: 700;
}

/* ===================== СТРАНИЦА ПРОСМОТРА ===================== */
.watch {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  padding: 1rem 2rem 3rem;
  max-width: 1500px;
  margin: 0 auto;
}

.watch__player-wrap { min-width: 0; }

.player {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  position: relative;
}

.player iframe,
.player video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #000;
}

.player__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* Рекламный контейнер (оверлей поверх видео) */
.ad-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 20;
}
.ad-overlay__label {
  color: #ffc107;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.ad-overlay__video { width: 100%; height: 100%; }
.ad-overlay__skip {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 0.4rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.watch__info {
  margin-top: 1.2rem;
  padding: 0 0.25rem;
}

.watch__title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.watch__meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.watch__description {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 800px;
}

/* Сайдбар рекомендаций */
.watch__sidebar {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 1.2rem;
  align-self: start;
  position: sticky;
  top: 4.5rem;
  max-height: 85vh;
  overflow-y: auto;
}

.watch__sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.recommendations { display: flex; flex-direction: column; gap: 0.9rem; }

.rec-item {
  display: flex;
  gap: 0.8rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 8px;
  transition: var(--transition);
}
.rec-item:hover { background: var(--bg-card); }

.rec-item__poster {
  width: 100px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg-card);
}

.rec-item__info { min-width: 0; }
.rec-item__title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
}
.rec-item__meta {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.3rem;
}

/* ===================== ПОДВАЛ ===================== */
.footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ===================== ЗАГРУЗКА / СОСТОЯНИЯ ===================== */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: 1rem;
}

.error-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}
.error-state strong { color: var(--accent); }

/* ===================== АДАПТИВ ===================== */
@media (max-width: 900px) {
  .watch {
    grid-template-columns: 1fr;
  }
  .watch__sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .header { padding: 0.8rem; flex-wrap: wrap; }
  .header__search { order: 3; max-width: 100%; flex-basis: 100%; }
  .hero { min-height: 52vh; padding: 1.5rem 1rem; }
  .main, .watch { padding: 0.8rem 1rem 2rem; }
  .category__row { grid-auto-columns: 140px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .rec-item__poster { width: 72px; }
}