/*
 * «Ночь» — ночная афиша игры (из бывшего варианта 3 «Ночная Хотару»).
 * Каждая игра — широкий кадр во всю ширину экрана, как афиша в кинотеатре; текст лежит на тёмной
 * стороне кадра, статус — бумажная бирка, кнопка «Скачать игру» — цвета тории. Под кадром — лента кадров
 * с плиткой «Все кадры», по щелчку открывается просмотр. Следующая игра в списке зеркалится: текст справа.
 *
 * Анимация (только когда скрипт поставил на <html> класс .motion — без него всё видно сразу и неподвижно):
 * кадр проявляется из темноты и медленно наезжает; название проступает мазком кисти, бирка качается
 * на нитке, жанр, строка и кнопки всплывают по очереди; над кадром летают светлячки;
 * лента кадров выезжает при прокрутке.
 */

/* ---------- Кадр игры ---------- */

.feature { position: relative; }
.feature + .feature { margin-top: clamp(3rem, 8vw, 6rem); }

/* Сцена: кадр лежит под текстом во всю ширину, текст прижат к низу */
.feature__stage {
  position: relative;
  min-height: clamp(34rem, 82vh, 54rem);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.feature__shot {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
/* Картинка с запасом по высоте: при прокрутке она сдвигается медленнее текста */
.feature__pan {
  position: absolute;
  inset: -9% 0;
  transform: translate3d(0, var(--pan, 0px), 0);
}
.feature__pan img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 62% 50%;
  transform: scale(1.04);
}
/* Тёмная сторона кадра, на которой лежит текст, и уход в ночь снизу */
.feature__shot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(13, 13, 15, .96) 0%, rgba(13, 13, 15, .88) 28%, rgba(13, 13, 15, .35) 55%, rgba(13, 13, 15, 0) 75%),
    linear-gradient(to top, var(--night) 0%, rgba(13, 13, 15, .6) 18%, rgba(13, 13, 15, 0) 40%);
}
.fireflies {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.feature__text {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
  padding-block: 7rem clamp(3.5rem, 9vh, 5.5rem);
}
.feature__inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.1rem;
  max-width: 34rem;
}

/* Статус — бумажная бирка с дырочкой, висит на ней */
.tag {
  display: inline-block;
  padding: .3rem .8rem .3rem 1.45rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink);
  background:
    radial-gradient(circle at .62rem 50%, var(--night) 0 .17rem, rgba(0, 0, 0, 0) .19rem),
    var(--paper);
  clip-path: polygon(.55rem 0, 100% 0, 100% 100%, .55rem 100%, 0 50%);
  transform: rotate(-2deg);
  transform-origin: .62rem 50%;
}

.feature__title {
  font-family: var(--font-sign);
  font-size: clamp(2.7rem, 6.2vw, 5.4rem);
  line-height: 1.04;
  color: var(--light);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}
.feature__genre {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--lantern);
}
.feature__tagline {
  font-size: clamp(1.05rem, 1.6vw, 1.22rem);
  line-height: 1.55;
  color: var(--light);
  max-width: 32ch;
}
/* Кнопка цвета тории; при наведении по ней проходит отблеск фонаря */
.cta {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin-top: .4rem;
  padding: .85rem 1.35rem;
  border-radius: 4px;
  font-weight: 600;
  color: var(--light);
  text-decoration: none;
  background-color: var(--torii);
  background-image: linear-gradient(110deg, rgba(255, 210, 160, 0) 35%, rgba(255, 210, 160, .22) 50%, rgba(255, 210, 160, 0) 65%);
  background-size: 260% 100%;
  background-position: 120% 0;
  box-shadow: 0 10px 24px -10px rgba(158, 58, 44, .8);
  transition: background-color .2s, background-position .8s ease;
}
.cta {
  border: 0;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.3;
  cursor: pointer;
}
.cta svg { width: 1.15em; height: 1.15em; transition: transform .25s; }
.cta:hover { background-color: var(--torii-hover); background-position: -20% 0; }
.cta:hover svg { transform: translateX(3px); }
button.cta:hover svg { transform: translateY(2px); }

/* Кнопка «Скачать игру» и ссылка «Об игре» рядом */
.feature__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .9rem 1.6rem;
  margin-top: .4rem;
}
.feature__actions .cta { margin-top: 0; }
.more-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-weight: 600;
  color: var(--light);
  text-decoration: underline;
  text-decoration-color: rgba(245, 235, 212, .4);
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
  transition: text-decoration-color .2s;
}
.more-link svg { width: 1.1em; height: 1.1em; transition: transform .25s; }
.more-link:hover { text-decoration-color: var(--lantern); }
.more-link:hover svg { transform: translateX(3px); }
/* На каких системах есть игра */
.feature__platforms {
  font-size: .82rem;
  letter-spacing: .06em;
  color: var(--muted);
}

/* Зеркальный кадр для каждой второй игры */
.feature:nth-child(even) .feature__shot::after {
  background:
    linear-gradient(270deg, rgba(13, 13, 15, .96) 0%, rgba(13, 13, 15, .88) 28%, rgba(13, 13, 15, .35) 55%, rgba(13, 13, 15, 0) 75%),
    linear-gradient(to top, var(--night) 0%, rgba(13, 13, 15, .6) 18%, rgba(13, 13, 15, 0) 40%);
}
.feature:nth-child(even) .feature__pan img { object-position: 38% 50%; }
.feature:nth-child(even) .feature__inner { margin-left: auto; }

/* ---------- Лента кадров ---------- */

