/* base.css — токены, типографика, layout, утилиты */
/* Защитный CSS (CLAUDE.md): аномальные файлы не ломают вёрстку */
img, svg, video { max-width: 100%; max-height: 400px; height: auto; }
[hidden] { display: none !important; }

/* === Шрифт Roboto self-hosted (3 веса) === */
@font-face {
  font-family: 'Roboto'; font-style: normal; font-weight: 400;
  font-display: swap;
  src: url('/docs-right2/static/fonts/Roboto-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Roboto'; font-style: normal; font-weight: 500;
  font-display: swap;
  src: url('/docs-right2/static/fonts/Roboto-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'Roboto'; font-style: normal; font-weight: 700;
  font-display: swap;
  src: url('/docs-right2/static/fonts/Roboto-Bold.woff2') format('woff2');
}

/* === CSS-токены PEREPLAN === */
:root {
  /* Бренд */
  --c-brand: #126aee;
  --c-brand-dark: #1b3388;
  --c-brand-light: #79bbff;
  --c-brand-50: #e8f0fd;
  --c-brand-100: #d2e3fd;

  /* Нейтрали */
  --c-bg: #f9f9f9;
  --c-surface: #fff;
  --c-text: #222;
  --c-muted: #6b7280;
  --c-soft: #a5a9b3;
  --c-border: #e6e8ec;
  --c-border-strong: rgba(0,0,0,.12);
  --c-on-brand: #fff;

  /* Тёмные акценты (для конкретных компонентов, в палитру не идут) */
  --c-toast-bg: #1f2937;
  --c-danger-hover: #931616;
  --c-skel-1: #eeeff1;
  --c-skel-2: #f6f7f9;

  /* Семантика статусов (фон + текст с AA-контрастом) */
  --c-success: #1f9d55;       --c-success-bg: #e3f5ec;  --c-success-text: #0d6b45;
  --c-warning: #d97a00;       --c-warning-bg: #fff1dd;  --c-warning-text: #8a4d00;
  --c-danger:  #b91c1c;       --c-danger-bg:  #fce8e6;  --c-danger-text:  #a1231d;
  --c-info:    #2563eb;       --c-info-bg:    #dbeafe;  --c-info-text:    #1b3388;
  --c-purple:  #6b46c1;       --c-purple-bg:  #eee6fa;  --c-purple-text:  #4b2e92;
  --c-grey:    #6b7280;       --c-grey-bg:    #eeeff1;  --c-grey-text:    #4b5563;

  /* Геометрия */
  --r-sm: 8px;   --r-md: 12px;   --r-lg: 16px;   --r-xl: 20px;   --r-pill: 999px;
  --sp-1: 4px;   --sp-2: 8px;    --sp-3: 12px;   --sp-4: 16px;   --sp-5: 20px;
  --sp-6: 24px;  --sp-7: 28px;   --sp-8: 32px;   --sp-10: 40px;  --sp-12: 48px;

  /* Тени мягкие */
  --shadow-1: 0 1px 2px rgba(0,0,0,.04);
  --shadow-2: 0 2px 8px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --shadow-3: 0 8px 24px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.04);

  /* Анимация */
  --ease: cubic-bezier(.16,.84,.32,1);
  --t-fast: 140ms;
  --t-med: 200ms;
  --t-slow: 320ms;

  /* Layout */
  --header-h: 56px;
  --content-max: 1180px;

  /* Уровни вложенности процессов (конструктор): корень/подпроцесс/под-под */
  --c-level-0: var(--c-brand);
  --c-level-1: var(--c-purple);
  --c-level-2: #d6336c;
  --c-level-2-bg: #fce4ec;

  /* Полевик (field_app) — производные от бренда */
  --c-fa-text:     #1d1f23;
  --c-fa-text-2:   #6e7681;
  --c-fa-text-3:   #97a0aa;
  --c-fa-line:     #e8eaed;
  --c-fa-success:  #1a8a3c;
  --c-fa-err:      #c0392b;
  --c-fa-brand-lt: #d0e4fc;
  --c-fa-success-lt: #e6f4ea;
  --c-fa-info-lt:  #eef4ff;
}

/* === Базовый reset === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Roboto', -apple-system, system-ui, Segoe UI, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100dvh;
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--c-brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

ol, ul { margin: 0; padding-left: 1.4em; }
p { margin: 0 0 var(--sp-3); }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--sp-4) 0; }

/* === Типографика === */
h1, h2, h3, h4 { margin: 0 0 var(--sp-3); color: var(--c-text); font-weight: 500; }
h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -.005em; }
h2 { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -.005em; }
h3 { font-size: 18px; line-height: 1.3; font-weight: 500; }
h4 { font-size: 16px; line-height: 1.35; font-weight: 500; }

.small      { font-size: 14px; line-height: 1.45; }
.caption    { font-size: 13px; line-height: 1.4; font-weight: 500; color: var(--c-muted); }
.eyebrow    { font-size: 11px; line-height: 1.3; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--c-muted); }
.muted      { color: var(--c-muted); }
.soft       { color: var(--c-soft); }
.mono       { font-variant-numeric: tabular-nums; }

@media (max-width: 768px) {
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
}

/* === Skip link (a11y) === */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--c-brand); color: #fff;
  padding: 12px 18px; border-radius: 0 0 var(--r-sm) 0;
  z-index: 999;
}
.skip-link:focus { left: 0; }

/* === Top bar === */
.top-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) var(--sp-4);
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.top-bar .brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  color: var(--c-text); font-weight: 500; font-size: 15px;
}
.top-bar .brand img { height: 22px; width: auto; max-height: none; }
.top-bar nav { display: inline-flex; align-items: center; gap: var(--sp-3); }
.top-bar nav .caption { white-space: nowrap; }

/* === Main / контейнер === */
main { padding: var(--sp-4); max-width: var(--content-max); margin: 0 auto; }
@media (min-width: 768px) { main { padding: var(--sp-6); } }
.container-narrow { max-width: 560px; margin: 0 auto; }

/* === Утилиты flex/grid === */
.flex   { display: flex; }
.iflex  { display: inline-flex; }
.col    { flex-direction: column; }
.wrap   { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.grow   { flex: 1 1 auto; min-width: 0; }
.shrink-0 { flex-shrink: 0; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 768px) {
  .grid-cols-2, .grid-cols-3 { grid-template-columns: 1fr; }
}

/* gap */
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

/* spacing */
.mt-2 { margin-top: var(--sp-2); }  .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }  .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }  .mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }  .mb-6 { margin-bottom: var(--sp-6); }
.py-4 { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }

/* text */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-brand  { color: var(--c-brand-dark); }
.text-success{ color: var(--c-success-text); }
.text-warning{ color: var(--c-warning-text); }
.text-danger { color: var(--c-danger-text); }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.break { word-break: break-word; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }

/* backgrounds */
.bg-surface { background: var(--c-surface); }
.bg-soft    { background: var(--c-bg); }
.bg-brand-50{ background: var(--c-brand-50); }

/* === Focus ring (a11y) === */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* === mark подсветка поиска === */
mark {
  background: var(--c-brand-50);
  color: var(--c-brand-dark);
  padding: 0 2px;
  border-radius: 3px;
}

/* === scrollbar для desktop === */
@media (hover: hover) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 5px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.2); }
}

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

/* === safe-area для iPhone notch === */
@supports (padding: max(0px)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}
