/* ============================================================
   Кино Mini App — "cinematic dark" design system.
   Netflix-подобный опыт: всегда тёмная тема (как у стримингов),
   красный фирменный акцент, hero-билборд, горизонтальные ряды,
   нижняя навигация. Палитра фиксированная — тема Telegram
   сознательно игнорируется (кино смотрят в темноте).
   ============================================================ */

:root {
  --bg: #0a0a10;
  --bg-elevated: #16161f;
  --text: #f5f5f7;
  --hint: #8e93a3;
  --accent: #e50914;          /* фирменный красный */
  --accent-press: #b8070f;

  /* Старые имена переменных оставлены: их использует экран деталей. */
  --tg-bg: var(--bg);
  --tg-text: var(--text);
  --tg-hint: var(--hint);
  --tg-link: #6ab3f3;
  --tg-button: var(--accent);
  --tg-button-text: #ffffff;
  --tg-secondary-bg: var(--bg-elevated);
  --tg-accent-text: #ff6b74;
  --tg-section-header-text: var(--hint);

  --card-bg: #16161f;
  --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 0 12px 28px -14px rgba(0, 0, 0, 0.7);
  --card-shadow-active: 0 1px 2px rgba(0, 0, 0, 0.4);
  --skeleton-base: #1c1c26;
  --skeleton-shine: #262632;
  --divider: rgba(255, 255, 255, 0.09);
  --overlay-scrim: rgba(8, 8, 14, 0.6);

  --rating-good-bg: rgba(52, 211, 153, 0.16);
  --rating-good-fg: #4ade80;
  --rating-mid-bg: rgba(251, 191, 36, 0.16);
  --rating-mid-fg: #fbbf24;
  --rating-low-bg: rgba(248, 113, 113, 0.16);
  --rating-low-fg: #f87171;
  --rating-none-bg: rgba(255, 255, 255, 0.08);
  --rating-none-fg: #9aa3af;

  /* Высота нижней навигации — контент отступает на неё снизу. */
  --nav-height: calc(58px + env(safe-area-inset-bottom, 0px));

  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

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

/* Belt-and-braces: guarantee the `hidden` attribute always hides an
   element, even when a component's own class also sets `display`. */
[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
}

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

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------------- Topbar ---------------- */

/* Прозрачный поверх hero; при скролле app.js вешает .scrolled (тёмная
   подложка c блюром). В режимах сетки (.solid) подложка постоянная. */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: transparent;
  transition: background-color 0.25s ease;
}

.topbar.scrolled,
.topbar.solid {
  background: rgba(10, 10, 16, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
}

.wordmark {
  margin: 0;
  flex: 1;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-shadow: 0 1px 12px rgba(229, 9, 20, 0.35);
  user-select: none;
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  opacity: 0.6;
}

/* Строка поиска (режим поиска) */

.search-row {
  gap: 10px;
}

.search-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 0 12px;
  height: 40px;
  gap: 8px;
  box-shadow: inset 0 0 0 1px var(--divider);
}

.search-icon {
  flex: none;
  color: var(--hint);
}

#search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15.5px;
  height: 100%;
  padding: 0;
}

#search-input::placeholder {
  color: var(--hint);
}

#search-input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: var(--hint);
  opacity: 0.35;
  color: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.search-clear:active {
  opacity: 0.5;
}

.search-cancel {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 2px;
  cursor: pointer;
}

.search-cancel:active {
  opacity: 0.6;
}

/* ---------------- Screens ---------------- */

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen-list {
  padding-bottom: var(--nav-height);
}

/* ============================================================
   HOME: hero-билборд
   ============================================================ */

.home {
  display: flex;
  flex-direction: column;
}

.hero {
  position: relative;
  overflow: hidden;
}

/* Слайды растянуты на весь блок и перекрещиваются по opacity. Высота —
   распорка: отступ под топбар (~76px) + высота постера (2:3 от ширины
   в .hero-poster: clamp(150px,54vw,220px) * 1.5) + подпись (~110px). */
.hero-slides {
  position: relative;
  height: calc(env(safe-area-inset-top, 0px) + clamp(225px, 81vw, 330px) + 186px);
}

.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
}

.hero-slide.active {
  opacity: 1;
  pointer-events: auto;
}

