/* ==========================================================
   Telematria — таблица стилей
   Один файл. Ноль внешних запросов. Ноль скриптов.
   ========================================================== */

:root {
  --bg:        #fbfbfd;
  --surface:   #ffffff;
  --panel:     #f3f4f8;
  --ink:       #10121a;
  --muted:     #61697c;
  --line:      #e6e8f0;
  --line-soft: #eef0f6;

  --accent:    #4338ca;
  --accent-2:  #0ea5b7;
  --accent-ink:#3730a3;
  --accent-bg: #eeecfb;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "JetBrains Mono", Consolas, "DejaVu Sans Mono", monospace;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(16,18,26,.05), 0 1px 1px rgba(16,18,26,.03);
  --shadow-md: 0 4px 16px rgba(16,18,26,.06), 0 1px 3px rgba(16,18,26,.04);

  --t--2: .75rem;
  --t--1: .875rem;
  --t-1:  1.125rem;
  --t-2:  1.375rem;
  --t-3:  1.875rem;
  --t-4:  2.75rem;
  --t-5:  3.75rem;

  --shell: 88rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0b0c10;
    --surface:   #121419;
    --panel:     #171a21;
    --ink:       #eceef4;
    --muted:     #99a1b5;
    --line:      #23262f;
    --line-soft: #1b1e26;
    --accent:    #8b85f5;
    --accent-2:  #2dd4bf;
    --accent-ink:#a9a4ff;
    --accent-bg: #1b1a2e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 6px 24px rgba(0,0,0,.45);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; }

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 1rem; top: 1rem; z-index: 60;
  background: var(--ink); color: var(--bg);
  padding: .5rem .9rem; border-radius: var(--r-sm);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- Верхняя панель ---------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(1px)) {
  .topbar { background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(1.6) blur(12px); }
}
.topbar__in {
  max-width: var(--shell); margin-inline: auto;
  padding: .7rem 1.5rem; display: flex; align-items: center; gap: 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  text-decoration: none; font-weight: 650; letter-spacing: -.015em; font-size: var(--t-1);
}
.brand__glyph {
  width: 1.4rem; height: 1.4rem; border-radius: 6px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.brand__sub { color: var(--muted); font-weight: 450; font-size: var(--t--1); }
.topbar__spacer { flex: 1; }

.topnav { display: flex; align-items: center; gap: 1.4rem; font-size: var(--t--1); }
.topnav a { text-decoration: none; color: var(--muted); }
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 550; }

.langswitch {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px;
  padding: 2px; background: var(--surface);
  font-size: var(--t--2); font-weight: 600; letter-spacing: .04em;
}
.langswitch a { text-decoration: none; color: var(--muted); padding: .18rem .6rem; border-radius: 999px; }
.langswitch a[aria-current="true"] { background: var(--accent-bg); color: var(--accent-ink); }

@media (max-width: 52rem) {
  .brand__sub { display: none; }
  .topnav { gap: 1rem; }
}

/* ---------- Каркас ---------- */

.shell { max-width: var(--shell); margin-inline: auto; padding-inline: 1.5rem; }
.shell--docs { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 3rem; align-items: start; }
@media (max-width: 62rem) { .shell--docs { grid-template-columns: minmax(0, 1fr); gap: 1rem; } }

/* ---------- Навигация по этапам ---------- */

.navdrop { margin-block: 2.5rem; }
.navdrop > summary {
  cursor: pointer; list-style: none;
  padding: .7rem 1rem; font-weight: 600; font-size: var(--t--1);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  display: flex; justify-content: space-between; align-items: center;
}
.navdrop > summary::-webkit-details-marker { display: none; }
.navdrop > summary::after { content: "▾"; color: var(--muted); }
.navdrop[open] > summary::after { content: "▴"; }
.navdrop__body { padding-top: 1rem; }

@media (min-width: 62.01rem) {
  .navdrop { position: sticky; top: 5rem; }
  .navdrop > summary { display: none; }
  .navdrop__body { display: block; padding-top: 0; }
}
@media (max-width: 62rem) { .navdrop { margin-block: 1.25rem 0; } }

.sidenav__label {
  font-size: var(--t--2); text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); font-weight: 650; margin: 0 0 1rem;
}
@media (max-width: 62rem) { .sidenav__label { display: none; } }

