/* ═══════════════════════════════════════════════════════════
   ДРУГ — сброс и базовая типографика
   ═══════════════════════════════════════════════════════════ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);   /* фиксированная шапка не перекрывает якоря */
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4, h5, h6 { font-weight: inherit; font-size: inherit; }
p, h1, h2, h3, h4, h5, h6, li { overflow-wrap: break-word; }

/* ── Фокус: видим всегда, у всего ──────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
/* на терракотовом фоне обводка того же цвета не читается */
.is-on-accent :focus-visible,
.card--accent :focus-visible,
.paper :focus-visible { outline-color: var(--ink); }

/* ── Ссылка «к содержимому» для клавиатуры ────────────────── */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 200;
  background: var(--paper);
  color: var(--ink);
  padding: .7rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: top var(--dur-s) var(--ease);
}
.skip-link:focus { top: 1rem; }

/* ── Раскладка ─────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--section-y); }
.section--tight { padding-block: var(--s-7); }
.section--deep { background: var(--bg-deep); }

/* ── Типографика ───────────────────────────────────────────── */
.display,
.h1, .h2, .h3 {
  font-family: var(--font-display);
  letter-spacing: -.02em;
  line-height: var(--lh-tight);
}

.h1 { font-size: var(--fs-h1); font-weight: 800; }
.h2 { font-size: var(--fs-h2); font-weight: 700; }
.h3 { font-size: var(--fs-h3); font-weight: 500; line-height: 1.25; letter-spacing: -.01em; }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  max-width: 56ch;
}

/* ── Ритм ──────────────────────────────────────────────────────
   Расстояния задаём через gap у обёрток, а не margin у каждого
   элемента: так ничего не схлопывается и не складывается дважды. */
.prose {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  align-items: flex-start;
}
.prose > .h2 + * { margin-top: var(--s-1); }

.aside {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.text { color: var(--text-dim); line-height: var(--lh-body); }
.text--measure { max-width: var(--measure); }
.muted { color: var(--text-mute); }
.accent { color: var(--accent); }

/* Надзаголовок «ДРУГ ◆ РАЗДЕЛ» — из референса */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow__rest { color: var(--text-mute); }
.eyebrow::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--accent);
  transform: rotate(45deg);
  flex: none;
}

/* Шапка секции: надзаголовок слева, полевая нумерация справа */
.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-6);
  border-bottom: 1px solid var(--line);
}

/* Заголовок секции и подводка под ним */
.section__intro {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-bottom: var(--s-6);
  max-width: 62ch;
}
/* если под шапкой есть заголовок, отбивку держит уже .section__intro */
.section__head:has(+ .section__intro) { margin-bottom: var(--s-4); }

/* Кнопка под содержимым секции */
.section__foot { margin-top: var(--s-6); }
.section__num {
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  color: var(--text-mute);
  white-space: nowrap;
}

/* ── Сетки ─────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--gap); }
.grid--wide { gap: var(--gap-lg); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--5 { grid-template-columns: repeat(5, 1fr); }
.grid--sidebar {
  grid-template-columns: minmax(0, 1fr) minmax(0, .78fr);
  gap: var(--gap-lg);
  align-items: start;
}

.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack--lg { gap: var(--s-5); }

/* ── Появление при скролле ───────────────────────────────────
   Содержимое видно по умолчанию. Прячем его, только если скрипт
   действительно запустился и поставил класс .js на <html>.
   Иначе сбой JS или блокировщик оставили бы пустой экран.      */
.reveal { transition: opacity .65s var(--ease), transform .65s var(--ease); }
.js .reveal { opacity: 0; transform: translateY(22px); }
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ── Уважение к настройке «уменьшить движение» ─────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* ── Адаптив базовой сетки ─────────────────────────────────── */
@media (max-width: 1100px) {
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .grid--5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .grid--2, .grid--3, .grid--sidebar { grid-template-columns: 1fr; }
  .grid--5 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .grid--4, .grid--5 { grid-template-columns: 1fr; }
}
