/* ─── Studio 3D story ───
   Default (no JS, reduced motion, no WebGL): a readable stacked hero with a poster.
   .story-live: a pinned WebGL studio scene driven by scroll (story3d.js). */

:root {
  --story-bg:
    radial-gradient(70% 55% at 62% 72%, rgba(0, 0, 0, 0.05), transparent 70%),
    radial-gradient(120% 95% at 58% 28%, #ffffff 0%, #f2f3f5 48%, #e3e5e9 100%);
  --story-line: rgba(0, 0, 0, 0.14);
  --story-scrim: rgba(242, 243, 245, 0.92);
  --story-vignette: rgba(0, 0, 0, 0.05);
  --story-glass: rgba(255, 255, 255, 0.72);
  --story-glass-line: rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --story-bg:
      radial-gradient(60% 40% at 58% 74%, rgba(255, 255, 255, 0.045), transparent 70%),
      radial-gradient(120% 95% at 58% 26%, #1c1d21 0%, #0c0d0f 50%, #040405 100%);
    --story-line: rgba(255, 255, 255, 0.16);
    --story-scrim: rgba(6, 6, 7, 0.9);
    --story-vignette: rgba(0, 0, 0, 0.34);
    --story-glass: rgba(30, 31, 36, 0.62);
    --story-glass-line: rgba(255, 255, 255, 0.1);
  }
}

:root[data-theme="dark"] {
  --story-bg:
    radial-gradient(60% 40% at 58% 74%, rgba(255, 255, 255, 0.045), transparent 70%),
    radial-gradient(120% 95% at 58% 26%, #1c1d21 0%, #0c0d0f 50%, #040405 100%);
  --story-line: rgba(255, 255, 255, 0.16);
  --story-scrim: rgba(6, 6, 7, 0.9);
  --story-vignette: rgba(0, 0, 0, 0.34);
  --story-glass: rgba(30, 31, 36, 0.62);
  --story-glass-line: rgba(255, 255, 255, 0.1);
}

/* Lenis smooth scroll */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

.hero.story {
  padding: 0;
  overflow: visible;
  text-align: left;
  background: var(--story-bg);
  color: var(--hero-ink);
  touch-action: auto;
}
.hero.story::before, .hero.story::after { display: none; }

.story-ru, .story-tg, .story-en { display: none; }
html[lang="ru"] .story-ru, html[lang="tg"] .story-tg, html[lang="en"] .story-en { display: inline; }

/* ─── Typography ─── */

.story-eyebrow {
  margin: 0 0 18px;
  font: 600 12px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hero-muted);
}
.story-copy h1 {
  margin: 0 0 18px;
  font-size: clamp(40px, 5.2vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.038em;
  font-weight: 700;
}
.story-copy h2 {
  margin: 0 0 18px;
  font-size: clamp(32px, 4vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.032em;
  font-weight: 650;
}
.story-copy p {
  margin: 0 0 10px;
  max-width: 36ch;
  font-size: clamp(16px, 1.2vw, 19px);
  line-height: 1.5;
  color: var(--hero-muted);
}
.story-intro [data-i18n="role"] {
  color: var(--hero-ink);
  font-weight: 600;
  font-size: clamp(17px, 1.35vw, 21px);
}
.story-copy .hero-actions { justify-content: flex-start; margin-top: 30px; }
.story-final-title {
  margin: 0 0 12px;
  font-size: clamp(28px, 3.4vw, 50px) !important;
  line-height: 1.08 !important;
  letter-spacing: -0.03em;
  font-weight: 650;
  color: var(--hero-ink) !important;
  max-width: none !important;
}
.story-final-sub {
  font: 500 13px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace !important;
  letter-spacing: 0.12em;
  max-width: none !important;
}

/* ─── Static / fallback layout ─── */

.story-stage {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(96px, 14vh, 150px) 22px 40px;
  display: grid;
  gap: 56px;
}
.story-canvas, .story-film, .story-rail, .story-cue, .story-explore { display: none; }
.story-poster {
  display: block;
  width: min(1100px, calc(100% - 32px));
  height: auto;
  margin: 0 auto 80px;
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18);
}

/* ─── Live scene ─── */

.hero.story.story-live { height: 480svh; }
.story-live .story-stage {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 540px;
  max-width: none;
  padding: 0;
  display: block;
  overflow: clip;
}
.story-live .story-poster { display: none; }
.story-live .story-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.1s cubic-bezier(0.22, 1, 0.36, 1);
  touch-action: pan-y;
}
.story-live.story-ready .story-canvas { opacity: 1; }
.story-live[data-explore="on"] .story-canvas { cursor: grab; }
.story-live[data-explore="on"] .story-canvas:active { cursor: grabbing; }

/* Film: static grain (breaks up banding in dark gradients) and a soft vignette.
   Plain CSS over the canvas and under the text, so it costs the GPU nothing per frame. */
.story-live .story-film {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 55% 48%, transparent 55%, var(--story-vignette) 100%);
}
.story-live .story-film::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.1;
  mix-blend-mode: overlay;
  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='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.story-live .story-copy {
  position: absolute;
  z-index: 2;
  left: max(28px, calc((100vw - 1240px) / 2 + 28px));
  top: 50%;
  width: min(440px, 36vw);
  translate: 0 -50%;
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}
.story-live .story-copy[data-story-copy="0"] { opacity: 1; pointer-events: auto; }
.story-live .story-intro { width: min(520px, 40vw); }
/* Intro entrance on the compositor: it stays smooth while story3d.js builds the scene. */
@keyframes story-rise {
  from { opacity: 0; transform: translate3d(0, 26px, 0); }
}
@media (prefers-reduced-motion: no-preference) {
  .story-live .story-intro > * { animation: story-rise 1.1s cubic-bezier(0.19, 1, 0.22, 1) both; }
  .story-live .story-intro > :nth-child(1) { animation-delay: 0.1s; }
  .story-live .story-intro > :nth-child(2) { animation-delay: 0.17s; }
  .story-live .story-intro > :nth-child(3) { animation-delay: 0.24s; }
  .story-live .story-intro > :nth-child(4) { animation-delay: 0.31s; }
  .story-live .story-intro > :nth-child(5) { animation-delay: 0.38s; }
  .story-live .story-intro > :nth-child(6) { animation-delay: 0.45s; }
}
.story-live .story-intro .hero-location { display: none; }
.story-live .story-final {
  left: 50%;
  top: clamp(84px, 13svh, 140px);
  width: min(820px, calc(100% - 40px));
  translate: -50% 0;
  text-align: center;
}