.spine { list-style: none; margin: 0; padding: 0; position: relative; font-size: var(--t--1); }
.spine::before {
  content: ""; position: absolute; left: .43rem; top: .8rem; bottom: .8rem; width: 2px;
  border-radius: 2px; background: linear-gradient(to bottom, var(--accent), var(--accent-2)); opacity: .28;
}
.spine__item { position: relative; }
.spine__link {
  display: block; text-decoration: none; color: var(--muted);
  padding: .42rem 0 .42rem 1.75rem;
}
.spine__link::before {
  content: ""; position: absolute; left: 0; top: .78rem;
  width: .95rem; height: .95rem; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
}
.spine__link:hover { color: var(--ink); }
.spine__link:hover::before { border-color: var(--accent); }
.spine__item.is-current > .spine__link { color: var(--ink); font-weight: 600; }
.spine__item.is-current > .spine__link::before {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; box-shadow: 0 0 0 4px var(--accent-bg);
}
.spine__ord { font-family: var(--font-mono); font-size: var(--t--2); color: var(--muted); margin-right: .45rem; }

.spine__sub { list-style: none; margin: .1rem 0 .4rem; padding: 0 0 0 1.75rem; }
.spine__sub a {
  display: block; text-decoration: none; color: var(--muted);
  padding: .18rem 0 .18rem .8rem; border-left: 2px solid var(--line);
}
.spine__sub a:hover { color: var(--ink); border-left-color: var(--accent); }
.spine__sub a[aria-current="page"] { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 550; }

/* ---------- Главный экран ---------- */

.hero { padding: 4.5rem 0 3rem; }
.pill {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--accent-bg); color: var(--accent-ink); border-radius: 999px;
  padding: .3rem .85rem; font-size: var(--t--2); font-weight: 600; margin-bottom: 1.4rem;
}
.hero h1 {
  font-size: clamp(2.1rem, 5.2vw, var(--t-5)); line-height: 1.05;
  letter-spacing: -.035em; font-weight: 700; margin: 0 0 1.2rem; max-width: 19ch;
}
.grad {
  background: linear-gradient(105deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { font-size: var(--t-1); color: var(--muted); max-width: 54ch; margin: 0; }

.actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 2rem; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem; text-decoration: none;
  font-size: var(--t--1); font-weight: 600; padding: .62rem 1.15rem;
  border-radius: 999px; border: 1px solid transparent;
}
.btn--primary { background: var(--ink); color: var(--bg); }
.btn--primary:hover { opacity: .88; }
.btn--ghost { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Конвейер ---------- */

.pipeline { margin-top: 3.5rem; }
.pipeline__track {
  list-style: none; margin: 0; padding: 0; position: relative;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem;
}
.pipeline__track::before {
  content: ""; position: absolute; left: 4%; right: 4%; top: .52rem; height: 2px;
  background: linear-gradient(to right, var(--accent), var(--accent-2)); opacity: .3;
}
.pipeline__cell { position: relative; }
.pipeline__link { display: block; text-decoration: none; padding-top: 1.7rem; }
.pipeline__link::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: 1.05rem; height: 1.05rem; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
}
.pipeline__link:hover::before { border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.pipeline__ord { font-family: var(--font-mono); font-size: var(--t--2); color: var(--muted); display: block; }
.pipeline__name { font-weight: 600; font-size: var(--t--1); display: block; margin-top: .1rem; }
.pipeline__link:hover .pipeline__name { color: var(--accent-ink); }
@media (max-width: 46rem) {
  .pipeline__track { grid-template-columns: 1fr 1fr; gap: 1rem .5rem; }
  .pipeline__track::before { display: none; }
}

/* ---------- Секции и карточки ---------- */

.section { padding: 4rem 0; border-top: 1px solid var(--line-soft); }
.section--first { border-top: 0; padding-top: 2.5rem; }
.section__head { margin-bottom: 2rem; max-width: 58ch; }
.section__eyebrow {
  font-size: var(--t--2); text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent-ink); font-weight: 700; margin: 0 0 .6rem;
}
.section__title { font-size: var(--t-3); letter-spacing: -.025em; line-height: 1.18; margin: 0 0 .7rem; font-weight: 680; }
.section__note { color: var(--muted); margin: 0; }

.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; }
.card {
  grid-column: span 2; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1.5rem; text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-md); }
.card--wide { grid-column: span 3; }
.card__ord {
  font-family: var(--font-mono); font-size: var(--t--2); font-weight: 700;
  letter-spacing: .1em; color: var(--accent-ink); margin-bottom: 1.6rem;
}
.card__title { font-size: var(--t-2); letter-spacing: -.02em; font-weight: 650; margin: 0 0 .45rem; }
.card__note { color: var(--muted); font-size: var(--t--1); margin: 0; }
.card__more { margin-top: 1.1rem; font-size: var(--t--1); font-weight: 600; color: var(--accent-ink); }
@media (max-width: 62rem) { .bento { grid-template-columns: repeat(2, 1fr); } .card, .card--wide { grid-column: span 1; } }
@media (max-width: 40rem) { .bento { grid-template-columns: 1fr; } }

