/* ==========================================================================
   Reset + typography + layout primitives
   ========================================================================== */

/* Фирменная гарнитура из брендбука. Black — для логотипа, Bold — для
   крупных заголовков. Оба грузятся только там, где реально нужны. */
@font-face {
  font-family: "OfficinaSansBlack";
  src: url("../fonts/OfficinaSansBlackITC-Regular.ad18b040303a.ttf") format("truetype");
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: "OfficinaSansBold";
  src: url("../fonts/OfficinaSansBoldITC-Regular.2213df7ed909.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--s-5));
  /* clip, а не hidden: не создаёт контекст прокрутки, поэтому sticky-шапка
     и sticky-колонки продолжают работать. Убирает боковую полосу, которую
     иначе даёт уехавшее за экран мобильное меню (оно position: fixed). */
  overflow-x: clip;
}

@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;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "cv11" 1;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  margin: 0 0 var(--s-3);
  line-height: 1.12;
  letter-spacing: -0.021em;
  font-weight: 700;
  color: var(--ink);
  text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
h5 { font-size: var(--step-0); }

p { margin: 0 0 var(--s-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-500); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--brand-400); }

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

ul, ol { margin: 0 0 var(--s-4); padding-left: 1.25em; }
li { margin-bottom: var(--s-1); }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-6) 0; }

small { font-size: var(--step--1); }

code, kbd { font-family: var(--font-mono); font-size: 0.9em; }

::selection { background: var(--brand-200); color: var(--brand-900); }

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

/* --- Layout ------------------------------------------------------------ */
.container {
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}
.container-narrow { width: min(100% - 2.5rem, var(--container-narrow)); margin-inline: auto; }

.section { padding-block: clamp(3rem, 7vw, 6.5rem); }
.section--tight { padding-block: clamp(2rem, 4vw, 3.5rem); }
.section--sand { background: var(--paper-alt); }
.section--ink { background: var(--brand-900); color: #EAF3F7; }
.section--ink h1, .section--ink h2, .section--ink h3 { color: #fff; }

.stack > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }
.stack-sm > * + * { margin-top: var(--s-2); }

.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--top { align-items: flex-start; }
.row--nowrap { flex-wrap: nowrap; }
.spacer { flex: 1 1 auto; }

.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
/* 160px, а не 220: на телефоне плитки метрик должны ложиться по две в ряд,
   иначе сводка превращается в бесконечную ленту. */
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }

/* Асимметричные раскладки «контент + колонка».
   Отдельными классами, а не инлайном: инлайновые grid-template-columns
   не схлопываются на мобильных — их нечем перебить в медиазапросе. */
.grid-main { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.grid-wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.grid-aside { grid-template-columns: minmax(0, 1fr) minmax(0, 340px); align-items: start; }
.grid-form { grid-template-columns: minmax(0, 1fr) minmax(0, 520px); align-items: start; }
.grid-panel { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); align-items: start; }

@media (max-width: 1000px) {
  .grid-main, .grid-wide, .grid-aside, .grid-form, .grid-panel {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Боковая колонка не должна «прилипать», когда она уехала под контент. */
  .grid-main > aside, .grid-wide > aside, .grid-aside > aside,
  .grid-form > aside, .grid-panel > aside { position: static !important; }
}

/* --- Type helpers ------------------------------------------------------ */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-500);
  margin-bottom: var(--s-3);
}
.eyebrow::before {
  content: "";
  width: 24px; height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.lead { font-size: var(--step-1); color: var(--ink-2); line-height: 1.55; }
.muted { color: var(--muted); }
.tiny { font-size: var(--step--2); }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.tabnum { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); }
.hidden { display: none !important; }
/* Компоненты с собственным display (.alert, .card…) иначе игнорируют hidden. */
[hidden] { display: none !important; }

.section-head { max-width: 62ch; margin-bottom: var(--s-6); }
.section-head--center { margin-inline: auto; text-align: center; }

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

/* Утилита для широкого контента: скроллим контейнер, а не страницу. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --- Entrance animation -------------------------------------------------
   Прячем только когда точно есть JS: иначе при сбое скрипта половина
   страницы осталась бы невидимой. */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out);
}
.js .reveal.is-visible { opacity: 1; transform: none; }
