:root {
  color-scheme: light;
  --paper: #d9c8b6;
  --paper-light: #eee1cf;
  --ink: #54483f;
  --line: rgba(90, 76, 60, .22);
  --view-height: 100svh;
  --view-px: 800px;
}
* { box-sizing: border-box; }
html { margin: 0; padding: 0; scroll-behavior: auto; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
html.intro-active, body.intro-active { overflow: hidden !important; }
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid #8b6d52; outline-offset: 5px; }
[hidden] { display: none !important; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--paper-light); z-index: 100; }

/* Заставка: абсолютный приоритет загрузки и натуральная ширина исходного видео. */
.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #d9c8b6 url('../assets/logo-poster.jpg') center/cover no-repeat;
  display: grid;
  place-items: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 220ms cubic-bezier(.35,0,.25,1), visibility 220ms;
  overflow: hidden;
}
.intro.is-out { opacity: 0; visibility: hidden; pointer-events: none; }
.intro__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  background: #d9c8b6;
}
.intro__skip {
  position: absolute;
  z-index: 2;
  top: max(24px, env(safe-area-inset-top));
  right: max(26px, env(safe-area-inset-right));
  border: 1px solid rgba(88,74,63,.26);
  border-radius: 999px;
  padding: 11px 17px;
  background: rgba(239,225,207,.62);
  color: #635245;
  font-size: 12px;
  letter-spacing: .055em;
  transition: background .2s, border-color .2s;
  backdrop-filter: blur(5px);
}
.intro__skip:hover { background: rgba(245,236,223,.85); border-color: rgba(88,74,63,.4); }
.intro__skip span { margin-left: 8px; }
.intro__loader {
  position: absolute;
  bottom: max(34px, env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  width: 78px; height: 2px;
  background: rgba(105,84,63,.18);
  overflow: hidden;
  border-radius: 10px;
}
.intro__loader span {
  display: block; width: 40%; height: 100%; background: #9b7b5d;
  animation: load 1.8s ease-in-out infinite alternate;
}
@keyframes load { from { transform: translateX(-110%); } to { transform: translateX(255%); } }
.intro__fallback {
  position: absolute; z-index: 3; padding: 36px; text-align: center;
  background: rgba(232,218,201,.94);
  border-radius: 6px;
}
.intro__fallback p { font-size: 25px; font-family: Georgia,serif; margin: 0 0 20px; }
.action-button { padding: 14px 20px; border: 1px solid #a89174; border-radius: 4px; background: transparent; color: #534538; }

/* Скролл-сцена: реально 5 высот экрана между 0 и 100% видеосюжета. */
.scroll-story {
  position: relative;
  width: 100%;
  height: calc(var(--view-height) * 6);
  background: var(--paper);
}
.scroll-story__sticky {
  position: sticky;
  top: 0;
  width: 100%;
  height: var(--view-height);
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
}
.film-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #d7c7b2;
}
.film-stage__video {
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #d7c7b2;
  image-rendering: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.story-ui { position: absolute; pointer-events: none; inset: 0; z-index: 2; }
.story-ui__bottom {
  position: absolute;
  left: clamp(25px,4.8vw,94px);
  right: clamp(25px,4.8vw,94px);
  bottom: max(36px, env(safe-area-inset-bottom));
  display: flex; align-items: end; justify-content: space-between;
  gap: 24px;
}
.story-ui__hint, .story-ui__progress {
  color: #594b3e;
  font-size: 11px;
  line-height: 1.6;
  font-weight: 500;
  letter-spacing: .06em;
  text-shadow: 0 1px 10px rgba(232,217,198,.8);
}
.story-ui__hint { transition: opacity .4s, transform .4s; }
.story-ui__hint.is-hidden { opacity: 0; transform: translateY(8px); }
.story-ui__arrow { display: inline-block; font-size: 24px; margin-right: 9px; vertical-align: -3px; animation: arrow 1.7s ease-in-out infinite; }
@keyframes arrow { 50% { transform: translateY(6px); } }
.story-ui__progress { display: flex; align-items: center; gap: 14px; }
.story-ui__progress-label { font-size: 10px; letter-spacing: .13em; }
.story-ui__bars { display: flex; align-items: center; gap: 4px; height: 14px; }
.story-ui__bars i {
  display: block; height: 2px; width: clamp(13px,2.2vw,34px);
  background: rgba(96,77,59,.27);
  position: relative; overflow: hidden;
}
.story-ui__bars i::before { content: ''; position:absolute; inset:0; width:var(--segment,0%); background:#705840; transition: width 90ms linear; }
.story-ui__count { font-variant-numeric: tabular-nums; letter-spacing: .11em; }
.loading-indicator {
  position: absolute; z-index: 4; left: 50%; bottom: 11%; transform:translateX(-50%);
  border: 1px solid var(--line); border-radius: 99px;
  padding: 10px 16px; color: #4f4538; background: rgba(236,226,212,.89);
  font-size: 12px; white-space: nowrap;
}


@media (max-width: 700px) {
  .intro__video { object-fit: cover; }
  .intro__skip { top:max(18px,env(safe-area-inset-top)); right:max(16px,env(safe-area-inset-right)); font-size:11px; }
  .story-ui__bottom { left:19px; right:19px; bottom:max(24px,env(safe-area-inset-bottom)); display:block; }
  .story-ui__hint { margin: 0 0 19px; font-size:11px; }
  .story-ui__progress { justify-content: space-between; gap:7px; }
  .story-ui__bars { flex: 1; }
  .story-ui__bars i { flex: 1; min-width:0; width:auto; }
  .story-ui__progress-label { font-size: 9px; letter-spacing: .08em; }
  .story-ui__count { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .story-ui__arrow, .intro__loader span { animation: none; }
  .intro { transition-duration: .2s; }
}