/* ---------- Списки материалов ---------- */

.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.entry {
  display: grid; grid-template-columns: 3.4rem minmax(0,1fr) auto; gap: 1rem;
  align-items: baseline; text-decoration: none; padding: 1rem 1.2rem;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line);
}
.entry:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.entry__ord { font-family: var(--font-mono); font-size: var(--t--2); color: var(--muted); }
.entry__title { font-weight: 600; }
.entry__note { display: block; color: var(--muted); font-size: var(--t--1); font-weight: 400; margin-top: .15rem; }
.entry__arrow { color: var(--muted); font-size: var(--t--1); }
.entry:hover .entry__arrow { color: var(--accent-ink); }
.entry--draft { background: transparent; border-style: dashed; color: var(--muted); }
.tag {
  font-size: var(--t--2); font-weight: 600; letter-spacing: .04em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .55rem; white-space: nowrap;
}
@media (max-width: 40rem) {
  .entry { grid-template-columns: 2.6rem minmax(0,1fr); }
  .entry__arrow, .entry .tag { display: none; }
}

/* ---------- Статья ---------- */

.doc { padding-block: 2.5rem 4rem; max-width: 46rem; }
.crumbs { font-size: var(--t--1); color: var(--muted); margin: 0 0 1rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.doc__title { font-size: clamp(1.85rem, 4vw, var(--t-4)); letter-spacing: -.03em; line-height: 1.12; margin: 0 0 1rem; font-weight: 700; }
.doc__lede { font-size: var(--t-1); color: var(--muted); margin: 0 0 1.5rem; }
.doc__meta {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  font-family: var(--font-mono); font-size: var(--t--2); color: var(--muted);
  padding-bottom: 1.8rem; border-bottom: 1px solid var(--line);
}

.prose > * + * { margin-top: 1.15rem; }
.prose h2 { font-size: var(--t-2); letter-spacing: -.02em; font-weight: 650; margin-top: 2.6rem; }
.prose h3 { font-size: var(--t-1); font-weight: 640; margin-top: 1.8rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .35rem; }
.prose strong { font-weight: 650; }
.prose code {
  font-family: var(--font-mono); font-size: .85em; background: var(--panel);
  border: 1px solid var(--line-soft); padding: .1em .38em; border-radius: 5px;
}
.prose pre {
  font-family: var(--font-mono); font-size: var(--t--1); line-height: 1.55;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 1rem 1.15rem; overflow-x: auto;
}
.prose pre code { background: none; border: 0; padding: 0; }
.prose blockquote { margin-inline: 0; padding: .2rem 0 .2rem 1.1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose a { text-underline-offset: .16em; }
.prose a:hover { color: var(--accent-ink); }

.callout {
  background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--r-md); padding: 1rem 1.2rem; font-size: var(--t--1); line-height: 1.6;
}
.callout strong { color: var(--accent-ink); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
table { border-collapse: collapse; width: 100%; font-size: var(--t--1); }
th, td { text-align: left; padding: .7rem 1rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
thead th { background: var(--panel); font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

.term { text-decoration: none; border-bottom: 1px dashed var(--muted); }
.term:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3.5rem; }
.pager a { border: 1px solid var(--line); border-radius: var(--r-md); padding: .9rem 1.1rem; text-decoration: none; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--muted); font-size: var(--t--2); letter-spacing: .06em; text-transform: uppercase; }
.pager b { font-weight: 600; }
.pager .is-next { text-align: right; }
@media (max-width: 40rem) { .pager { grid-template-columns: 1fr; } .pager .is-next { text-align: left; } }

/* ---------- Дверь ---------- */

.door { min-height: 100svh; display: grid; place-content: center; text-align: center; padding: 1.5rem; }
.door__brand { display: inline-flex; align-items: center; gap: .6rem; font-size: var(--t-2); font-weight: 680; letter-spacing: -.02em; margin-bottom: 1.2rem; }
.door p { color: var(--muted); margin: .2rem auto; max-width: 40ch; }
.door__pick { display: flex; gap: .7rem; justify-content: center; margin-top: 2.2rem; }

/* ---------- Подвал ---------- */

.footer { border-top: 1px solid var(--line); }
.footer__in {
  max-width: var(--shell); margin-inline: auto; padding: 2rem 1.5rem 3rem;
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between;
  font-size: var(--t--1); color: var(--muted);
}
.footer a { text-decoration: none; }
.footer a:hover { color: var(--ink); }

@media (prefers-reduced-motion: no-preference) {
  .card, .entry, .btn, .pager a, .spine__link::before, .pipeline__link::before { transition: 160ms ease; }
}