.strip {
  max-width: 76rem;
  margin: clamp(-1.5rem, -2vw, -.5rem) auto 0;
  position: relative;
  z-index: 4;
}
.strip__label {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .85rem;
}
.strip__list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: clamp(.6rem, 1.4vw, 1.1rem);
}
/* Кадр — кнопка: открывает крупный просмотр */
.shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--muted);
  cursor: zoom-in;
}
.shot__frame {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 3px;
  outline: 1px solid rgba(245, 235, 212, .12);
}
/* Плитка «Все кадры»: следующий кадр под вуалью и «+13» */
.shot--all { cursor: pointer; }
.shot.shot--all img { filter: brightness(.35) saturate(.6); }
.shot__more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-sign);
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
  color: var(--light);
}
.shot.shot--all:hover img { filter: brightness(.5) saturate(.8); }
.shot--all .shot__caption { color: var(--lantern); }
.shot img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform .5s ease, filter .3s;
  filter: brightness(.88);
}
.shot__caption { display: block; margin-top: .5rem; font-size: .86rem; line-height: 1.4; transition: color .2s; }
.shot:hover img { transform: scale(1.04); filter: brightness(1); }
.shot:hover .shot__caption { color: var(--light); }

/* ---------- Анимация ---------- */

/* До появления на экране кадр и текст ждут в темноте */
.motion .feature:not(.is-in) .feature__pan img,
.motion .feature:not(.is-in) .feature__inner > *,
.motion .feature:not(.is-in) .fireflies { opacity: 0; }

/* Кадр проявляется из темноты, потом камера медленно плывёт */
.motion .feature.is-in .feature__pan img {
  animation:
    shot-in 2.6s cubic-bezier(.2, .6, .2, 1) backwards,
    drift 14s cubic-bezier(.2, .5, .3, 1) 2.6s forwards;
}
.motion .feature.is-in .fireflies { animation: fade-in 3s ease 1.4s backwards; }

/* Название проступает мазком кисти слева направо */
.motion .feature.is-in .feature__title {
  -webkit-mask-image: linear-gradient(90deg, #000 40%, rgba(0, 0, 0, 0) 60%);
  mask-image: linear-gradient(90deg, #000 40%, rgba(0, 0, 0, 0) 60%);
  -webkit-mask-size: 300% 100%;
  mask-size: 300% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: 0 0;
  mask-position: 0 0;
  animation: brush 1.5s cubic-bezier(.55, .1, .25, 1) 1s backwards;
}
.motion .feature.is-in .tag { animation: tag-swing 1.8s cubic-bezier(.3, .7, .4, 1) .7s backwards; }
.motion .feature.is-in .feature__genre { animation: rise .8s cubic-bezier(.2, .7, .2, 1) 1.8s backwards; }
.motion .feature.is-in .feature__tagline { animation: rise .8s cubic-bezier(.2, .7, .2, 1) 2s backwards; }
.motion .feature.is-in .feature__actions { animation: rise .8s cubic-bezier(.2, .7, .2, 1) 2.2s backwards; }
.motion .feature.is-in .feature__platforms { animation: rise .8s cubic-bezier(.2, .7, .2, 1) 2.35s backwards; }

/* Лента кадров выезжает по одному кадру */
.motion .strip:not(.is-in) .strip__label,
.motion .strip:not(.is-in) .shot { opacity: 0; }
.motion .strip.is-in .strip__label { animation: rise .7s ease-out backwards; }
.motion .strip.is-in .shot {
  animation: rise .9s cubic-bezier(.2, .7, .2, 1) backwards;
  animation-delay: calc(.15s + var(--k, 0) * .12s);
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes shot-in {
  0% { opacity: 0; transform: scale(1.16); filter: brightness(.15) saturate(.5); }
  35% { opacity: 1; }
  100% { transform: scale(1.04); filter: none; }
}
@keyframes drift {
  from { transform: scale(1.04) translate(0, 0); }
  to { transform: scale(1.1) translate(-1.6%, -1%); }
}
@keyframes brush {
  from { -webkit-mask-position: 100% 0; mask-position: 100% 0; filter: blur(4px); }
  to { -webkit-mask-position: 0 0; mask-position: 0 0; filter: blur(0); }
}
@keyframes tag-swing {
  0% { opacity: 0; transform: translateY(-14px) rotate(-40deg); }
  15% { opacity: 1; }
  38% { transform: rotate(14deg); }
  58% { transform: rotate(-8deg); }
  76% { transform: rotate(3deg); }
  100% { transform: rotate(-2deg); }
}

/* ---------- Узкие экраны: кадр сверху, текст под ним ---------- */

@media (max-width: 760px) {
  .feature__stage { min-height: 0; display: block; }
  .feature__shot { position: relative; aspect-ratio: 4 / 3.4; }
  .feature__pan img { object-position: 75% 50%; }
  .feature__shot::after,
  .feature:nth-child(even) .feature__shot::after {
    background:
      linear-gradient(to bottom, rgba(13, 13, 15, .6) 0%, rgba(13, 13, 15, 0) 25%),
      linear-gradient(to top, var(--night) 0%, rgba(13, 13, 15, .4) 22%, rgba(13, 13, 15, 0) 45%);
  }
  .feature__text { margin-top: -2.5rem; padding-block: 0; }
  .feature:nth-child(even) .feature__inner { margin-left: 0; }
  .strip { margin-top: 2.5rem; }
  /* Лента листается пальцем вбок, не раздвигая страницу */
  .strip__list {
    grid-auto-columns: 60%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    padding-bottom: .5rem;
    scrollbar-width: thin;
  }
  .shot { scroll-snap-align: start; }
}
