/* =============================================================
   KapitalOS · Base
   Сброс + базовая типографика + утилиты раскладки
   ============================================================= */

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

* { margin: 0; }

/* Атрибут hidden должен скрывать всегда — иначе .btn/.fchip/.badge с display:inline-flex
   перебивают его (из-за этого «Редактировать» и чип-сброс не прятались) */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-weight: var(--fw-regular);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  overflow-x: hidden;
}

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

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  text-wrap: balance;
}

p { text-wrap: pretty; }

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--primary-hover); }

ul, ol { list-style: none; padding: 0; }

button { font: inherit; color: inherit; cursor: pointer; }

input, textarea, select { font: inherit; color: inherit; }

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

/* Видимый фокус для клавиатуры */
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Скроллбар */
* { scrollbar-width: thin; scrollbar-color: var(--slate-300) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: var(--r-full);
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* ---------- Раскладка ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}
.container--narrow { max-width: var(--container-narrow); }

.section { padding-block: var(--section-y); }
.section--tight { padding-block: clamp(1.75rem, 3.5vw, 2.75rem); }

/* ---------- Типографические утилиты ---------- */
.display {
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--fw-bold);
}
.h1 { font-size: var(--fs-3xl); }
.h2 { font-size: clamp(1.875rem, 4vw, 2.25rem); }
.h3 { font-size: var(--fs-xl); }
.h4 { font-size: var(--fs-lg); }

.lead {
  font-size: clamp(1.0625rem, 1.8vw, 1.25rem);
  line-height: var(--lh-base);
  color: var(--text-muted);
  font-weight: var(--fw-regular);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-caps);
  line-height: 1;
  text-transform: uppercase;
  color: var(--primary);
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.num { font-family: var(--font-mono); font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }

.measure { max-width: 62ch; }
.measure-narrow { max-width: 46ch; }
.mx-auto { margin-inline: auto; }

/* Доступность: скрыто визуально, видно для скринридеров */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -120%;
  z-index: var(--z-toast);
  background: var(--primary);
  color: var(--text-on-brand);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--r-sm);
  font-weight: var(--fw-medium);
}
.skip-link:focus { top: var(--space-4); color: var(--text-on-brand); }

/* Анимация появления при скролле */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}
