/* ============================================================
   BASE — структура, типографика, моушн, примитивы компонентов.
   Подключается ПОСЛЕ theme.css. Цвета/шрифты/радиусы здесь не задаются —
   только роли из темы. Править под проект можно, но через токены.
   ============================================================ */

:root {
  /* Типошкала (fluid, utopia-style): 3–4 размера на экран, не больше 5 */
  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);   /* 13–14: подписи, хинты */
  --step-body: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);          /* 16–18: текст */
  --step-lead: clamp(1.1875rem, 1.08rem + 0.5vw, 1.5rem);       /* 19–24: подзаголовок, лид */
  --step-head: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);           /* 24–40: заголовок секции/экрана */
  --step-display: clamp(2.25rem, 1.2rem + 5vw, 5.5rem);         /* 36–88: только hero лендинга */

  /* Отступы: база 4px. Внутри группы — мелкие шаги, между группами — крупные */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 144px;
  --margin: clamp(16px, 2.4vw, 40px);       /* поля страницы — одни на всё */
  --gutter: clamp(12px, 1.4vw, 24px);
  --measure: 66ch;                          /* ширина строки текста */
  --section-gap: clamp(72px, 6vw + 40px, 200px);  /* между секциями лендинга */

  /* Тень — только у того, что парит над страницей (меню, поповер, диалог, тост) */
  --shadow-float: 0 1px 2px rgb(0 0 0 / 0.06), 0 12px 32px -8px rgb(0 0 0 / 0.18);

  /* Моушн (easings.net-уровень, без пружин и отскоков) */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);      /* появления, UI до 600ms */
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);      /* крупные reveal 700ms+ */
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);   /* панели, шторки, перемещения */
  --ease-exit: cubic-bezier(0.55, 0.055, 0.675, 0.19); /* уход, коротко */
  --t-press: 120ms;
  --t-hover: 160ms;
  --t-ui: 220ms;
  --t-reveal: 700ms;
  --stagger: 70ms;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(button, [role="button"]) { -webkit-tap-highlight-color: transparent; }

/* ---------- page ---------- */
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-body);
  line-height: 1.5;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-1); }

/* ---------- type ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-wrap: balance;
  hyphens: none;
}
.display { font-family: var(--font-display); font-size: var(--step-display); line-height: 0.98; letter-spacing: -0.035em; max-width: 14ch; }
h1 { font-size: var(--step-head); }
h2 { font-size: var(--step-lead); letter-spacing: -0.01em; }
h3 { font-size: var(--step-body); letter-spacing: 0; }
p { max-width: var(--measure); text-wrap: pretty; }
p + p { margin-top: 0.9em; }
.lead { font-size: var(--step-lead); line-height: 1.4; max-width: 44ch; }
.muted { color: var(--muted); }
small, .caption { font-size: var(--step-small); line-height: 1.45; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.9em; }
kbd {
  padding: 1px 6px; border-radius: var(--r-1);
  background: var(--surface); color: var(--muted); font-size: var(--step-small);
}
a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 0.07em; }

/* ---------- layout helpers ---------- */
.page { padding-inline: var(--margin); }
.stack > * + * { margin-top: var(--stack, var(--s-4)); }
.row { display: flex; align-items: center; gap: var(--row, var(--s-3)); flex-wrap: wrap; }

/* ---------- primitives ---------- */
.btn {
  --_bg: var(--surface); --_fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--control-h); padding-inline: calc(var(--control-h) * 0.45);
  border: 0; border-radius: var(--r-1);
  background: var(--_bg); color: var(--_fg);
  font-size: var(--ui-size); font-weight: 500; line-height: 1; white-space: nowrap;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.btn svg { width: 1.1em; height: 1.1em; flex: none; }
.btn--primary { --_bg: var(--accent); --_fg: var(--accent-ink); }
.btn--ghost { --_bg: transparent; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: color-mix(in oklab, var(--_bg), var(--ink) 8%); }
  .btn--primary:hover:not(:disabled) { background: color-mix(in oklab, var(--accent), var(--ink) 14%); }
  .btn--ghost:hover:not(:disabled) { background: var(--surface); }
}

.field { display: grid; gap: var(--s-2); }
.field label { font-size: var(--step-small); font-weight: 500; }
.field .hint { font-size: var(--step-small); color: var(--muted); }
.field .error { font-size: var(--step-small); color: var(--danger); }
.input {
  height: var(--control-h); padding-inline: var(--s-3);
  border: 0; border-radius: var(--r-1);
  background: var(--surface); color: var(--ink); font-size: var(--ui-size);
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow var(--t-hover) ease, background-color var(--t-hover) ease;
}
textarea.input { height: auto; min-height: calc(var(--control-h) * 2.5); padding-block: var(--s-3); resize: vertical; }
.input::placeholder { color: var(--muted); opacity: 0.8; }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--danger); }

.panel { background: var(--surface); border-radius: var(--r-2); padding: var(--s-5); }
.float { background: var(--raised); border-radius: var(--r-2); box-shadow: var(--shadow-float); }

.table { width: 100%; border-collapse: collapse; font-size: var(--ui-size); }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: var(--step-small); }
.table th, .table td { padding: 0 var(--s-3); height: var(--control-h); border-bottom: 1px solid var(--line); }
.table td.num, .table th.num { text-align: right; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(20px); }
  .js .reveal.is-in {
    opacity: 1; transform: none;
    transition: opacity var(--t-reveal) var(--ease-out), transform var(--t-reveal) var(--ease-expo);
    transition-delay: calc(var(--i, 0) * var(--stagger));
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
