/* Экран «Деталь фильма/сериала». */

.detail {
  padding-bottom: calc(104px + var(--safe-bottom));
}

/* --- Шапка с размытым бэкдропом --- */
.detail__hero {
  position: relative;
  height: 236px;
}

.detail__backdrop {
  position: absolute;
  inset: 0;
  background-image: var(--backdrop, none);
  background-position: center 30%;
  background-size: cover;
}

.detail__backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(23, 20, 27, 0.2) 0%, rgba(23, 20, 27, 0.62) 58%, var(--bg) 100%);
}

.detail__backdrop--empty {
  background-image: linear-gradient(150deg, #453a52 0%, #2a2334 48%, var(--bg) 100%);
}

.detail__topbar {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--sp-2) + var(--safe-top)) var(--sp-3) 0;
}

/* --- Постер и заголовок --- */
.detail__head {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: var(--sp-4);
  margin-top: -68px;
  padding: 0 var(--gutter);
}

.detail__poster {
  flex: 0 0 96px;
  width: 96px;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.detail__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail__intro {
  min-width: 0;
  padding-bottom: 2px;
}

.detail__type {
  color: var(--cat, var(--text-2));
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail__title {
  margin-top: 5px;
  font-size: var(--fs-display);
  font-weight: 800;
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.detail__original {
  margin-top: 3px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.detail__meta {
  margin-top: 6px;
  color: var(--text-2);
  font-size: var(--fs-sm);
}

.detail__score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.detail__votes {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

/* --- Жанры --- */
.detail__genres {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--gutter) 0;
}

/* --- Библиотека: бейдж и оценка --- */
.library {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--gutter) 0;
}

.library__badge {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--r-2);
  background: rgba(143, 188, 154, 0.16);
  color: var(--status-finished);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.library__rating {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--r-2);
  background: rgba(242, 203, 107, 0.14);
  color: var(--rating);
  font-size: var(--fs-sm);
  font-weight: 800;
}

/* --- Описание --- */
.detail__overview {
  color: var(--text-2);
  font-size: var(--fs-body);
  line-height: 1.55;
  white-space: pre-line;
}

.detail__overview--clamped {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.section .link-btn {
  margin-top: var(--sp-2);
}

/* Офлайн блок «Похожее» скрыт, пока нет сети. */
body.is-offline .similar-section {
  display: none;
}

/* --- Нижняя панель действий --- */
.action-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  display: flex;
  gap: var(--sp-2);
  width: 100%;
  max-width: 430px;
  padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + var(--safe-bottom));
  /* Без тёмного градиента: кнопки сами стеклянные, а пустая зона не перекрывает контент. */
  background: transparent;
  transform: translateX(-50%);
  pointer-events: none;
}

.action-bar > * {
  pointer-events: auto;
}

/* Стеклянные кнопки статуса и удаления — в одном стиле с нижней панелью. */
.action-bar .btn--done,
.action-bar .btn--ghost {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
}

.action-bar .btn--done {
  border-color: color-mix(in srgb, var(--status-color) 45%, var(--glass-border));
  background:
    linear-gradient(
      color-mix(in srgb, var(--status-color) 20%, transparent),
      color-mix(in srgb, var(--status-color) 9%, transparent)
    ),
    var(--glass-bg);
  color: var(--status-color);
}

.action-bar .btn--ghost {
  color: var(--text);
}

/* Основная кнопка добавления: стеклянная, с полупрозрачной акцентной подложкой. */
.action-bar .btn--primary {
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--glass-border));
  background:
    linear-gradient(
      color-mix(in srgb, var(--accent) 64%, transparent),
      color-mix(in srgb, var(--accent) 46%, transparent)
    ),
    var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  color: var(--accent-ink);
  box-shadow:
    var(--glass-shadow),
    0 12px 30px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Ручные часы в игре — только для игр из библиотеки. */
.hours-form {
  display: grid;
  gap: var(--sp-4);
}

