/* ROOT LAB — слой анимации. Всё движение включается классом .has-motion,
   который не ставится при prefers-reduced-motion: reduce. */

:root {
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.76, 0, 0.24, 1);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

section[id] {
  scroll-margin-top: var(--header-h);
}

/* ---------- Зерно (фактура как в референсе Bagatelle) ---------- */

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 160;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  opacity: 0.06;
}

.has-motion body::after {
  animation: grain 0.9s steps(5) infinite;
}

@keyframes grain {
  0% { background-position: 0 0; }
  20% { background-position: -8px 6px; }
  40% { background-position: 6px -10px; }
  60% { background-position: -12px -4px; }
  80% { background-position: 10px 8px; }
  100% { background-position: 0 0; }
}

/* ---------- Шторка: интро и переходы между страницами ---------- */

html.is-cover::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--c-black);
  animation: cover-fallback 0s linear 4s forwards;
}

@keyframes cover-fallback {
  to { visibility: hidden; }
}

.curtain {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: var(--s-5) var(--pad);
  background: var(--c-black);
  color: var(--c-bg);
  transition: translate 1s var(--ease-io);
}

.curtain.is-out {
  translate: 0 -100%;
}

.curtain--leave {
  translate: 0 100%;
  transition-duration: 0.7s;
}

.curtain--leave.is-in {
  translate: 0 0;
}

.curtain__mark {
  align-self: center;
  display: flex;
  justify-content: center;
  overflow: hidden;
  font-family: var(--f-cond);
  font-weight: 700;
  font-size: clamp(4.5rem, 19vw, 22rem);
  line-height: 0.82;
  letter-spacing: -0.02em;
  white-space: pre;
}

.curtain__mark span {
  display: inline-block;
  translate: 0 105%;
  animation: rise 1s var(--ease-expo) forwards;
  animation-delay: calc(0.15s + var(--i) * 55ms);
}

.curtain.is-out .curtain__mark span {
  translate: 0 0;
  animation: lift 0.8s var(--ease-io) forwards;
  animation-delay: calc(var(--i) * 25ms);
}

.curtain__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  font-family: var(--f-cond);
  font-size: var(--fs-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.curtain__count {
  font-variant-numeric: tabular-nums;
  color: var(--c-orange);
}

.curtain__bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: var(--c-orange);
  transform-origin: left;
  scale: var(--p, 0) 1;
}

