/* ==========================================================================
   Базовые стили: сброс, типографика, контейнер, доступность
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

html.is-locked { overflow: hidden; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3, h4, p, ul, ol, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

img, picture, svg, canvas, video { display: block; max-width: 100%; }
img { height: auto; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

[hidden] { display: none !important; }

::selection { background: var(--accent); color: #fff; }

/* ---------- Доступность ---------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-pill);
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: 16px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Контейнер ---------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Переносы строк по брейкпоинтам ---------- */

.br-md { display: none; }
.br-lg { display: none; }
@media (min-width: 640px) { .br-md { display: inline; } }
@media (min-width: 1024px) { .br-lg { display: inline; } }

/* ---------- Заголовки и акценты ---------- */

.h-display {
  font-size: var(--fs-h2);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}
.h-display--md { font-size: var(--fs-h2-md); }

/* Акцентное слово в заголовке: тот же шрифт, но цветом. Одно на заголовок. */
.hl { font-style: normal; color: var(--hl-color, var(--accent)); }

/* Служебная подпись: моно, капсом */
.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: 500;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  line-height: 1.3;
}

/* ---------- Появление при прокрутке ----------
   Один словарь: data-reveal = "" (подъём) | fade | scale | mask (шторка для изображений) */

.js [data-reveal] {
  opacity: 0;
  transform: translate3d(0, var(--reveal-y), 0);
  transition: opacity var(--t-reveal) var(--ease-out), transform var(--t-reveal) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal="scale"] { transform: translate3d(0, 24px, 0) scale(0.94); }
.js [data-reveal="mask"] {
  opacity: 1;
  transform: none;
  clip-path: inset(0 0 99.4% 0 round var(--r-lg)); /* не 100%: полностью обрезанный блок браузер считает невидимым */
  transition: clip-path 1.3s var(--ease-out) var(--reveal-delay, 0ms);
}
.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}
.js [data-reveal="mask"].is-visible { clip-path: inset(0 0 0 0 round var(--r-lg)); }

/* Заголовки по словам (создаются в motion.js): слово выезжает из-под линии */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.1em 0.06em 0.16em; margin: -0.1em -0.06em -0.16em; }
.w__i { display: inline-block; transform: translate3d(0, 115%, 0); transition: transform 1.2s var(--ease-out); transition-delay: calc(var(--wi, 0) * 55ms + var(--reveal-delay, 0ms)); }
.is-split-in .w__i { transform: none; }

/* Абзац, который «загорается» по словам при прокрутке */
.scrub .sw { opacity: 0.5; /* не ниже 3:1 по контрасту для крупного текста */ transition: opacity 0.6s var(--ease); }
.scrub .sw.is-lit { opacity: 1; }

/* ---------- Прогресс прокрутки ---------- */

.progress { position: fixed; inset: 0 0 auto 0; z-index: var(--z-progress); height: 3px; pointer-events: none; }
.progress i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--sp, 0)); }
/* Полоса прогресса на нативной scroll-анимации: работает на композиторе, JS не нужен (Chrome, Safari 26+) */
@supports (animation-timeline: scroll()) {
  .progress i { transform: scaleX(0); animation: progress-grow linear both; animation-timeline: scroll(root block); }
  @keyframes progress-grow { to { transform: scaleX(1); } }
}

/* ---------- Курсор «Смотреть» (только мышь) ---------- */

.cursor {
  position: fixed; left: 0; top: 0; z-index: var(--z-cursor);
  display: grid; place-items: center;
  width: 84px; height: 84px; margin: -42px 0 0 -42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  pointer-events: none;
  visibility: hidden;
}
.cursor.is-on { visibility: visible; }
.cursor__label { font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- Уменьшенная анимация ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; clip-path: none; }
  .w__i { transform: none; }
  .scrub .sw { opacity: 1; }
  .cursor, .progress { display: none; }
}

/* Плавную прокрутку ведёт motion.js; родную отключаем, чтобы они не конфликтовали */
html.is-smooth { scroll-behavior: auto; }

/* Плавные переходы между страницами — только мышь/десктоп.
   На тач-устройствах View Transition перезапускал появление заголовков (data-split) дважды. */
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.32s; animation-timing-function: var(--ease, ease); }
}