/* Размытая «аура» из того же постера — кинематографичный фон. */
.hero-ambient {
  position: absolute;
  inset: -12%;
  background-size: cover;
  background-position: center 25%;
  filter: blur(42px) brightness(0.45) saturate(1.35);
  transform: scale(1.25);
}

/* Горизонтальный кадр из фильма (backdrop_path из TMDB): почти резкий,
   затемнённый — кинематографичный фон слайда, как billboard у Netflix.
   Лёгкий blur прячет артефакты сжатия w780 на больших экранах. */
.hero-ambient.sharp {
  inset: 0;
  background-position: center 20%;
  filter: blur(2px) brightness(0.5) saturate(1.2);
  transform: scale(1.08);
}

.hero-ambient.no-image {
  background: radial-gradient(120% 90% at 50% 0%, #262636 0%, var(--bg) 75%);
  filter: none;
  transform: none;
}

.hero-poster,
.hero-poster-placeholder {
  position: relative;
  z-index: 2;
  width: clamp(150px, 54vw, 220px);
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  background: var(--card-bg);
}

.hero-slide.active .hero-poster {
  animation: hero-poster-in 7s ease-out both;
}

@keyframes hero-poster-in {
  from {
    transform: scale(1.045);
  }
  to {
    transform: scale(1);
  }
}

.hero-poster-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
}

.hero-poster-placeholder svg {
  width: 30%;
  height: 30%;
  opacity: 0.55;
}

.hero-text {
  position: relative;
  z-index: 2;
  padding: 16px 24px 0;
  text-align: center;
  max-width: 480px;
}

.hero-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(245, 245, 247, 0.85);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.hero-meta .hero-star {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}

.hero-meta .hero-star svg {
  width: 13px;
  height: 13px;
}

.hero-meta .hero-star.good { color: var(--rating-good-fg); }
.hero-meta .hero-star.mid { color: var(--rating-mid-fg); }
.hero-meta .hero-star.low { color: var(--rating-low-fg); }
.hero-meta .hero-star.none { color: var(--rating-none-fg); }

.hero-meta .dot {
  opacity: 0.5;
}

/* Градиент вниз в фон страницы — hero «растворяется» в контенте. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 16, 0.55) 0%,
    transparent 22%,
    transparent 62%,
    var(--bg) 100%
  );
}

/* Кнопка + точки поверх градиента */
.hero-panel {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 24px 6px;
  margin-top: -2px;
}

.btn-watch {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(100%, 300px);
  padding: 13px 20px;
  border-radius: 10px;
  background: #ffffff;
  color: #0a0a10;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn-watch:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.hero-dots {
  display: flex;
  gap: 7px;
  padding: 2px 0;
}

.hero-dot {
  appearance: none;
  border: 0;
  padding: 0;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: width 0.25s ease, background-color 0.25s ease;
}

.hero-dot.active {
  width: 22px;
  background: var(--accent);
}

/* ============================================================
   HOME: горизонтальные ряды
   ============================================================ */

.rows {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 18px 0 10px;
}