.curtain__label {
  grid-row: 1 / -1;
  place-self: center;
  font-family: var(--f-cond);
  font-size: clamp(2.75rem, 1.6rem + 4.2vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

@keyframes rise {
  to { translate: 0 0; }
}

@keyframes lift {
  to { translate: 0 -105%; }
}

/* ---------- Шапка ---------- */

.scroll-progress {
  display: none;
}

.has-motion .header {
  transition: translate 0.6s var(--ease-expo), background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.has-motion.is-header-hidden .header {
  translate: 0 -100%;
}

@media (max-width: 47.99em) {
  :root {
    --header-h: calc(6.5rem + env(safe-area-inset-top, 0px));
  }

  html::before {
    content: "";
    position: fixed;
    z-index: 60;
    top: 0;
    right: 0;
    left: 0;
    height: env(safe-area-inset-top, 0px);
    background: var(--c-bg);
    pointer-events: none;
  }

  html.has-motion::before,
  html.has-motion.is-header-hidden::before {
    translate: none;
    transition: none;
  }

  .has-motion .header {
    transition: translate 0.34s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s linear,
      background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  }

  .has-motion.is-header-hidden .header {
    opacity: 0;
  }

  .has-motion .filters {
    transition: top 0.34s cubic-bezier(0.4, 0, 0.2, 1);
  }

  html:not(.is-scrolled):has(body[data-page="home"])::before {
    content: none;
  }

  .announce__text,
  html:not(.is-scrolled) [data-page="home"] .announce__text {
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body:not([data-page="home"]) .header,
  [data-page="home"] .header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }

  body:not([data-page="home"]) .header::before,
  .is-scrolled [data-page="home"] .header::before {
    content: "";
    position: absolute;
    right: 0;
    bottom: 100%;
    left: 0;
    height: 8rem;
    background: var(--c-bg);
    pointer-events: none;
  }

  body:not([data-page="home"]) {
    padding-top: var(--header-h);
  }
}

.has-motion .filters {
  transition: top 0.6s var(--ease-expo);
}

.has-motion.is-header-hidden .filters {
  top: 0;
}

/* ---------- Появление при прокрутке ---------- */

.has-motion [data-reveal] {
  opacity: 0;
  translate: 0 2.5rem;
  transition:
    opacity 1s var(--ease-expo) var(--d, 0ms),
    translate 1.3s var(--ease-expo) var(--d, 0ms);
}

.has-motion [data-reveal].is-in {
  opacity: 1;
  translate: 0 0;
}

@media (max-width: 47.99em) {
  .has-motion #more-rail > [data-reveal],
  .has-motion #more-rail > [data-reveal].is-in {
    opacity: 1;
    translate: none;
    transition: none;
  }

  .has-motion .pdp__info [data-reveal],
  .has-motion .pdp__info [data-reveal].is-in {
    opacity: 1;
    translate: none;
    transition: none;
  }

  .has-motion .pdp__info [data-split] .w > span {
    translate: none;
    transition: none;
  }
}

/* Заголовки: слова выезжают из-под маски */
.has-motion [data-split] .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-block: 0.12em;
  margin-block: -0.12em;
}

.has-motion [data-split] .w > span {
  display: inline-block;
  translate: 0 115%;
  transition: translate 1.15s var(--ease-expo) calc(var(--d, 0ms) + var(--i, 0) * 45ms);
}

.has-motion [data-split].is-in .w > span {
  translate: 0 0;
}

/* Вордмарки: буквы поднимаются по одной */
.has-motion [data-chars] .ch {
  display: inline-block;
  translate: 0 102%;
  transition: translate 1.3s var(--ease-expo) calc(var(--i, 0) * 55ms);
}

.has-motion [data-chars].is-in .ch {
  translate: 0 0;
}

.has-motion .about-banner__mark {
  overflow: hidden;
}

/* Фото: проявляется из блюра */
.has-motion [data-reveal-img] img {
  filter: blur(26px);
  opacity: 0.4;
  scale: 1.1;
  transition:
    filter 1.4s var(--ease-io) var(--d, 0ms),
    opacity 1s var(--ease-io) var(--d, 0ms),
    scale 2s var(--ease-expo) var(--d, 0ms);
}

.has-motion [data-reveal-img].is-in img {
  filter: blur(0);
  opacity: 1;
  scale: var(--scale-end, 1);
}

.has-motion [data-reveal-img].is-done img {
  filter: none;
}

/* Параллакс */
.has-motion [data-parallax] {
  --scale-end: 1.14;
  overflow: hidden;
}

.has-motion [data-parallax] img {
  translate: 0 var(--py, 0px);
}

/* ---------- Hero: шторка между баннерами ---------- */

.has-motion .hero__slide {
  z-index: 0;
  opacity: 0;
  visibility: hidden;
  clip-path: inset(0 0 0 0);
  pointer-events: none;
}

.has-motion .hero__slide.is-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: none;
}

.has-motion .hero__slide.is-leaving {
  z-index: 3;
  opacity: 1;
  visibility: visible;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 1.45s cubic-bezier(0.76, 0, 0.18, 1), visibility 0s linear 1.45s;
}

.has-motion .hero[data-hero-dir="prev"] .hero__slide.is-leaving {
  clip-path: inset(100% 0 0 0);
}

.has-motion .hero__slide.is-leaving::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: 1px;
  background: #fff;
  box-shadow: 0 0 28px 1px rgb(255 255 255 / 0.55);
  pointer-events: none;
}

.has-motion .hero[data-hero-dir="prev"] .hero__slide.is-leaving::after {
  top: 0;
  bottom: auto;
}

.has-motion .hero__media img {
  scale: 1.08;
  transition: scale 1.45s cubic-bezier(0.76, 0, 0.18, 1), filter 1.45s ease, translate 1.45s cubic-bezier(0.76, 0, 0.18, 1);
}

.has-motion .hero__slide.is-leaving .hero__media img {
  scale: 1.14;
  translate: 0 -3%;
  filter: brightness(0.55);
}

.has-motion.is-ready .hero__slide.is-active .hero__media img {
  scale: 1;
  translate: 0 0;
  filter: none;
  transition: scale 9s cubic-bezier(0.2, 0, 0.1, 1), filter 0.6s ease, translate 1.45s cubic-bezier(0.76, 0, 0.18, 1);
}

.has-motion [data-reveal-img].is-reset img {
  transition: none !important;
}

.has-motion .hero[data-reveal-img]:not(.is-in) .hero__slide .hero__media img {
  filter: blur(26px);
}

.has-motion .hero[data-reveal-img] .hero__slide.is-active .hero__media img {
  transition:
    scale 9s cubic-bezier(0.2, 0, 0.1, 1),
    filter 1.4s var(--ease-io),
    opacity 1s var(--ease-io),
    translate 1.45s cubic-bezier(0.76, 0, 0.18, 1);
}

