/* ===== Дикий Маркс — design tokens ===== */
:root {
  /* warm white / graphite */
  --bg: #f5f2ec;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #ece9e2;
  --surface-3: #e1ddd4;
  --ink: #14130f;
  --ink-2: #44423c;
  --ink-3: #7a7770;
  --ink-mute: #a6a39c;
  --line: rgba(20, 19, 15, 0.10);
  --line-strong: rgba(20, 19, 15, 0.18);

  /* brand */
  --red: #a11d20;
  --red-deep: #7a1417;
  --red-soft: rgba(161, 29, 32, 0.10);
  --red-line: rgba(161, 29, 32, 0.30);

  /* steel — links / interactive */
  --steel: #2d5d7a;
  --steel-2: #1f4358;
  --steel-soft: rgba(45, 93, 122, 0.10);

  /* status */
  --ok: #2d6a3e;
  --warn: #8a5a00;

  /* radii / shadow */
  --r-1: 4px;
  --r-2: 8px;
  --r-3: 14px;
  --r-4: 20px;
  --shadow-1: 0 1px 0 rgba(20,19,15,0.04), 0 1px 2px rgba(20,19,15,0.04);
  --shadow-2: 0 2px 0 rgba(20,19,15,0.04), 0 8px 24px rgba(20,19,15,0.08);

  /* type */
  --font-sans: "IBM Plex Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* layout */
  --maxw: 1280px;
  --gutter: 28px;
  --col-gap: 24px;
}

