/* =========================================================
   ПЕРЕМЕННЫЕ И БАЗОВЫЕ НАСТРОЙКИ
   ========================================================= */
:root,
[data-theme="dark"] {
  --bg: #0d0d10;
  --bg-2: #15161b;
  --bg-3: #1c1d24;
  --panel: #17181f;
  --border: #26272f;
  --text: #e8e8ec;
  --muted: #8a8a95;
  --accent: #e91e63;
  --accent-2: #ff3d7f;
  --shadow: 0 8px 30px rgba(0,0,0,.5);
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-2: #ffffff;
  --bg-3: #ececf0;
  --panel: #ffffff;
  --border: #dcdce3;
  --text: #1c1d24;
  --muted: #6b6b75;
  --accent: #d81b60;
  --accent-2: #f0478e;
  --shadow: 0 8px 30px rgba(0,0,0,.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Inter', 'Roboto Condensed', sans-serif;
  font-size: 15px; line-height: 1.6; min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }

body, .topbar, .site-footer, .panel, .ep-card, .season-pill, .review,
.graph-item, .preview-box, .video-wrap, .rating-box, .cs-trigger, .cs-list, .hero-card {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* =========================================================
   ШАПКА И НАВИГАЦИЯ
   ========================================================= */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(8, 8, 11, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: border-color .3s, box-shadow .3s;
}
.topbar:hover { border-bottom-color: var(--accent); box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
[data-theme="light"] .topbar { background: rgba(255, 255, 255, 0.85); }

.topbar-inner { display: flex; align-items: center; gap: 24px; height: 72px; }

.logo {
  font-family: 'Bebas Neue', sans-serif; font-size: 32px;
  letter-spacing: 4px; color: #ff1e3c; text-decoration: none;
  text-shadow: 0 0 15px rgba(255, 30, 60, 0.6);
  transition: text-shadow .3s; display: flex; align-items: center;
}
.logo:hover { text-shadow: 0 0 25px rgba(255, 30, 60, 1); }

.topbar-search { position: relative; }
.topbar-search input {
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 16px 8px 36px; font-size: 14px; font-family: inherit;
  min-width: 220px; transition: all .3s;
}
.topbar-search input:focus {
  outline: none; border-color: var(--accent);
  background: var(--bg); box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.15);
}
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search::before {
  content: '🔍'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); font-size: 14px; opacity: 0.5; pointer-events: none;
}

.topbar-nav { display: flex; gap: 24px; margin-left: auto; }
.topbar-nav a {
  color: var(--muted); font-size: 15px; font-weight: 500;
  text-decoration: none; position: relative; padding: 4px 0;
  transition: color .2s;
}
.topbar-nav a:hover { color: #fff; }
[data-theme="light"] .topbar-nav a:hover { color: var(--text); }
.topbar-nav a::after {
  content: ''; position: absolute; bottom: 0; left: 0;
  width: 0%; height: 2px; background: var(--accent); transition: width .3s ease;
}
.topbar-nav a:hover::after { width: 100%; }

.topbar-actions { display: flex; gap: 10px; }
.icon-btn {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 50%;
  width: 40px; height: 40px; cursor: pointer;
  display: grid; place-items: center; font-size: 18px; transition: all .2s;
}
.icon-btn:hover { background: var(--bg-3); border-color: var(--accent); transform: rotate(15deg) scale(1.05); }

.custom-select { position: relative; min-width: 180px; }
.cs-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; gap: 10px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 16px; font-size: 14px; font-family: inherit; cursor: pointer;
  transition: all .2s;
}
.cs-trigger:hover { border-color: var(--accent); }
.cs-arrow { transition: transform .2s; color: var(--muted); }
.custom-select.open .cs-arrow { transform: rotate(180deg); }
.cs-list {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); padding: 8px; list-style: none;
  max-height: 300px; overflow: auto; opacity: 0; visibility: hidden;
  transform: translateY(-6px); transition: opacity .2s, transform .2s, visibility .2s; z-index: 50;
}
.custom-select.open .cs-list { opacity: 1; visibility: visible; transform: translateY(0); }
.cs-list li a {
  display: block; padding: 10px 14px; border-radius: 8px;
  color: var(--text); font-size: 14px; text-decoration: none; transition: background .2s;
}
.cs-list li a:hover { background: var(--accent); color: #fff; }

/* =========================================================
   HERO BLOCK (KINOPOISK STYLE)
   ========================================================= */
.hero-block {
  position: relative; min-height: 520px; display: flex; align-items: center;
  background-color: var(--bg); background-size: cover; background-position: center 20%;
  padding: 60px 0; border-bottom: 1px solid var(--border);
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(13,13,16,1) 0%, rgba(13,13,16,0.9) 35%, rgba(13,13,16,0.4) 70%, rgba(13,13,16,0.1) 100%);
  z-index: 1;
}
[data-theme="light"] .hero-overlay {
  background: linear-gradient(90deg, rgba(245,245,247,1) 0%, rgba(245,245,247,0.9) 35%, rgba(245,245,247,0.4) 70%, rgba(245,245,247,0.1) 100%);
}
.hero-inner { position: relative; z-index: 2; }
.hero-content { max-width: 650px; }
.hero-logo { margin-bottom: 20px; }
.logo-prefix { display: block; font-size: 12px; letter-spacing: 4px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.hero-logo h1 {
  font-family: 'Bebas Neue', sans-serif; font-size: 64px; line-height: 1;
  color: #e50914; letter-spacing: 1px; margin: 0; text-shadow: 0 0 20px rgba(229, 9, 20, 0.4);
}
.hero-rating { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; font-size: 14px; color: #ccc; }
[data-theme="light"] .hero-rating { color: var(--muted); }
.rating-badge { background: #3bb33b; color: #000; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.meta-text { display: flex; align-items: center; gap: 4px; }
.age-limit { border: 1px solid #555; padding: 1px 6px; border-radius: 3px; font-size: 12px; }
.hero-desc-short { font-size: 15px; line-height: 1.5; color: #ddd; margin-bottom: 20px; }
[data-theme="light"] .hero-desc-short { color: var(--text); }
.hero-credits { font-size: 14px; color: #999; margin-bottom: 24px; }
.credit-row { margin-bottom: 6px; }
.credit-label { color: var(--muted); }
.credit-value { color: #ccc; }
[data-theme="light"] .credit-value { color: var(--text); }
.hero-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* =========================================================
   КНОПКИ
   ========================================================= */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 6px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .2s; border: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: var(--bg-3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--muted); }
.btn-large { padding: 14px 32px; font-size: 15px; border-radius: 8px; }
.btn-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; font-size: 18px; cursor: pointer; display: grid; place-items: center; transition: all 0.2s;
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

/* =========================================================
   ОСНОВНОЙ КОНТЕНТ
   ========================================================= */
.main-content { padding-top: 40px; padding-bottom: 60px; }
.block-title {
  font-family: 'Bebas Neue', sans-serif; font-size: 28px;
  letter-spacing: 1px; margin-bottom: 20px; color: #fff;
}
[data-theme="light"] .block-title { color: var(--text); }

.seasons-section { margin-bottom: 40px; }
.season-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.season-tab {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--muted);
  display: grid; place-items: center; text-decoration: none;
  font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.season-tab:hover { background: var(--bg-2); color: var(--text); border-color: var(--muted); }
.season-tab.active { background: #fff; color: #000; border-color: #fff; }
[data-theme="light"] .season-tab.active { background: var(--text); color: var(--bg); }

.episodes-carousel {
  display: flex; gap: 16px; overflow-x: auto; padding-bottom: 20px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.episodes-carousel::-webkit-scrollbar { height: 6px; }
.episodes-carousel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.carousel-card { flex: 0 0 260px; text-decoration: none; color: var(--text); }
.carousel-thumb {
  width: 100%; aspect-ratio: 16/9; background-color: var(--bg-3);
  background-size: cover; background-position: center;
  border-radius: 8px; margin-bottom: 10px; transition: transform 0.2s;
}
.carousel-card:hover .carousel-thumb { transform: scale(1.03); }
.carousel-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carousel-duration { font-size: 12px; color: var(--muted); }

.description-section { margin-bottom: 40px; }
.text-content p { color: var(--muted); font-size: 15px; line-height: 1.6; max-width: 800px; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; }
.info-col h3 { font-size: 20px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.info-list dt { color: var(--muted); font-size: 13px; margin-top: 12px; }
.info-list dd { color: var(--text); font-size: 14px; margin: 2px 0 0 0; line-height: 1.5; }

/* =========================================================
   ПЛЕЕР
   ========================================================= */
.player-page { padding: 40px 0; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.player-head h1 { font-family: 'Bebas Neue', sans-serif; font-size: 30px; letter-spacing: 2px; }
.player-meta { color: var(--muted); font-size: 13px; margin-bottom: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.player-title-wrap { display: flex; flex-direction: column; }

.video-wrap { background: #000; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 20px; }
.video-wrap video, .video-wrap iframe { width: 100%; display: block; aspect-ratio: 16/9; border: none; }
.video-note { padding: 16px; color: var(--muted); font-size: 14px; background: var(--bg-2); border-top: 1px solid var(--border); }
.video-note code { background: var(--bg-3); padding: 2px 6px; border-radius: 4px; color: var(--accent); }
.nav-episodes { display: flex; justify-content: space-between; gap: 12px; margin: 20px 0; }
.episode-desc { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; color: var(--muted); font-size: 15px; line-height: 1.6; }

/* =========================================================
   КАРТОЧКИ СЕРИЙ (в карусели)
   ========================================================= */
.season-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.season-pill { padding: 8px 16px; border-radius: 6px; background: var(--bg-3); border: 1px solid var(--border); font-size: 14px; color: var(--text); cursor: pointer; transition: all .2s; }
.season-pill:hover { background: var(--bg-2); }
.season-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.episode-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.ep-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: all .2s; position: relative; }
.ep-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.ep-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(233,30,99,.3); }
.ep-num { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.ep-thumb { aspect-ratio: 16/9; background-color: #1a1b22; background-size: cover; background-position: center; position: relative; transition: transform .3s; }
.ep-thumb::after { content: '▶'; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.85); font-size: 26px; text-shadow: 0 0 10px rgba(0,0,0,.8); background: rgba(0,0,0,.3); opacity: 0; transition: opacity .25s; z-index: 3; }
.ep-card:hover .ep-thumb::after { opacity: 1; }
.ep-thumb:not([style]) { background: linear-gradient(135deg, #1a1b22, #2a1a1a); }
.ep-thumb:not([style])::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #1a1b22 25%, #2a1b22 50%, #1a1b22 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; z-index: 1; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.ep-rating { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.75); color: #ffd166; padding: 2px 6px; border-radius: 4px; font-size: 12px; z-index: 2; }
.ep-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--accent); z-index: 2; transition: width .3s; }
.carousel-card.active {
  /* Убираем border и padding, которые ломают сетку */
  border: none;
  padding: 5px;
  margin: 5px;
  
  /* Используем box-shadow вместо рамки */
  box-shadow: 0 0 0 3px var(--accent);
  border-radius: 8px; /* Скругляем углы тени, чтобы совпадало с картинкой */
  background: transparent;
}

/* Чтобы картинка внутри не вылезала за скругленные углы */
.carousel-card.active .carousel-thumb {
  border-radius: 8px;
}
.carousel-playing { position: absolute; top: 8px; right: 8px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; box-shadow: 0 2px 8px rgba(0,0,0,.4); animation: pulse 1.5s infinite; z-index: 5; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }

/* =========================================================
   ФУТЕР
   ========================================================= */
.site-footer { border-top: 1px solid var(--border); background: #08080b; margin-top: 40px; padding: 30px 0; }
[data-theme="light"] .site-footer { background: #ffffff; }
.footer-inner { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 30px; align-items: center; }
.footer-logo { font-family: 'Bebas Neue', sans-serif; font-size: 24px; letter-spacing: 3px; color: #ff1e3c; }
.footer-col strong { display: block; margin-bottom: 4px; font-size: 13px; }
.footer-col p, .footer-col a { color: var(--muted); font-size: 13px; text-decoration: none; }
.to-top { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text); font-size: 13px; transition: all .2s; }
.to-top:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* =========================================================
   МОДАЛКА ТРЕЙЛЕРА
   ========================================================= */
.trailer-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; }
.trailer-body { position: relative; width: min(90vw, 960px); }
.trailer-body iframe { width: 100%; aspect-ratio: 16/9; border: 0; display: block; }
.trailer-close { position: absolute; top: -36px; right: 0; background: transparent; border: none; color: #fff; font-size: 32px; cursor: pointer; }

/* =========================================================
   МОБИЛЬНОЕ МЕНЮ (Бургер)
   ========================================================= */
.burger-btn { display: none; }
.mobile-menu {
  position: fixed; top: 72px; left: 0; right: 0;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px; gap: 16px;
  transform: translateY(-100%); opacity: 0; visibility: hidden;
  transition: all .3s; z-index: 99; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.mobile-menu.open { transform: translateY(0); opacity: 1; visibility: visible; }
.mobile-menu a { color: var(--text); font-size: 18px; text-decoration: none; padding: 10px 0; border-bottom: 1px solid var(--border); }

/* =========================================================
   АДАПТИВНОСТЬ
   ========================================================= */
@media (max-width: 900px) {
  .hero-logo h1 { font-size: 42px; }
  .hero-block { padding: 40px 0; min-height: auto; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .burger-btn { display: grid; }
  .topbar-nav { display: none; }
  .topbar-search { display: none; }
  .custom-select { display: none; }
  .mobile-menu { top: 60px; }
  .player-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .player-head .btn-ghost { align-self: flex-start; }
}

/* В самом низу файла, в блоке адаптивности */
@media (max-width: 768px) {
  .topbar-inner {
    display: flex;
    justify-content: space-between; /* Логотип слева, кнопки справа */
    align-items: center;
    gap: 12px;
    height: 64px;
    padding: 0 16px; /* Чуть уменьшим отступы по бокам */
  }

  /* Логотип больше не отталкивает кнопки, так как justify-content уже задан */
  .logo {
    font-size: 26px;
    margin-right: auto; /* Дополнительный пинок для кнопок вправо */
  }

  /* Скрываем лишние элементы */
  .topbar-nav, .topbar-search, .custom-select {
    display: none;
  }

  /* Кнопки */
  .topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px; /* Расстояние между луной и бургером */
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .burger-btn {
    display: grid; /* Показываем бургер */
  }

  .mobile-menu {
    top: 64px; /* Высота шапки, чтобы меню выезжало под ней */
  }
}

@media (max-width: 640px) {
  .topbar-inner { height: 60px; gap: 12px; }
  .logo { font-size: 26px; }
  .hero-block { background-position: center top; }
  .hero-overlay {
    background: linear-gradient(180deg, rgba(13,13,16,0.6) 0%, rgba(13,13,16,0.95) 60%, rgba(13,13,16,1) 100%);
  }
  [data-theme="light"] .hero-overlay {
    background: linear-gradient(180deg, rgba(245,245,247,0.6) 0%, rgba(245,245,247,0.95) 60%, rgba(245,245,247,1) 100%);
  }
  .hero-logo h1 { font-size: 36px; }
  .hero-actions { flex-wrap: wrap; }
  .info-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; }
  .graph-item { grid-template-columns: 1fr; gap: 6px; }
  .season-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .season-card { padding: 16px; }
  .season-card h3 { font-size: 1.4rem; }
  .season-card p { font-size: .75rem; }
  .player-head h2 { font-size: 1.8rem; }
}

/* =========================================================
   ПОИСК: ГОРИЗОНТАЛЬНЫЕ КАРТОЧКИ
   ========================================================= */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-card {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}

.search-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  background: var(--bg-3);
}

.search-thumb {
  aspect-ratio: 16/9;
  background-color: var(--bg-3);
  background-size: cover;
  background-position: center;
  position: relative;
}

.search-thumb::after {
  content: '▶';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.85);
  font-size: 32px;
  text-shadow: 0 0 10px rgba(0,0,0,.8);
  background: rgba(0,0,0,.3);
  opacity: 0;
  transition: opacity 0.25s;
}

.search-card:hover .search-thumb::after {
  opacity: 1;
}

.search-rating {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,.8);
  color: #ffd166;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.search-body {
  padding: 16px 20px 16px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.search-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #fff;
}

[data-theme="light"] .search-title {
  color: var(--text);
}

.search-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Адаптивность для поиска */
@media (max-width: 768px) {
  .search-card {
    grid-template-columns: 140px 1fr;
    gap: 12px;
  }
  .search-body {
    padding: 12px 12px 12px 0;
  }
  .search-title {
    font-size: 15px;
    margin-bottom: 4px;
  }
  .search-desc {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }
}