.has-motion .hero__title .w > span {
  translate: 0 115%;
  transition: translate 0s linear 1.5s;
}

.has-motion.is-ready .hero__slide.is-active .hero__title .w > span {
  translate: 0 0;
  transition: translate 1.15s var(--ease-expo) calc(0.42s + var(--i, 0) * 55ms);
}

.has-motion .hero__eyebrow,
.has-motion .hero__text,
.has-motion .hero__content .btn-group {
  opacity: 0;
  translate: 0 1.4rem;
  transition: opacity 0s linear 1.5s, translate 0s linear 1.5s;
}

.has-motion.is-ready .hero__slide.is-active .hero__eyebrow,
.has-motion.is-ready .hero__slide.is-active .hero__text,
.has-motion.is-ready .hero__slide.is-active .hero__content .btn-group {
  opacity: 1;
  translate: 0 0;
  transition: opacity 0.9s var(--ease-expo) var(--d), translate 1.1s var(--ease-expo) var(--d);
}

.hero__eyebrow { --d: 0.38s; }
.hero__text { --d: 0.58s; }
.hero__content .btn-group { --d: 0.74s; }

.has-motion .hero__controls,
.has-motion .hero__next {
  opacity: 0;
  transition: opacity 0.8s var(--ease-expo) 0.8s;
}

.has-motion.is-ready .hero__controls,
.has-motion.is-ready .hero__next {
  opacity: 1;
}

/* ---------- Бегущая строка (чёрная лента, как в референсе GAZU) ---------- */

.marquee {
  overflow: hidden;
  background: var(--c-ink);
  color: var(--c-bg);
  padding-block: clamp(0.9rem, 0.6rem + 0.8vw, 1.5rem);
  user-select: none;
}

.marquee__track {
  display: flex;
  width: max-content;
}

.has-motion .marquee__track {
  animation: marquee 38s linear infinite;
}

.marquee:hover .marquee__track {
  animation-play-state: paused;
}

.marquee__group {
  display: flex;
  align-items: center;
  flex: none;
  gap: clamp(1.5rem, 1rem + 2vw, 3.5rem);
  padding-right: clamp(1.5rem, 1rem + 2vw, 3.5rem);
  font-family: var(--f-cond);
  font-size: clamp(1.75rem, 1rem + 2.6vw, 3.75rem);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.marquee__dots {
  display: inline-flex;
  gap: 0.12em;
}

.marquee__dots::before,
.marquee__dots::after {
  content: "";
  width: 0.42em;
  height: 0.42em;
  border: 0.08em solid var(--c-lime);
  border-radius: 50%;
}

.marquee__dots::after {
  background: var(--c-lime);
}

@keyframes marquee {
  to { translate: -50% 0; }
}

/* ---------- Микро-взаимодействия ---------- */

.has-motion .link svg {
  transition: translate 0.5s var(--ease-expo);
}

.has-motion .link:hover svg {
  translate: 0.3em 0;
}

.has-motion .card__media img {
  transition: opacity var(--dur-slow) var(--ease);
}

/* ---------- Номера в кружках (референс-презентация) ---------- */

.num {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: var(--bw) solid var(--c-line-strong);
  border-radius: 50%;
  font-family: var(--f-cond);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.pillar {
  display: grid;
  align-content: start;
  gap: var(--s-4);
  padding-top: var(--s-5);
  border-top: var(--bw) solid var(--c-line-strong);
}

.pillar__title {
  font-family: var(--f-mono);
  font-size: clamp(1.25rem, 0.6rem + 1.2vw, 1.875rem);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  overflow-wrap: break-word;
}

.pillar p {
  font-size: var(--fs-small);
  max-width: 22em;
}

/* ---------- Подвал открывается из-под последнего блока ---------- */

.has-motion main {
  position: relative;
  z-index: 1;
  background: var(--c-bg);
}

.has-motion .footer-reveal.is-pinned {
  clip-path: inset(0);
}

.has-motion .footer-reveal.is-pinned .footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
  margin-top: 0;
}

.has-motion body:has(.footer-reveal.is-pinned) main {
  border-bottom-right-radius: 1.75rem;
  border-bottom-left-radius: 1.75rem;
  box-shadow: 0 1.75rem 4.5rem rgb(0 0 0 / 0.35);
}

.has-motion .footer-reveal.is-pinned .footer__wordmark {
  translate: 0 var(--footer-shift, 2.75rem);
}
