/* ФИСТАШКА — значения взяты из Figma: «PISTACHE / Three screen scroll story» (1440×900)
   и «ФИСТАШКА / Мобильная версия / 390» (390×844). */
:root {
  --bg: #110b08;        /* 0.065 / 0.043 / 0.032 */
  --cream: #e8e0c9;     /* 0.91 / 0.88 / 0.79 */
  --accent: #b0bf7d;    /* 0.69 / 0.75 / 0.49 */
  --serif: "Prata", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --vh: 100vh;
  --pad: 80px;
}
@supports (height: 100svh) { :root { --vh: 100svh; } }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--cream);
  font-family: var(--sans); font-weight: 400;
  overflow-x: clip; -webkit-font-smoothing: antialiased;
}
p, h1, h2 { margin: 0; font-weight: 400; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }
.accent { color: var(--accent); }
.m-only { display: none; }

/* ---------- Шапка (Frame 80/38, 1280×60) ---------- */
.hdr {
  position: fixed; z-index: 20; inset: 0 0 auto 0;
  height: 136px; padding: 38px var(--pad) 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  pointer-events: none;
  background: linear-gradient(var(--bg) 0%, rgba(17, 11, 8, .72) 45%, rgba(17, 11, 8, 0) 100%);
}
.hdr > * { pointer-events: auto; }
.logo { font-family: var(--serif); font-size: 30px; line-height: 60px; letter-spacing: 0; }
.nav {
  position: absolute; left: calc(631 / 1440 * 100%); top: 38px;
  height: 60px; display: flex; align-items: center; gap: 13px;
  font-size: 11px; line-height: 1;
}
.nav a, .tagline, .cta, .menu-btn { transition: opacity .25s ease, color .25s ease; }
.nav a:hover, .cta:hover { color: var(--accent); }
.tagline { font-size: 10px; line-height: 60px; }
.menu-btn { display: none; }

/* ---------- Подвал (Frame 80/830, 1280×30) ---------- */
.ftr {
  position: fixed; z-index: 20; inset: auto 0 0 0;
  padding: 0 var(--pad) 58px;
  display: flex; justify-content: space-between; align-items: flex-end;
  font-size: 10px; line-height: 12px; pointer-events: none;
}

/* ---------- Текст сцены (Frame 80/240, 620×306) ---------- */
.copy {
  position: absolute; z-index: 5;
  left: var(--pad); top: calc(240 / 900 * var(--vh));
  width: 620px; display: flex; flex-direction: column; align-items: flex-start; gap: 30px;
}
.eyebrow { font-size: 11px; line-height: 13px; }
.title {
  font-family: var(--serif); font-size: clamp(46px, 4.583vw, 66px);
  line-height: 1.05; max-width: 560px; letter-spacing: 0;
}
.lead { font-size: 16px; line-height: 1.65; max-width: 400px; }
.cta { font-size: 11px; line-height: 13px; letter-spacing: .12em; }

/* ---------- Десерт (850×850, x570 y50) ---------- */
.dessert {
  position: absolute; z-index: 1;
  right: calc(20 / 1440 * 100%); bottom: 0;
  width: min(calc(850 / 900 * var(--vh)), calc(850 / 1440 * 100vw));
  aspect-ratio: 1 / 1;
  /* мягкие края, чтобы кадр растворялся в фоне */
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
}
.dessert > img, .dessert > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.dessert canvas { opacity: 0; }
.dessert.is-ready canvas { opacity: 1; }
.dessert.is-ready .poster { visibility: hidden; }

/* =========================================================
   Режим 1: видео по скроллу (класс .scrub на <html>)
   ========================================================= */
.scrub .story { position: relative; height: calc(var(--vh) * 4.2); }
.scrub .stage { position: sticky; top: 0; height: var(--vh); overflow: hidden; }
.scrub .panel { position: absolute; inset: 0; pointer-events: none; }
.scrub .panel .still { display: none; }
.scrub .panel .copy > * {
  opacity: 0; transform: translate3d(0, 22px, 0);
  transition: opacity .55s cubic-bezier(.2, .7, .2, 1), transform .7s cubic-bezier(.2, .7, .2, 1);
}
.scrub .panel.is-active { pointer-events: auto; }
.scrub .panel.is-active .copy > * { opacity: 1; transform: none; }
.scrub .panel.is-active .copy > :nth-child(2) { transition-delay: .06s; }
.scrub .panel.is-active .copy > :nth-child(3) { transition-delay: .12s; }
.scrub .panel.is-active .copy > :nth-child(4) { transition-delay: .18s; }

/* =========================================================
   Режим 2: статичные три экрана (reduced motion / без JS)
   ========================================================= */
html:not(.scrub) .dessert { display: none; }
html:not(.scrub) .panel { position: relative; height: var(--vh); min-height: 640px; overflow: hidden; }
html:not(.scrub) .panel .still {
  position: absolute; right: calc(20 / 1440 * 100%); bottom: 0;
  width: min(calc(850 / 900 * var(--vh)), calc(850 / 1440 * 100vw)); height: auto; aspect-ratio: 1 / 1;
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
}

/* ---------- Планшет ---------- */
@media (max-width: 1100px) and (min-width: 768px) {
  :root { --pad: 48px; }
  .copy { width: 52%; }
  .nav { left: auto; right: var(--pad); }
  .tagline { display: none; }
}

/* =========================================================
   Телефон — макет 390×844
   ========================================================= */
@media (max-width: 767.98px) {
  :root { --pad: 24px; }
  .d-only, .br-d { display: none; }
  .m-only { display: inline; }

  .hdr { height: 96px; padding: 24px var(--pad) 0; align-items: center; }
  .hdr > * { height: 40px; }
  .logo { font-size: 23px; line-height: 40px; }
  .tagline { display: none; }
  .menu-btn {
    display: block; padding: 0; margin: 0; border: 0; background: none;
    font: 10px/40px var(--sans); letter-spacing: 0; cursor: pointer;
    min-width: 44px; text-align: right;
  }
  .nav {
    position: fixed; inset: 0; z-index: -1; height: auto;
    flex-direction: column; justify-content: center; gap: 28px;
    background: rgba(17, 11, 8, .96);
    font-family: var(--serif); font-size: 28px;
    opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s;
  }
  .nav span { display: none; }
  .nav.is-open { opacity: 1; visibility: visible; }

  .ftr { padding: 0 var(--pad) calc(37px + env(safe-area-inset-bottom)); font-size: 9px; line-height: 10px; }

  .copy { left: var(--pad); right: var(--pad); top: 118px; width: auto; gap: 20px; }
  .eyebrow { font-size: 9px; line-height: 11px; letter-spacing: .05em; }
  .title { font-size: 38px; line-height: 1.2; }
  .lead { font-size: 13px; line-height: 1.55; max-width: none; }
  .cta { font-size: 10px; line-height: 12px; }

  /* 390×390, низ квадрата на 54px выше низа экрана */
  .dessert, html:not(.scrub) .panel .still {
    left: 50%; right: auto; bottom: 54px; transform: translateX(-50%);
    width: min(100vw, calc(var(--vh) - 54px - 330px), 520px);
  }
  html:not(.scrub) .panel { min-height: 700px; }
}

@media (max-width: 767.98px) and (max-height: 700px) {
  .copy { top: 92px; gap: 14px; }
  .title { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