.row-title {
  margin: 0 16px 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.row-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 16px 6px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.row-scroll::-webkit-scrollbar {
  display: none;
}

.row-card {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  flex: 0 0 auto;
  scroll-snap-align: start;
  position: relative;
}

.row-card .poster {
  position: relative;
  width: 111px;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.row-card:active .poster {
  transform: scale(0.95);
  box-shadow: var(--card-shadow-active);
}

.row-card .poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.row-card .poster img.loaded {
  opacity: 1;
}

/* «Топ 10» — большая цифра позади постера, как у Netflix. */
.row-card.numbered {
  padding-left: 50px;
}

.row-card.numbered .rank {
  position: absolute;
  left: -2px;
  bottom: 0;
  z-index: 0;
  font-size: 96px;
  line-height: 0.8; /* прижать глиф к низу, чтобы его не клипал скролл-контейнер */
  font-weight: 900;
  letter-spacing: -0.06em;
  color: var(--bg);
  -webkit-text-stroke: 2.5px rgba(255, 255, 255, 0.45);
  user-select: none;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.row-card.numbered .poster {
  position: relative;
  z-index: 1;
}

/* Плейсхолдер без постера: иконка + название, чтобы карточка не была немой. */
.poster-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(155deg, #1d1d29, var(--card-bg));
  color: var(--hint);
}

.poster-placeholder svg {
  width: 30%;
  height: 30%;
  opacity: 0.55;
}

.poster-placeholder .ph-title {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  color: var(--text);
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Blur-заглушка ThumbHash (см. thumbDataURL в app.js): вместо иконки — размытая
   миниатюра постера фоном. Вешается и на плейсхолдеры, и на <img> с фиксированной
   геометрией (hero/detail) — фон виден, пока грузится настоящая картинка. */
.ph-blur {
  background-size: cover;
  background-position: 50% 50%;
}

.ph-blur svg {
  display: none;
}

/* Бейдж рейтинга на постере */
.badge-on-image {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 3px 6px;
  border-radius: 20px;
  background: var(--overlay-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}

.badge-dot.good { background: #34d399; }
.badge-dot.mid { background: #fbbf24; }
.badge-dot.low { background: #f87171; }
.badge-dot.none { background: #9aa3af; }

/* ---------------- Home skeleton ---------------- */

.home-skeleton {
  padding-bottom: 20px;
}

.sk-hero {
  height: calc(env(safe-area-inset-top, 0px) + 380px);
  border-radius: 0 0 24px 24px;
  margin-bottom: 26px;
}

.sk-row {
  padding: 0 16px;
  margin-bottom: 26px;
}

.sk-row-title {
  width: 40%;
  height: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.sk-row-cards {
  display: flex;
  gap: 10px;
  overflow: hidden;
}

.sk-row-card {
  flex: 0 0 auto;
  width: 111px;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
}

/* ============================================================
   GRID (поиск / избранное / история)
   ============================================================ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 18px 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 74px) 16px 8px;
}

@media (min-width: 560px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 22px 14px;
    padding-left: 20px;
    padding-right: 20px;
  }
}

.card {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: card-in 0.32s ease both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.card:active .card-poster {
  transform: scale(0.96);
  box-shadow: var(--card-shadow-active);
}

.card-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-poster img.loaded {
  opacity: 1;
}

.card-info {
  padding: 0 1px;
}

.card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}

.card-meta {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Rating pill (detail meta row) */
.rating-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1;
}

.rating-pill.good { background: var(--rating-good-bg); color: var(--rating-good-fg); }
.rating-pill.mid { background: var(--rating-mid-bg); color: var(--rating-mid-fg); }
.rating-pill.low { background: var(--rating-low-bg); color: var(--rating-low-fg); }
.rating-pill.none { background: var(--rating-none-bg); color: var(--rating-none-fg); }

.rating-pill svg {
  width: 13px;
  height: 13px;
}

/* ---------------- Skeleton base ---------------- */

.skeleton {
  background: linear-gradient(
    100deg,
    var(--skeleton-base) 30%,
    var(--skeleton-shine) 50%,
    var(--skeleton-base) 70%
  );
  background-size: 220% 100%;
  animation: shine 1.4s ease-in-out infinite;
}

@keyframes shine {
  0% { background-position: 140% 0; }
  100% { background-position: -40% 0; }
}

.skeleton-card .card-poster {
  box-shadow: none;
}

.skeleton-line {
  height: 10px;
  border-radius: 6px;
  margin-top: 8px;
}

.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .card { animation: none; }
  .hero-slide { transition: none; }
  .hero-slide.active .hero-poster { animation: none; }
}

/* ---------------- Load-more / sentinel ---------------- */

.sentinel {
  height: 1px;
}

.loading-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 0 28px;
  color: var(--hint);
  font-size: 13px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--divider);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.load-more-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 0 28px;
  color: var(--hint);
  font-size: 13px;
}

.btn-retry-inline {
  appearance: none;
  border: 0;
  background: var(--card-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.btn-retry-inline:active {
  opacity: 0.8;
}

/* ---------------- Empty / error states ---------------- */

.state-empty,
.state-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(env(safe-area-inset-top, 0px) + 110px) 32px 80px;
  gap: 14px;
  color: var(--hint);
}

.state-icon {
  width: 68px;
  height: 68px;
  color: var(--hint);
  opacity: 0.7;
}

.state-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text);
}

.state-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  max-width: 30ch;
}

.btn-retry {
  margin-top: 4px;
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 12px;
  cursor: pointer;
}

.btn-retry:active {
  background: var(--accent-press);
}

/* ============================================================
   Bottom nav
   ============================================================ */

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(12, 12, 18, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--hint);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}

.nav-btn svg {
  width: 23px;
  height: 23px;
}

.nav-btn.active {
  color: var(--text);
}

.nav-btn.active svg {
  color: var(--accent);
}

/* ============================================================
   Detail screen
   ============================================================ */

.screen-detail {
  padding-bottom: 24px;
}

.detail-hero {
  position: relative;
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
  background: var(--card-bg);
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 20%;
  filter: blur(26px) brightness(0.5) saturate(1.25);
  transform: scale(1.2);
}

/* С backdrop подложка почти резкая (кадр из фильма), без него — блюр постера. */
.detail-backdrop.sharp {
  filter: blur(3px) brightness(0.55) saturate(1.15);
  transform: scale(1.08);
}

.detail-backdrop.no-image {
  background: linear-gradient(160deg, #1d1d29, var(--bg));
  filter: none;
  transform: none;
}

.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0%,
    transparent 35%,
    var(--bg) 96%
  );
}

.detail-back,
.detail-fav {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  z-index: 5;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--overlay-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.detail-back {
  left: 14px;
}

.detail-back:active {
  opacity: 0.75;
}

.detail-fav {
  right: 14px;
  transition: transform 0.12s ease, color 0.12s ease;
}

.detail-fav:active {
  transform: scale(0.88);
}

.detail-fav.active {
  color: #ff5c6c;
}

.detail-fav.active svg path {
  fill: #ff5c6c;
}

.detail-poster-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: 46px 0 18px;
}

.detail-poster {
  width: 168px;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.8);
  background: var(--card-bg);
}

.detail-poster-placeholder {
  width: 168px;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.8);
  background: linear-gradient(155deg, #1d1d29, var(--card-bg));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
}

.detail-poster-placeholder svg {
  width: 30%;
  height: 30%;
  opacity: 0.55;
}

.detail-body {
  position: relative;
  z-index: 2;
  padding: 0 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.detail-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.detail-original {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--hint);
}

.detail-meta {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.detail-meta .meta-chip {
  font-size: 13.5px;
  color: var(--hint);
  font-weight: 500;
}

.detail-meta .meta-dot {
  color: var(--hint);
  opacity: 0.6;
}

.detail-overview {
  margin: 20px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  text-align: left;
  align-self: stretch;
  white-space: pre-line;
}

.detail-overview.is-empty {
  color: var(--hint);
  text-align: center;
  font-style: italic;
}

.detail-spacer {
  height: 88px;
}

/* Detail skeleton */

.detail-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 46px) 22px 0;
}

