/* ==========================================================================
   base.css — reset, базовая типографика, утилиты, доступность.
   Подключается вторым: tokens → base → components → sections.

   Правило темы: контент виден без JavaScript. Никаких opacity: 0 в CSS —
   стартовые состояния анимаций задаёт main.js через gsap.set().
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--anchor-offset);
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ul, ol {
  margin: 0;
}

ul[class],
ol[class] {
  padding: 0;
  list-style: none;
}

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

/* Атрибуты width/height у <img> — презентационные подсказки: без height: auto
   они перебивают aspect-ratio и растягивают картинку. */
img,
svg { height: auto; }

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- Документ ---------- */
html,
body {
  overflow-x: clip;              /* никакого горизонтального скролла */
  max-width: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-normal);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Зерно: поверх фона, под контентом. Без него тёмный фон плоский. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  background-image: var(--grain);
  background-size: var(--grain-size) var(--grain-size);
  background-repeat: repeat;
  opacity: var(--grain-opacity);
}

/* Весь контент — над зерном */
.site-header,
main,
.site-footer,
.mobile-menu {
  position: relative;
  z-index: var(--z-base);
}

.site-header { z-index: var(--z-header); }
.mobile-menu { z-index: var(--z-menu); }

/* ---------- Типографика ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);   /* только 600: 500 на тёмном пропадает */
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-display);
}

h2 { font-size: var(--fs-h2); line-height: var(--lh-title); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

p { text-wrap: pretty; }

/* Подсвеченное слово в заголовке */
.hl { color: var(--gold); }

a {
  color: inherit;
  text-decoration-color: var(--line-2);
  text-underline-offset: var(--underline-offset);
  transition: color var(--dur-fast) var(--ease),
              text-decoration-color var(--dur-fast) var(--ease);
}

a:hover { text-decoration-color: currentColor; }

strong,
b { font-weight: var(--fw-semibold); }

small { font-size: var(--fs-sm); }

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

hr {
  height: var(--border-hair);
  border: 0;
  background-color: var(--line);
  margin-block: var(--space-lg);
}

::selection {
  background-color: var(--gold);
  color: var(--on-gold);
}

/* ---------- Фокус ---------- */
:focus { outline: none; }

:focus-visible {
  outline: var(--border-thick) solid var(--focus-ring);
  outline-offset: var(--space-3xs);
  border-radius: var(--radius-xs);
}

/* ---------- Утилиты раскладки ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: var(--container-narrow); }
.container--wide   { max-width: var(--container-wide); }
.container--price  { max-width: var(--container-price); }
.container--steps  { max-width: var(--container-steps); }

.section {
  position: relative;
  padding-block: var(--section-y);
  scroll-margin-top: var(--anchor-offset);
}

.section--alt   { background-color: var(--bg-2); }
.section--tight { padding-block: var(--section-y-sm); }

.section__head {
  max-width: 42ch;
  margin-bottom: clamp(var(--space-xl), 5vw, var(--space-3xl));
}

.section__head--center {
  margin-inline: auto;
  text-align: center;
}

.section__lead {
  margin-top: var(--space-md);
  color: var(--text-soft);
  font-size: var(--fs-lead);
  line-height: var(--lh-snug);
}

.stack > * + * { margin-top: var(--stack-gap); }

/* ---------- Утилиты текста ---------- */
.u-display { font-family: var(--font-display); }
.u-mono    { font-family: var(--font-mono); }

.u-lead {
  font-size: var(--fs-lead);
  line-height: var(--lh-snug);
  color: var(--text-soft);
}

.u-note {
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  color: var(--text-mute);
}

.u-soft   { color: var(--text-soft); }
.u-gold   { color: var(--gold); }
.u-center { text-align: center; }
.u-nowrap { white-space: nowrap; }

/* ---------- Доступность ---------- */
.visually-hidden {
  position: absolute;
  width: var(--border-hair);
  height: var(--border-hair);
  padding: 0;
  margin: calc(-1 * var(--border-hair));
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-2xs);
  left: var(--space-2xs);
  z-index: var(--z-skip);
  padding: var(--space-2xs) var(--space-sm);
  background-color: var(--gold);
  color: var(--on-gold);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-pill);
  text-decoration: none;
  transform: translateY(calc(-1 * var(--space-4xl)));
}

.skip-link:focus-visible { transform: translateY(0); }

[hidden] { display: none !important; }

/* Блокировка прокрутки под открытым мобильным меню */
body.is-locked { overflow: hidden; }

/* ---------- Уважение к настройкам системы ----------
   ScrollTrigger и таймлайны гасит main.js; здесь — CSS-переходы и keyframes. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
