/* ============================================================
   ClarityBOT — Base: reset, типографика, зерно, утилиты
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv01';
}

/* ---------- Смена темы ----------
   Переливать цвета у каждого элемента нельзя: на экране входа их два
   десятка, а в панели под тысячу, и каждый кадр браузер перерисовывает
   всё заново — поверх этого ещё зерно с mix-blend-mode и размытие под
   шапкой, оба на весь экран. Отсюда и были десять кадров в секунду.

   Поэтому цвета меняются одним кадром, а плавность даёт одна-единственная
   пелена поверх страницы: она залита прежним фоном и растворяется. Живёт
   на видеокарте, анимируется только прозрачность — ровно 60 кадров при
   любом размере окна. */
html.theme-swap,
html.theme-swap *,
html.theme-swap *::before,
html.theme-swap *::after {
  transition: none !important;
  animation: none !important;
}

.theme-veil {
  position: fixed; inset: 0; z-index: 10000;
  pointer-events: none;
  opacity: 1;
  will-change: opacity;
  transform: translateZ(0);   /* просим отдельный слой — иначе перерисовка */
  transition: opacity 560ms cubic-bezier(.22, 1, .36, 1);
}
.theme-veil.out { opacity: 0; }

/* Пока пелена уходит, зерно молчит: полноэкранный mix-blend-mode
   пересчитывается на каждый её кадр и съедает весь выигрыш. */
html.theme-veiling body::after { display: none; }

/* ---------- Заставка ----------
   Первое, что видно при заходе. Держится, пока грузятся шрифты и данные,
   потом растворяется. Лежит поверх всего и ничего не ждёт от JS: если
   скрипт не выполнится, страховочное правило уберёт её само. */
.preload {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity 620ms var(--ease), visibility 620ms;
}
.preload.done { opacity: 0; visibility: hidden; pointer-events: none; }

.preload-in {
  display: grid; justify-items: center; gap: 18px;
  animation: plIn 700ms var(--ease-out) both;
}
.preload-mark { color: var(--accent); display: grid; place-items: center; }
.preload-mark svg { width: 46px; height: 46px; }
/* Знак прочерчивается: отступ штриха уезжает в ноль, и линия будто рисуется.
   В разметке у обеих линий pathLength=100 — иначе короткая (9.6) дорисуется
   за десятую долю времени, пока длинная (36.9) ещё в пути. */
.preload-mark path {
  stroke-dasharray: 100; stroke-dashoffset: 100;
  animation: plDraw 850ms var(--ease-out) 100ms forwards;
}
.preload-word {
  font-family: var(--font-display); font-size: 30px; font-weight: 500;
  letter-spacing: .01em; color: var(--text);
}
.preload-word span {
  display: inline-block;
  animation: plLetter 500ms var(--ease-out) both;
}
.preload-bar {
  width: 116px; height: 2px; border-radius: 2px;
  background: var(--border-2); overflow: hidden;
}
.preload-bar i {
  display: block; height: 100%; width: 40%;
  background: var(--accent); border-radius: 2px;
  animation: plBar 1.5s var(--ease) infinite;
}

@keyframes plIn     { from { opacity: 0; transform: translateY(8px); } }
@keyframes plDraw   { to   { stroke-dashoffset: 0; } }
@keyframes plLetter { from { opacity: 0; transform: translateY(9px); } }
@keyframes plBar    { 0% { transform: translateX(-115%); } 100% { transform: translateX(290%); } }

@media (prefers-reduced-motion: reduce) {
  .preload-in, .preload-mark path, .preload-word span, .preload-bar i { animation: none; }
  .preload-mark path { stroke-dashoffset: 0; }
}

/* ---------- Зерно бумаги: живая текстура поверх всего ---------- */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999;
  opacity: var(--grain-op);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Типографика ---------- */
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

.display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -.02em;
  font-optical-sizing: auto;
}

h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 21px; line-height: 1.25; }
h3 { font-size: 16px; line-height: 1.35; }
h4 { font-size: 14px; line-height: 1.4; }

p { margin: 0; }

.eyebrow {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
}

.lede    { font-size: 14px; color: var(--text-2); line-height: 1.6; }
.muted   { color: var(--text-2); }
.dim     { color: var(--text-3); }
.mono    { font-family: var(--font-mono); font-size: .92em; font-variant-ligatures: none; }
.tnum    { font-variant-numeric: tabular-nums; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; text-underline-offset: 2px; }

::selection { background: var(--accent-soft); color: var(--text); }

/* ---------- Скроллбары ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--border-str); background-clip: content-box; }

/* ---------- Фокус ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ---------- Иконки ---------- */
.ico { width: 18px; height: 18px; flex: none; stroke-width: 1.6; }
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 22px; height: 22px; }

/* ---------- Утилиты раскладки ---------- */
.row  { display: flex; align-items: center; }
.col  { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.center  { justify-content: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.g1{gap:4px}.g2{gap:8px}.g3{gap:12px}.g4{gap:16px}.g5{gap:20px}.g6{gap:24px}
.mt1{margin-top:4px}.mt2{margin-top:8px}.mt3{margin-top:12px}.mt4{margin-top:16px}
.mt5{margin-top:20px}.mt6{margin-top:24px}.mt7{margin-top:32px}
.mb2{margin-bottom:8px}.mb3{margin-bottom:12px}.mb4{margin-bottom:16px}
.mb5{margin-bottom:20px}.mb6{margin-bottom:24px}
.hidden { display: none !important; }

/* Разделитель. Раньше был градиент с прозрачными концами — в узких
   карточках он читался как обрывок линии, а не как приём. Сплошной. */
.rule {
  height: 1px; border: 0; margin: 0;
  background: var(--border);
}
