/* ==========================================================================
   SIGNAL — базовая система: токены, шрифты, сброс, типографика, компоненты.
   Принцип: бумага, чернила и один сигнальный цвет. Никаких скруглений.
   ========================================================================== */

@font-face {
  font-family: 'Geologica';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/geologica-cyrillic-full-normal.woff2') format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Geologica';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/geologica-latin-ext-full-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Geologica';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/geologica-latin-full-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Martian Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url('../fonts/martian-mono-cyrillic-standard-normal.woff2') format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Martian Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url('../fonts/martian-mono-latin-ext-standard-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Martian Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  src: url('../fonts/martian-mono-latin-standard-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('../fonts/jetbrains-mono-cyrillic-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('../fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #ebe9e3;
  --paper-2: #e2dfd7;
  --paper-3: #d5d1c6;
  --ink: #0e0e0c;
  --ink-2: #2a2a27;
  --muted: #615f58;                  /* 5.3:1 на бумаге */
  --line: rgba(14, 14, 12, 0.14);
  --line-2: rgba(14, 14, 12, 0.07);
  --accent: #ff4d00;
  --accent-text: #b03600;            /* оранжевый для мелкого текста на бумаге: контраст 5.1:1 */
  --accent-ink: #0e0e0c;
  --ok: #1d7a3d;
  --warn: #b98000;
  --bad: #d3261a;

  --bg: var(--paper);
  --fg: var(--ink);
  --fg-2: var(--ink-2);
  --fg-muted: var(--muted);
  --rule: var(--line);
  --rule-soft: var(--line-2);
  --surface: var(--paper-2);

  --f-display: 'Geologica', 'Helvetica Neue', Arial, sans-serif;
  --f-mono: 'Martian Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --f-code: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-snap: cubic-bezier(0.7, 0, 0.2, 1);
  --t-fast: 0.22s;
  --t: 0.45s;
  --t-slow: 0.9s;

  --gutter: clamp(16px, 2.4vw, 36px);
  --maxw: 1600px;
  --header-h: 64px;

  color-scheme: light;
}

.inv {
  --bg: var(--ink);
  --fg: var(--paper);
  --fg-2: #c9c6be;
  --fg-muted: #8d8a82;
  --accent-text: var(--accent);
  --rule: rgba(235, 233, 227, 0.16);
  --rule-soft: rgba(235, 233, 227, 0.08);
  --surface: #1a1a17;
  background: var(--bg);
  color: var(--fg);
}

/* --- Ничего не закругляем. Совсем. --- */
*, *::before, *::after { border-radius: 0 !important; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-display);
  font-size: 17px;
  line-height: 1.5;
  font-weight: 400;
  font-variation-settings: 'SHRP' 40;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
p { margin: 0 0 1em; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
::selection { background: var(--accent); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Скроллбар — тоже прямоугольный */
* { scrollbar-width: thin; scrollbar-color: var(--ink) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--ink); border: 3px solid var(--paper); }
::-webkit-scrollbar-track { background: transparent; }

/* --- Типографика --- */
.display {
  font-family: var(--f-display);
  font-weight: 800;
  font-variation-settings: 'SHRP' 100;
  text-transform: uppercase;
  letter-spacing: -0.045em;
  line-height: 1;
}
.h1 { font-size: clamp(44px, 7.2vw, 128px); }
.h2 { font-size: clamp(36px, 5.2vw, 92px); }
.h3 { font-size: clamp(24px, 2.4vw, 40px); letter-spacing: -0.03em; line-height: 1; }
.lead { font-size: clamp(18px, 1.45vw, 23px); line-height: 1.45; color: var(--fg-2); max-width: 46ch; font-variation-settings: 'SHRP' 20; }
.mono {
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-stretch: 87.5%;
  font-weight: 450;
}
.mono-lg { font-family: var(--f-mono); font-stretch: 87.5%; letter-spacing: -0.02em; }
.code, code, pre { font-family: var(--f-code); font-size: 13.5px; }
.muted { color: var(--fg-muted); }
.idf { font-family: var(--f-code); font-size: 12px; text-transform: none; letter-spacing: 0; }
.accent { color: var(--accent-text); }
.tnum { font-variant-numeric: tabular-nums; }

/* --- Сетка --- */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); }

/* Видимые направляющие колонок — подпись швейцарской вёрстки */
.guides {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.guides span { border-left: 1px solid var(--line-2); height: 100%; }
.guides span:last-child { border-right: 1px solid var(--line-2); }
@media (max-width: 760px) {
  .guides { grid-template-columns: repeat(4, 1fr); }
  .guides span:nth-child(n + 5) { display: none; }
  .guides span:nth-child(4) { border-right: 1px solid var(--line-2); }
}

/* Зерно бумаги */
.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 90;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* --- Кнопки --- */
.btn {
  --b-bg: transparent;
  --b-fg: var(--fg);
  --b-border: var(--fg);
  --b-fill: var(--fg);
  --b-fill-fg: var(--bg);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 52px;
  padding: 0 22px;
  border: 1px solid var(--b-border);
  background: var(--b-bg);
  color: var(--b-fg);
  font-family: var(--f-mono);
  font-size: 12px;
  font-stretch: 87.5%;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  isolation: isolate;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
  user-select: none;
}
.btn::before {
  content: '';
  position: absolute;
  inset: -1px;
  background: var(--b-fill);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  transition: transform var(--t) var(--ease);
  z-index: -1;
}
.btn:hover::before, .btn:focus-visible::before { transform: scaleY(1); transform-origin: 50% 0; }
.btn:hover, .btn:focus-visible { color: var(--b-fill-fg); }
.btn .arr { display: inline-block; transition: transform var(--t) var(--ease); }
.btn:hover .arr { transform: translateX(4px); }
.btn--accent { --b-bg: var(--accent); --b-fg: var(--ink); --b-border: var(--accent); --b-fill: var(--ink); --b-fill-fg: var(--paper); }
.inv .btn--accent:hover { --b-fill: var(--paper); --b-fill-fg: var(--ink); }
.btn--solid { --b-bg: var(--fg); --b-fg: var(--bg); --b-fill: var(--accent); --b-fill-fg: var(--ink); --b-border: var(--fg); }
.btn--sm { height: 38px; padding: 0 14px; font-size: 11px; gap: 10px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-busy { pointer-events: none; opacity: 0.55; }
.btn.is-busy::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 30%;
  background: currentColor;
  animation: busy 0.9s var(--ease-io) infinite;
}
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.link {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size var(--t) var(--ease);
  padding-bottom: 1px;
}
.link:hover { background-size: 100% 1px; }
.link--u { background-size: 100% 1px; }
.link--u:hover { background-size: 0 1px; background-position: 100% 100%; }

/* --- Поля ввода --- */
.field { display: grid; gap: 8px; align-content: start; }
.field > label, .field > .label { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.02em; font-stretch: 87.5%; color: var(--fg-muted); }
.input, .select, .textarea {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: transparent;
  border: 1px solid var(--fg);
  color: var(--fg);
  font-size: 16px;
  outline: none;
  transition: box-shadow var(--t-fast) var(--ease), background var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}
.textarea { height: auto; min-height: 120px; padding: 14px 16px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { box-shadow: inset 0 0 0 1px var(--fg), 6px 6px 0 var(--accent); }
.input::placeholder, .textarea::placeholder { color: var(--fg-muted); }
.select {
  padding-right: 44px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 22px) 23px, calc(100% - 17px) 23px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.select option { background: var(--paper); color: var(--ink); }
.input--sm, .select--sm { height: 40px; font-size: 14px; padding: 0 12px; }
.select--sm { padding-right: 36px; background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 14px; line-height: 1.4; }
.check input { appearance: none; -webkit-appearance: none; flex: 0 0 18px; width: 18px; height: 18px; border: 1px solid var(--fg); margin: 1px 0 0; position: relative; cursor: pointer; }
.check input:checked { background: var(--fg); }
.check input:checked::after { content: ''; position: absolute; inset: 4px; background: var(--accent); }

.range { appearance: none; -webkit-appearance: none; width: 100%; height: 24px; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, var(--fg) var(--p, 50%), var(--rule) var(--p, 50%)); }
.range::-moz-range-track { height: 2px; background: var(--rule); }
.range::-moz-range-progress { height: 2px; background: var(--fg); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; background: var(--accent); border: 1px solid var(--ink); transition: transform var(--t-fast) var(--ease); }
.range::-moz-range-thumb { width: 14px; height: 14px; background: var(--accent); border: 1px solid var(--ink); }
.range:active::-webkit-slider-thumb { transform: scale(1.35) rotate(45deg); }

/* --- Значки и метки --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid currentColor;
  font-family: var(--f-mono);
  font-size: 10px;
  font-stretch: 87.5%;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tag--fill { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tag--accent { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.dot, .sq, .blk, .caret { display: none !important; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--bad { background: var(--bad); }
.dot--idle { background: var(--fg-muted); }
.dot--live { background: var(--accent); animation: blink 1.4s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

/* --- Тосты --- */
.toasts { position: fixed; right: var(--gutter); bottom: var(--gutter); z-index: 200; display: grid; gap: 8px; width: min(420px, calc(100vw - 2 * var(--gutter))); }
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 16px 14px 18px;
  border-left: 6px solid var(--accent);
  font-size: 14px;
  line-height: 1.4;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: toast-in 0.5s var(--ease) both;
  box-shadow: 8px 8px 0 rgba(14, 14, 12, 0.2);
}
.toast--ok { border-left-color: #3ccf6e; }
.toast--bad { border-left-color: var(--bad); }
.toast.is-out { animation: toast-out 0.35s var(--ease-io) both; }
@keyframes toast-in { from { transform: translateX(110%); } to { transform: none; } }
@keyframes toast-out { to { transform: translateX(110%); opacity: 0; } }

/* --- Модальное окно --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: rgba(14, 14, 12, 0.55);
  animation: fade-in 0.3s var(--ease) both;
}
.modal__box {
  width: min(560px, 100%);
  max-height: calc(100vh - 2 * var(--gutter));
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  box-shadow: 14px 14px 0 var(--accent);
  animation: modal-in 0.55s var(--ease) both;
}
.modal__head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--ink); }
.modal__body { padding: 24px 20px; display: grid; gap: 18px; }
.modal__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal.is-out { animation: fade-out 0.25s both; }
.modal.is-out .modal__box { animation: modal-out 0.25s var(--ease-io) both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes modal-in { from { clip-path: inset(0 0 100% 0); transform: translateY(24px); } to { clip-path: inset(0 0 0 0); transform: none; } }
@keyframes modal-out { to { clip-path: inset(100% 0 0 0); } }

.x-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid currentColor; transition: background var(--t-fast), color var(--t-fast); }
.x-btn:hover { background: var(--ink); color: var(--paper); }

/* --- Код --- */
.codeblock {
  position: relative;
  background: var(--ink);
  color: #e9e6dd;
  border: 1px solid var(--ink);
  font-family: var(--f-code);
  font-size: 13.5px;
  line-height: 1.65;
}
.codeblock pre { margin: 0; padding: 20px 22px; overflow-x: auto; white-space: pre; }
.codeblock .copy { position: absolute; top: 10px; right: 10px; }
.tok-k { color: #ff8a4c; }
.tok-s { color: #c4e48b; }
.tok-c { color: #7d7a72; }
.tok-n { color: #8fd3ff; }
.tok-p { color: #e9e6dd; }

/* --- Логотип --- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -0.04em; text-transform: uppercase; font-variation-settings: 'SHRP' 100; }
.logo svg { width: 30px; height: 20px; }
.logo svg path { stroke: currentColor; }
.logo .logo-pulse { stroke: var(--accent); stroke-dasharray: 80; stroke-dashoffset: 80; animation: logo-draw 2.4s var(--ease-io) 0.3s forwards; }
@keyframes logo-draw { to { stroke-dashoffset: 0; } }

/* Одометр */
.odo { display: inline-flex; overflow: hidden; line-height: 1; height: 1em; }
.odo-d { display: inline-block; height: 1em; overflow: hidden; position: relative; }
.odo-col { display: block; width: 1ch; word-break: break-all; white-space: normal; line-height: 1; transition: transform 1.1s var(--ease); }
.odo-s { display: inline-block; white-space: pre; }

/* --- Анимации появления (включаются классом .is-in) --- */
.js [data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease); transition-delay: var(--d, 0s); }
.js [data-reveal='fade'] { transform: none; }
.js [data-reveal='left'] { transform: translateX(-36px); }
.js [data-reveal='wipe'] { opacity: 1; transform: none; }
.js [data-reveal='wipe'] > * { clip-path: inset(0 100% 0 0); transition: clip-path 1.1s var(--ease-io); transition-delay: var(--d, 0s); }
.js [data-reveal='wipe'].is-in > * { clip-path: inset(0 0 0 0); }
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* Разбитый на строки/слова/буквы текст */
.split-line { display: block; overflow: hidden; padding: 0.12em 0 0.16em; margin: -0.12em 0 -0.16em; }
.split-word { display: inline-block; overflow: hidden; vertical-align: top; white-space: nowrap; padding: 0.22em 0.04em 0.2em; margin: -0.22em -0.04em -0.2em; }
.split-char { display: inline-block; will-change: transform; }
.js [data-split] .split-char,
.js [data-split] .split-inner { transform: translateY(118%); transition: transform 1.05s var(--ease); transition-delay: calc(var(--i, 0) * 0.028s + var(--d, 0s)); }
.js [data-split].is-in .split-char,
.js [data-split].is-in .split-inner { transform: none; }
.split-inner { display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0s !important; }
  .grain { display: none; }
}

/* --- Доступность: переход к содержимому с клавиатуры --- */
.skip-link { position: fixed; left: 12px; top: -100px; z-index: 1000; background: var(--ink); color: var(--paper); padding: 10px 14px; font-family: var(--f-mono); font-size: 12px; text-transform: uppercase; }
.skip-link:focus { top: 12px; }

/* --- Уведомление о cookie --- */
.cookie-note { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 900; max-width: 520px; display: flex; gap: 16px; align-items: center; padding: 14px 16px; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.cookie-note p { margin: 0; font-size: 14px; line-height: 1.45; }
.cookie-note a { color: var(--accent); text-decoration: underline; }
.cookie-note .btn { flex: none; --b-bg: var(--paper); --b-fg: var(--ink); --b-border: var(--paper); }
@media (max-width: 520px) { .cookie-note { flex-direction: column; align-items: stretch; } }
