/* ============================================================
   БАЗА · сброс, типографика, сетка, доступность
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--t-md);
  line-height: var(--lh-loose);
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv01';
  overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}

img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; }
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }

/* Заголовки: чем крупнее кегль, тем плотнее трекинг и интерлиньяж. */
h1, h2, h3, h4, h5 {
  font-family: var(--body);
  margin: 0;
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-tight);
  text-wrap: balance;
}
h1 { font-size: var(--t-3xl); line-height: var(--lh-tight); letter-spacing: var(--tr-tighter); }
h2 { font-size: var(--t-2xl); line-height: var(--lh-tight); letter-spacing: var(--tr-tighter); }
h3 { font-size: var(--t-xl); }
h4 { font-size: var(--t-md); }

/* Дисплейный шрифт — только там, где он звучит как голос бренда. */
.hero h1, .h2, .logo__wm, .hero-card h2, .final h2, .modal h2, .errpage__card h1, .qcard h2 {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: var(--tr-tighter);
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 6px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: color-mix(in srgb, var(--blue) 20%, transparent); }

/* ---------- каркас ---------- */

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding-inline: var(--s-6);
}
.wrap--narrow { max-width: 760px; }

.sec { padding-block: var(--sec-y); position: relative; }
.sec--ice { background: var(--ice); }
.sec--surface { background: var(--surface); }
.sec--tight { padding-block: clamp(48px, 5vw, 72px); }

section[id] { scroll-margin-top: 92px; }

.g { display: grid; gap: var(--gap); }
.g--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g--hero { grid-template-columns: minmax(0, 1.4fr) minmax(0, .6fr); }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); }

.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.stack { display: grid; gap: var(--s-3); }

/* Вертикальные отступы одним классом — вместо inline-стилей по месту. */
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); }
.mt-8 { margin-top: var(--s-8); }
.mb-4 { margin-bottom: var(--s-4); }

.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: var(--t-sm); }

.hr { height: 1px; background: var(--line); margin-block: var(--s-6); border: 0; }

/* ---------- типографические утилиты ---------- */

.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-2xs);
  font-weight: 700;
  letter-spacing: var(--tr-widest);
  text-transform: uppercase;
  color: var(--blue-ink);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.eyebrow::before { content: ""; width: 20px; height: 1.5px; background: currentColor; border-radius: 2px; }

.h2 { font-size: var(--t-3xl); line-height: var(--lh-tight); }

.lead {
  font-size: var(--t-lg);
  color: var(--ink-soft);
  font-weight: 450;
  line-height: var(--lh-loose);
  max-width: var(--measure);
  text-wrap: pretty;
}

.sec-head { max-width: 660px; margin-bottom: clamp(40px, 4.5vw, 64px); }
.sec-head .h2 { margin-block: var(--s-4); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--mono);
  font-size: var(--t-2xs);
  font-weight: 700;
  letter-spacing: var(--tr-wide);
  text-transform: uppercase;
  color: var(--blue-ink);
  background: var(--blue-soft-bg);
  padding: 5px 10px;
  border-radius: var(--r-xs);
  /* Короткие метки не переносим, но длинные должны уметь: чек-пойнт урока
     на английском («Put aside a first amount») в узком экране вылезал
     за край страницы и включал горизонтальную прокрутку. */
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
}
@media (max-width: 560px) {
  .tag { white-space: normal; text-align: left; }
}

/* ---------- иконки ---------- */

.ic {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -.14em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.ic--lg { width: 22px; height: 22px; }

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

.skip {
  position: absolute;
  left: var(--s-3);
  top: -60px;
  z-index: 400;
  background: var(--blue-btn);
  color: #fff;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-sm);
  font-weight: 700;
  transition: top .2s ease;
}
.skip:focus { top: var(--s-3); }

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

/* ---------- страница ошибки ---------- */

.errpage { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6); background: var(--surface); }
.errpage__card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: clamp(32px, 5vw, 56px);
  text-align: center;
  max-width: 520px;
  box-shadow: var(--sh-2);
}
.errpage__code { font-family: var(--mono); font-size: 40px; font-weight: 700; color: var(--blue); letter-spacing: var(--tr-tighter); }
.errpage__card h1 { font-size: var(--t-2xl); margin: var(--s-3) 0 var(--s-3); }
.errpage__card p { color: var(--ink-soft); margin-bottom: var(--s-6); }

/* ---------- движение по требованию ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 1040px) {
  .g--hero, .g--3, .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .g--2, .g--3, .g--4, .g--5, .g--hero, .grid-3 { grid-template-columns: 1fr; }
  body { font-size: var(--t-base); }
}