.hours-field {
  display: grid;
  gap: 6px;
}

.hours-field > span {
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hours-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

/* --- Дев-переключатель состояний (только preview.html) --- */
.dev-bar {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 50%;
  z-index: 90;
  display: flex;
  gap: var(--sp-1);
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: rgba(12, 10, 16, 0.86);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
}

.dev-bar button {
  padding: 7px 13px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
}

.dev-bar button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Прокрутка длинной детали: запас снизу уже учтён в .detail. */
@media (min-width: 480px) {
  .action-bar {
    border-radius: var(--r-4) var(--r-4) 0 0;
  }
}

/* --- Скелетоны фоновой догрузки --- */
.sk-block {
  pointer-events: none;
}

.sk {
  height: 12px;
  margin-top: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.4s ease infinite;
}

.sk--title {
  width: 42%;
  height: 18px;
  margin-top: 0;
}

.sk--line:nth-child(3) {
  width: 74%;
}

@keyframes sk-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* --- Мягкая ошибка догрузки --- */
.enrich-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-5) var(--gutter) 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* ============ Меню детали ============ */
.menu-list {
  display: grid;
  gap: 2px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 10px;
  border-radius: var(--r-2);
  color: var(--text);
  text-align: left;
}

.menu-item:active {
  background: var(--surface-2);
}

@media (hover: hover) {
  .menu-item:hover {
    background: var(--surface-2);
  }
}

.menu-item__icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--accent-soft);
}

.menu-item__icon svg {
  width: 19px;
  height: 19px;
}

.menu-item__text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.menu-item__label {
  font-size: var(--fs-sm);
  font-weight: 700;
}

.menu-item__hint {
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.menu-item--danger .menu-item__icon {
  background: rgba(255, 120, 100, 0.1);
  color: #ff9b8f;
}

.menu-item--danger .menu-item__label {
  color: #ff9b8f;
}

/* ============ Игра: детали, языки, требования ============ */
.facts__row--stack {
  display: block;
}

.facts__row--stack .facts__key {
  margin-bottom: 6px;
}

.facts__val--block {
  text-align: left;
}

.lang-groups,
.req-groups {
  display: grid;
  gap: var(--sp-3);
}

.lang-group__label,
.req-group__label {
  margin-bottom: 3px;
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lang-list,
.req-list {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.req-list {
  padding-left: 18px;
  list-style: disc;
}

.req-list li + li {
  margin-top: 3px;
}

.clamp-list {
  max-height: 5.2em;
  overflow: hidden;
}

.clamp-list.is-open {
  max-height: none;
}

.clamp-toggle {
  margin-top: 6px;
}

/* ============ Галерея игры ============ */
.gallery {
  display: flex;
  gap: var(--sp-3);
  margin-inline: calc(var(--gutter) * -1);
  padding: 2px var(--gutter) var(--sp-2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.gallery__item {
  position: relative;
  flex: 0 0 min(78vw, 320px);
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.gallery__item.is-missing {
  display: none;
}

.gallery__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gallery__img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gallery__item.is-loaded .gallery__img {
  opacity: 1;
}

.gallery__skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.4s ease infinite;
}

.gallery__item.is-loaded .gallery__skeleton {
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* ============ Полноэкранный просмотр ============ */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
  overflow: hidden;
}

.lightbox::backdrop {
  background: #000;
}

.lightbox__track {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x;
}

.lightbox__track::-webkit-scrollbar {
  display: none;
}

.lightbox__slide {
  display: grid;
  flex: 0 0 100%;
  place-items: center;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
}

.lightbox__slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox__close {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  box-shadow: var(--glass-shadow);
  color: var(--text);
}

.lightbox__close svg {
  width: 20px;
  height: 20px;
}

.lightbox__counter {
  position: fixed;
  bottom: calc(18px + var(--safe-bottom));
  left: 50%;
  z-index: 2;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(13, 14, 18, 0.72);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 700;
  transform: translateX(-50%);
}