.story-live .story-rail {
  display: flex;
  position: absolute;
  z-index: 2;
  right: 30px;
  top: 50%;
  translate: 0 -50%;
  flex-direction: column;
  gap: 10px;
}
.story-rail i {
  width: 2px;
  height: 20px;
  border-radius: 2px;
  background: var(--story-line);
  transition: height 0.5s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.5s ease;
}
.story-rail i.is-active { height: 40px; background: var(--hero-ink); }

.story-live .story-cue {
  display: block;
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 30px;
  width: 1px;
  height: 46px;
  overflow: hidden;
  background: var(--story-line);
}
.story-cue span {
  position: absolute;
  left: 0;
  top: -40%;
  width: 100%;
  height: 40%;
  background: var(--hero-ink);
  animation: story-cue 1.9s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes story-cue { to { top: 100%; } }

/* ─── "Closer look" viewer (after the story) ─── */

.story-live .story-explore {
  display: block;
  position: absolute;
  z-index: 3;
  left: max(28px, calc((100vw - 1240px) / 2 + 28px));
  top: 52%;
  width: min(380px, 32vw);
  translate: 0 -50%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.story-live[data-explore="on"] .story-explore { pointer-events: auto; }
.story-live[data-explore="on"] .story-rail { opacity: 0; }
.story-live[data-explore="on"] .story-final { transition: opacity 0.45s ease; }
.story-live[data-feature-open] .story-final { opacity: 0 !important; }
.story-explore-title { margin-bottom: 14px; }
.story-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.story-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 10px;
  border: 1px solid var(--story-glass-line);
  border-radius: 999px;
  background: var(--story-glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  color: var(--hero-ink);
  font: 600 15px/1.2 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.3s ease;
}
.story-pill:hover { transform: translateX(3px); }
.story-pill:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.story-pill-icon {
  position: relative;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.8;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.story-pill-icon::before, .story-pill-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 1.5px;
  background: currentColor;
  translate: -50% -50%;
}
.story-pill-icon::after { rotate: 90deg; }
.story-pill[aria-expanded="true"] .story-pill-icon { transform: rotate(45deg); }
.story-feature-body {
  margin-top: 8px;
  padding: 14px 18px;
  max-width: 380px;
  border: 1px solid var(--story-glass-line);
  border-radius: 20px;
  background: var(--story-glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  color: var(--hero-muted);
  font-size: 15px;
  line-height: 1.5;
  animation: story-card-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.story-feature-body p { margin: 0; max-width: none; font-size: inherit; }
@keyframes story-card-in { from { opacity: 0; transform: translateY(8px); } }
.story-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.story-swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--story-glass-line);
  border-radius: 999px;
  background: transparent;
  color: var(--hero-ink);
  font: 500 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}
.story-swatch i { width: 22px; height: 22px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); }
.story-swatch[aria-pressed="true"] { border-color: var(--hero-ink); }
.story-swatch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Tall screens: device on top, text at the bottom (JS uses the same aspect split). */
@media (max-aspect-ratio: 999/1000) {
  .story-live .story-copy:not(.story-final) {
    left: 20px;
    right: 20px;
    top: auto;
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    width: auto;
    translate: none;
  }
  .story-live .story-intro [data-i18n="tagline"] { display: none; }
  .story-live .story-copy h1 { font-size: clamp(34px, 9.5vw, 56px); }
  .story-live .story-copy h2 { font-size: clamp(28px, 8vw, 44px); }
  .story-live .story-copy .hero-actions { margin-top: 22px; }
  .story-live .story-final { left: 50%; right: auto; top: clamp(76px, 11svh, 120px); bottom: auto; width: calc(100% - 40px); translate: -50% 0; }
  .story-live .story-rail, .story-live .story-cue { display: none; }
  .story-live .story-explore { left: 16px; right: 16px; top: auto; bottom: calc(40px + env(safe-area-inset-bottom, 0px)); width: auto; translate: none; }
  .story-live .story-explore-title { display: none; }
  .story-features { flex-direction: row; overflow-x: auto; scrollbar-width: none; padding: 2px; }
  .story-features::-webkit-scrollbar { display: none; }
  .story-feature { flex: none; }
  .story-pill { white-space: nowrap; padding: 9px 14px 9px 9px; font-size: 14px; }
  .story-pill:hover { transform: none; }
  .story-feature-body { position: absolute; left: 0; right: 0; bottom: calc(100% + 10px); max-width: none; margin: 0; }
  .story-live .story-stage::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 46%;
    background: linear-gradient(to top, var(--story-scrim) 30%, transparent);
    pointer-events: none;
  }
}
@media (max-aspect-ratio: 999/1000) and (max-width: 760px) {
  .story-live .story-copy:not(.story-final) { bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
  .story-live .story-explore { bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .story-cue span { animation: none; }
  .story-live .story-canvas { transition: none; }
}