.detail-skeleton .sk-poster {
  width: 168px;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
}

.detail-skeleton .sk-line {
  height: 14px;
  border-radius: 7px;
  margin-top: 18px;
}

.detail-skeleton .sk-line.w1 { width: 70%; }

.detail-skeleton .sk-line.w2 {
  width: 40%;
  height: 11px;
  margin-top: 10px;
}

.detail-skeleton .sk-para {
  width: 100%;
  height: 11px;
  border-radius: 6px;
  margin-top: 10px;
}

/* ---------------- Seasons + variants ---------------- */

.section-label {
  align-self: stretch;
  text-align: left;
  margin: 24px 0 10px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hint);
}

.seasons {
  align-self: stretch;
}

.season-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.season-chip {
  appearance: none;
  border: 1px solid var(--divider);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.season-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.variants {
  align-self: stretch;
}

.variant-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.variant-row {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--divider);
  border-radius: 14px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.variant-row:active {
  transform: scale(0.99);
  box-shadow: var(--card-shadow-active);
}

.variant-row.loading {
  opacity: 0.6;
  pointer-events: none;
}

.variant-play {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(229, 9, 20, 0.16);
  color: #ff6b74;
}

.variant-play svg {
  width: 16px;
  height: 16px;
}

.variant-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.variant-quality {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

/* Бейдж версии/издания («Ч/Б», «Режиссёрская версия»…) рядом с качеством. */
.variant-edition {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(229, 9, 20, 0.16);
  color: #ff6b74;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  vertical-align: 2px;
  white-space: nowrap;
}

.variant-audio {
  font-size: 13px;
  color: var(--hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variant-size {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

.variants-empty {
  color: var(--hint);
  font-style: italic;
  font-size: 14px;
  text-align: center;
  margin: 8px 0 0;
}

/* ---------------- Desktop tweaks ---------------- */

@media (min-width: 720px) {
  .topbar {
    padding-left: 28px;
    padding-right: 28px;
  }
  .hero-poster,
  .hero-poster-placeholder {
    width: 240px;
  }
  .hero-slides {
    /* постер 240px -> 360px высоты + те же 186px обвязки */
    height: calc(env(safe-area-inset-top, 0px) + 546px);
  }
  .hero-title {
    font-size: 30px;
  }
  .row-card .poster {
    width: 138px;
  }
  .row-title {
    margin-left: 28px;
  }
  .row-scroll {
    padding-left: 28px;
    padding-right: 28px;
  }
  .detail-poster,
  .detail-poster-placeholder {
    width: 220px;
  }
  .detail-title {
    font-size: 28px;
  }
  .detail-body {
    padding: 0 32px;
  }
}

/* ---------------- Paywall: подписка (Telegram Stars) ----------------
   Нижний лист поверх всего приложения (см. index.html #paywall и app.js).
   Стилистика — как у остального «кинотеатра»: тёмный лист, красный CTA. */

.paywall-overlay {
  position: fixed;
  inset: 0;
  z-index: 60; /* выше topbar/bottomnav и экранов */
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.paywall-scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 8, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.paywall-sheet {
  position: relative;
  width: min(100%, 480px);
  background: var(--bg-elevated);
  border-radius: 22px 22px 0 0;
  padding: 26px 22px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -18px 50px -12px rgba(0, 0, 0, 0.8);
  animation: paywall-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  .paywall-sheet { animation: none; }
}

@keyframes paywall-in {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.paywall-close {
  appearance: none;
  border: 0;
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--hint);
  cursor: pointer;
}

.paywall-star {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 10px;
}

.paywall-title {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text);
}

.paywall-features {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.paywall-features li {
  position: relative;
  padding-left: 26px;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.35;
}

.paywall-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--rating-good-fg);
  font-weight: 800;
}

.paywall-buy {
  appearance: none;
  border: 0;
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 12px 30px -10px rgba(229, 9, 20, 0.55);
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.paywall-buy:active {
  transform: scale(0.98);
  background: var(--accent-press);
}

.paywall-buy:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.paywall-status {
  margin: 12px 2px 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--tg-accent-text);
}

.paywall-note {
  margin: 12px 2px 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--hint);
}

/* ---------------- Utility ---------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ============================================================
   Интро при запуске (à la Netflix)
   Тайминг: буквы сходятся и вспыхивают (~1.1s) → короткая пауза →
   шторка растворяется (~0.5s, начало на 1.35s). app.js удаляет узел
   по animationend самой шторки, чтобы она не висела в DOM.
   ============================================================ */
#splash {
  position: fixed;
  inset: 0;
  z-index: 1000;              /* поверх topbar, шторок и карточек */
  display: grid;
  place-items: center;
  background: #000;
  animation: splash-out 0.5s ease 1.35s forwards;
  pointer-events: none;       /* не блокируем тапы, если что-то пойдёт не так */
}

.splash-logo {
  font-size: clamp(34px, 11vw, 64px);
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.08em;
  user-select: none;
  animation: splash-logo-in 1.1s cubic-bezier(0.16, 0.8, 0.3, 1) both;
}

@keyframes splash-logo-in {
  0%   { transform: scale(1.45); letter-spacing: 0.55em; opacity: 0; filter: blur(10px); }
  38%  { opacity: 1; }
  70%  { filter: blur(0); text-shadow: 0 0 34px rgba(229, 9, 20, 0.65), 0 0 90px rgba(229, 9, 20, 0.35); }
  100% { transform: scale(1); letter-spacing: 0.08em; opacity: 1;
         text-shadow: 0 0 18px rgba(229, 9, 20, 0.45), 0 0 60px rgba(229, 9, 20, 0.22); }
}

@keyframes splash-out {
  to { opacity: 0; visibility: hidden; }
}

/* Слабое «дыхание» тьмы вокруг логотипа — глубина как у кинозаставки. */
#splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(229, 9, 20, 0.10), transparent 60%);
  opacity: 0;
  animation: splash-glow 1.2s ease 0.25s both;
}

@keyframes splash-glow {
  0% { opacity: 0; }
  60% { opacity: 1; }
  100% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  #splash { display: none; }
}