[data-theme="dark"] {
  --bg: #16181a;
  --bg-elev: #1c1f22;
  --surface: #1d2024;
  --surface-2: #25282d;
  --surface-3: #2c3035;
  --ink: #ececea;
  --ink-2: #b9bbbd;
  --ink-3: #898c90;
  --ink-mute: #5d6064;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --red: #d04144;
  --red-deep: #a11d20;
  --red-soft: rgba(208, 65, 68, 0.12);
  --red-line: rgba(208, 65, 68, 0.35);
  --steel: #7aa6c2;
  --steel-2: #a4c5db;
  --steel-soft: rgba(122, 166, 194, 0.10);
  --shadow-1: 0 1px 0 rgba(0,0,0,0.4);
  --shadow-2: 0 2px 0 rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

a { color: var(--steel); text-decoration: none; }
a:hover { color: var(--steel-2); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--steel);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ===== type scale ===== */
.t-d1 { font-size: clamp(40px, 5.6vw, 80px); line-height: 0.96; letter-spacing: -0.02em; font-weight: 600; }
.t-d2 { font-size: clamp(32px, 4.2vw, 56px); line-height: 1.02; letter-spacing: -0.018em; font-weight: 600; }
.t-h1 { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.08; letter-spacing: -0.014em; font-weight: 600; }
.t-h2 { font-size: clamp(22px, 2.2vw, 28px); line-height: 1.18; letter-spacing: -0.01em; font-weight: 600; }
.t-h3 { font-size: 19px; line-height: 1.3; font-weight: 600; letter-spacing: -0.005em; }
.t-body { font-size: 16px; line-height: 1.55; }
.t-body-lg { font-size: 18px; line-height: 1.55; }
.t-small { font-size: 14px; line-height: 1.5; }
.t-mono { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0; }
.t-eyebrow {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  color: var(--ink-3); text-transform: uppercase;
}

.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.red { color: var(--red); }

/* ===== layout ===== */
.shell { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: 96px 0; border-top: 1px solid var(--line); }
.section.compact { padding: 64px 0; }
.section.tight { padding: 48px 0; }
.section:first-of-type { border-top: none; }

.row { display: flex; gap: 24px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 24px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.between { justify-content: space-between; }
.center { align-items: center; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }

@media (max-width: 920px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .section { padding: 64px 0; }
  :root { --gutter: 20px; }
}

/* ===== buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 15px/1 var(--font-sans);
  padding: 12px 18px; border-radius: var(--r-2);
  border: 1px solid transparent; cursor: pointer; transition: all 0.12s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn .arrow { font-family: var(--font-mono); font-size: 14px; opacity: 0.85; }

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-deep); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-link { background: transparent; color: var(--steel); padding: 8px 0; border: none; }
.btn-link:hover { color: var(--steel-2); }
.btn-sm { padding: 8px 12px; font-size: 14px; }

/* ===== cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: 28px;
}
.card.flat { background: transparent; border-color: var(--line); }
.card.padded { padding: 36px; }
.card .card-eyebrow {
  font-family: var(--font-mono); font-size: 12px; color: var(--red);
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 12px;
}

/* ===== badges / chips ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px;
  padding: 4px 10px; border-radius: 100px;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge-red { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.badge-steel { background: var(--steel-soft); color: var(--steel); border-color: rgba(45,93,122,0.2); }
.badge-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); color: var(--ink-2);
}

/* ===== form ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-2); }
.field input, .field textarea, .field select {
  font: 15px/1.4 var(--font-sans);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  padding: 12px 14px;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--steel);
}
.checkbox-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--ink-2); }
.checkbox-row input { margin-top: 3px; }

/* ===== utility ===== */
.divider { height: 1px; background: var(--line); }
.dot { width: 8px; height: 8px; background: var(--red); border-radius: 50%; display: inline-block; }
.kbd {
  font-family: var(--font-mono); font-size: 12px;
  padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 4px; background: var(--surface);
}

/* circuit decorative */
.node { width: 9px; height: 9px; border-radius: 50%; background: var(--red); display: inline-block; }
.node.hollow { background: transparent; border: 2px solid var(--red); width: 11px; height: 11px; }

/* page wrapper */
.page { min-height: 60vh; }
.page-hero { padding-top: 64px; padding-bottom: 56px; }

/* anchor offset for sticky header */
[id] { scroll-margin-top: 88px; }

/* skip link */
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--red); color: #fff; padding: 10px 14px; z-index: 999; border-radius: 4px; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--ink-3); font-weight: 500; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }

/* prose for legal */
.prose h2 { margin-top: 36px; }
.prose h3 { margin-top: 24px; }
.prose p, .prose li { color: var(--ink-2); max-width: 70ch; }
.prose ol, .prose ul { padding-left: 1.2em; }

/* ===== mobile refinements ===== */
@media (max-width: 720px) {
  :root { --gutter: 18px; }
  .section { padding: 56px 0; }
  .section.compact { padding: 44px 0; }
  .page-hero { padding-top: 40px; padding-bottom: 36px; }
  .card.padded { padding: 24px; }
  .card { padding: 22px; }
  .t-d1 { font-size: clamp(34px, 9vw, 56px); line-height: 1; }
  .t-d2 { font-size: clamp(28px, 7.5vw, 44px); }
  .t-h1 { font-size: clamp(24px, 6vw, 32px); }
  .t-body-lg { font-size: 16px; }
  .btn { padding: 12px 16px; min-height: 44px; }
  .btn-sm { min-height: 36px; }
  /* tap target sanity */
  a, button { -webkit-tap-highlight-color: transparent; }
  .tbl th, .tbl td { padding: 12px 10px; font-size: 13px; }
}

@media (max-width: 420px) {
  :root { --gutter: 16px; }
  .section { padding: 48px 0; }
  .t-d1 { font-size: 36px; }
  .t-d2 { font-size: 30px; }
  .t-h1 { font-size: 24px; }
  .card { padding: 18px; }
  .card.padded { padding: 18px; }
}

/* prevent horizontal overflow on long mono strings (стек, реквизиты) */
.t-mono { overflow-wrap: anywhere; word-break: break-word; }
.tbl td.t-mono, .tbl td .t-mono { word-break: break-word; }
img, svg { max-width: 100%; }
