/* ═══════════════════════════════════════════════
   СТАТЬИ — /articles/
   Подключается после css/styles.css и живёт на его токенах.
   Разметку генерирует tools/build-articles.mjs.
   ═══════════════════════════════════════════════ */

:root {
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Consolas, monospace;
  --prose: #c8c8d0;   /* основной текст статьи: светлее --gray, длинное чтение */
  --nav-h: 68px;
}
@media (max-width: 768px) { :root { --nav-h: 62px; } }

.a-body { background: var(--black); }
/* Лигатуры моноширинных шрифтов рисуют != как ≠ и <- как ←: в учебном коде
   читатель должен видеть ровно то, что будет печатать. */
.a-body code, .a-tag, .a-cover-code, .a-code-head { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
/* styles.css режет горизонтальный вылет через overflow-x: hidden на html и body —
   это превращает body в контейнер прокрутки и ломает sticky у оглавления.
   clip режет так же, но контейнером прокрутки не становится. Файл грузится
   только на страницах статей, поэтому html здесь трогать безопасно. */
html, .a-body { overflow-x: clip; }

/* ── Полоса прогресса чтения ── */
.a-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 1100; pointer-events: none;
}
.a-progress span {
  display: block; height: 100%; width: 100%;
  background: var(--yellow);
  box-shadow: 0 0 12px rgba(245,197,24,0.5);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ── Каркас ── */
.a-main {
  position: relative;
  /* clip, а не hidden: hidden делает блок контейнером прокрутки, и sticky
     у оглавления перестаёт держаться за окно */
  overflow: clip;
  padding: calc(var(--nav-h) + 40px) 0 96px;
}
.a-main::before {
  content: '';
  position: absolute; top: -200px; left: 50%;
  width: 1200px; height: 700px; transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(245,197,24,0.07) 0%, transparent 60%);
  pointer-events: none;
}
.a-watermark {
  position: absolute; top: 120px; right: -60px;
  width: 420px; opacity: 0.03; transform: rotate(-8deg);
  pointer-events: none;
}
.a-main .container { position: relative; }

nav .nav-links a[aria-current="page"] { color: var(--white); font-weight: 600; }

.a-draft {
  margin-bottom: 24px; padding: 14px 18px;
  border: 1px dashed rgba(232,163,61,0.5); border-radius: var(--radius-sm);
  background: var(--warn-glow); color: var(--white); font-size: var(--t-small);
}

/* ── Шапка ── */
.a-crumbs {
  display: flex; flex-wrap: wrap; gap: 8px; list-style: none;
  font-size: var(--t-meta); color: var(--gray-dim); margin-bottom: 20px;
}
.a-crumbs li + li::before { content: '/'; margin-right: 8px; }
.a-crumbs a { color: var(--gray); }
.a-crumbs a:hover { color: var(--white); }
.a-crumbs [aria-current] {
  max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.a-head h1 {
  font-size: clamp(2rem, 3.8vw, 3rem);
  font-weight: 800; letter-spacing: var(--ls-head); line-height: 1.15;
  margin: 0 0 32px; max-width: 900px; text-wrap: balance;
}
.a-head--focus { max-width: 820px; margin: 24px auto 40px; text-align: center; }
.a-head--focus .a-crumbs { justify-content: center; }
.a-head--focus h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 900;
  letter-spacing: var(--ls-display); line-height: 1.08; margin: 0 auto 20px;
}
.a-kicker {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 20px;
  font-size: var(--t-label); font-weight: 700; letter-spacing: 3px;
  text-transform: uppercase; color: var(--yellow);
}
.a-kicker::before, .a-kicker::after { content: ''; width: 24px; height: 1px; background: var(--yellow); }
.a-head-lead {
  font-size: 1.1rem; line-height: 1.7; color: var(--gray);
  margin: 0 auto 28px; max-width: 640px; text-wrap: pretty;
}
.a-head--index { margin-bottom: 48px; }
.a-head--index h1 { margin-bottom: 16px; }
.a-head--index .a-head-lead { margin: 0; max-width: 620px; }

.a-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px;
  font-size: var(--t-meta); color: var(--gray-dim); margin-bottom: 16px;
}
.a-head--focus .a-meta { justify-content: center; }
.a-author { display: flex; align-items: center; gap: 10px; color: var(--white); font-weight: 600; }
.a-author img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; object-position: top; }
.a-num { font-variant-numeric: tabular-nums; }

/* ── Теги ── */
.a-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.a-article > .a-tags { margin-bottom: 28px; }
.a-tag {
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.4; color: var(--gray);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; padding: 4px 8px;
}
.a-tag--level { color: var(--yellow); background: rgba(245,197,24,0.08); border-color: rgba(245,197,24,0.2); }
.a-tag--draft { color: var(--warn); border-color: rgba(232,163,61,0.4); }

/* ── Обложки ── */
.a-cover {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); background: var(--dark-alt);
}
.a-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.a-cover--classic { aspect-ratio: 16 / 8; border-radius: var(--radius); margin-bottom: 40px; }
.a-cover--wide { aspect-ratio: 21 / 8; border-radius: var(--radius-lg); margin-bottom: 56px; }

.a-cover--auto {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 8%;
  background:
    radial-gradient(ellipse at 80% 50%, rgba(245,197,24,0.14) 0%, transparent 55%),
    linear-gradient(135deg, var(--surface) 0%, var(--dark-alt) 100%);
}
.a-cover--auto::before {
  /* сетка «миллиметровки» — тот же приём, что у кода: инженерная, не декоративная */
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}
.a-cover--auto img {
  position: relative; width: auto; height: 62%; max-width: 40%; object-fit: contain;
  filter: drop-shadow(0 12px 32px rgba(0,0,0,0.45));
}
.a-cover-code {
  position: relative; font-family: var(--mono); color: var(--gray-dim);
  font-size: clamp(0.8rem, 2vw, 1.15rem);
}

/* ── Раскладка статьи ── */
.a-layout { display: flex; gap: 56px; align-items: flex-start; }
.a-article { flex: 1 1 560px; min-width: 0; max-width: 720px; }
.a-layout--focus { justify-content: center; }

.a-side { flex: 0 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 20px; align-self: stretch; }
.a-side--focus { flex: 0 0 200px; position: sticky; top: calc(var(--nav-h) + 32px); align-self: flex-start; gap: 24px; }
.a-side-sticky { position: sticky; top: calc(var(--nav-h) + 24px); display: flex; flex-direction: column; gap: 20px; }
.a-side-label {
  font-size: var(--t-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--gray-dim); margin-bottom: 12px;
}
.a-side-label--gold { color: var(--yellow); margin-bottom: 10px; }

.a-offer {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid rgba(245,197,24,0.18);
  border-radius: var(--radius); padding: 28px;
}
.a-offer::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245,197,24,0.5), transparent);
}
.a-offer::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center top, rgba(245,197,24,0.08) 0%, transparent 60%);
}
.a-offer > * { position: relative; z-index: 1; }
.a-offer > img { display: block; width: 60px; height: 60px; object-fit: contain; margin-bottom: 16px; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3)); }
.a-offer-title { font-size: 1.3rem; font-weight: 800; letter-spacing: var(--ls-title); line-height: 1.25; margin-bottom: 14px; text-wrap: balance; }
.a-offer .btn { display: block; text-align: center; margin-top: 22px; }

/* Оглавление */
.a-toc ol { list-style: none; display: flex; flex-direction: column; }
.a-toc a {
  display: flex; align-items: flex-start; gap: 10px; padding: 6px 0;
  font-size: var(--t-small); line-height: 1.4; font-weight: 500; color: var(--gray-dim);
}
.a-toc a::before {
  content: ''; flex: 0 0 6px; height: 6px; margin-top: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.12); transition: background 0.2s;
}
.a-toc a:hover, .a-toc a.is-active { color: var(--white); }
.a-toc a.is-active::before { background: var(--yellow); }
.a-toc--box { background: var(--dark-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; }
.a-side--focus .a-tags { padding-top: 24px; border-top: 1px solid var(--border); }
.a-side--focus .a-tag { font-size: 0.7rem; }

/* Оглавление на телефоне — сворачиваемое, над текстом */
.a-toc-m {
  display: none; margin: 0 0 32px;
  background: var(--dark-alt); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.a-toc-m summary {
  cursor: pointer; padding: 14px 18px; list-style: none;
  font-size: var(--t-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--gray);
}
.a-toc-m summary::-webkit-details-marker { display: none; }
.a-toc-m summary::after { content: '+'; float: right; color: var(--yellow); font-size: 1rem; line-height: 1; }
.a-toc-m[open] summary::after { content: '−'; }
.a-toc-m ol { padding: 0 18px 14px 38px; }
.a-toc-m li { padding: 5px 0; font-size: var(--t-small); }
.a-toc-m a { color: var(--gray); }

/* Карточки Telegram и консультации */
.a-tg {
  display: flex; align-items: center; gap: 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin: 32px 0; color: var(--white);
  transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.a-tg img { flex: 0 0 56px; width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3)); }
.a-tg-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.a-tg-txt b { font-size: 1.02rem; font-weight: 700; }
.a-tg-txt span { font-size: var(--t-small); line-height: 1.6; color: var(--gray); }
.a-tg-go { flex: 0 0 auto; font-size: var(--t-small); font-weight: 700; color: var(--yellow); }
.a-tg--sm { gap: 14px; padding: 18px 20px; margin: 0; background: var(--dark-alt); }
.a-tg--sm img { flex-basis: 44px; width: 44px; height: 44px; }
.a-tg--sm .a-tg-txt b { font-size: 0.92rem; }
.a-tg--sm .a-tg-txt span { font-size: var(--t-meta); line-height: 1.5; }
@media (hover: hover) {
  .a-tg:hover {
    color: var(--white); border-color: var(--border-hover); transform: translateY(-3px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 40px var(--yellow-glow-sm);
  }
}

.a-cta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 24px;
  margin-top: 48px; padding: 28px;
  background: linear-gradient(135deg, rgba(245,197,24,0.12), rgba(245,197,24,0.03));
  border: 1px solid rgba(245,197,24,0.2); border-radius: var(--radius);
}
.a-cta img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3)); }
.a-cta-txt { flex: 1 1 280px; display: flex; flex-direction: column; gap: 6px; }
.a-cta-txt b { font-size: 1.2rem; font-weight: 800; letter-spacing: var(--ls-title); }
.a-cta-txt span { font-size: var(--t-small); line-height: 1.6; color: var(--gray); }
.a-cta .btn { white-space: nowrap; }

/* ── Текст статьи ── */
.a-prose { color: var(--gray); font-size: 1.02rem; line-height: 1.8; }
.a-prose > * { margin: 0 0 20px; }
.a-prose p { text-wrap: pretty; }
.a-prose .a-lede { font-size: 1.1rem; color: var(--prose); }
.a-prose h2 {
  font-size: 1.6rem; font-weight: 800; letter-spacing: var(--ls-head); line-height: 1.25;
  color: var(--white); margin: 48px 0 16px; scroll-margin-top: calc(var(--nav-h) + 28px);
}
.a-prose h3 {
  font-size: 1.2rem; font-weight: 700; letter-spacing: var(--ls-title); line-height: 1.35;
  color: var(--white); margin: 32px 0 10px; scroll-margin-top: calc(var(--nav-h) + 28px);
}
.a-prose h2 + h3 { margin-top: 20px; }
.a-prose strong { color: var(--white); font-weight: 600; }
.a-prose a { text-decoration: underline; text-decoration-color: rgba(245,197,24,0.4); text-underline-offset: 3px; }
.a-prose a:hover { text-decoration-color: currentColor; }
.a-prose hr { border: 0; height: 1px; background: var(--border); margin: 40px 0; }
.a-prose code {
  /* в styles.css code жёлтый и не переносится — для текста статьи это слишком громко */
  font-family: var(--mono); font-size: 0.86em; color: var(--white);
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px; padding: 1px 6px; white-space: normal; overflow-wrap: anywhere;
}
.a-prose blockquote {
  position: relative; padding-left: 28px; color: var(--prose); font-style: italic;
}
.a-prose blockquote::before {
  content: '«'; position: absolute; left: 0; top: -0.1em;
  font-size: 2em; line-height: 1; font-style: normal; font-weight: 800; color: var(--yellow);
}
.a-prose blockquote > :last-child, .a-note > :last-child { margin-bottom: 0; }

/* Плашка «Важно» */
.a-note {
  position: relative; overflow: hidden; margin-bottom: 24px;
  background: var(--surface); border: 1px solid rgba(245,197,24,0.18);
  border-radius: 12px; padding: 20px 22px;
  font-size: 0.96rem; line-height: 1.7; color: var(--prose);
}
.a-note::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at top left, rgba(245,197,24,0.06) 0%, transparent 60%);
}
.a-note > * { position: relative; margin: 0 0 12px; }
.a-note-label {
  font-size: var(--t-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--yellow); margin-bottom: 8px;
}

/* Списки */
.a-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.a-list li { display: flex; gap: 14px; }
.a-list li::before {
  content: ''; flex: 0 0 6px; height: 6px; margin-top: 0.72em;
  border-radius: 50%; background: var(--yellow);
}
.a-list--sm { gap: 10px; }
.a-list--sm li { gap: 10px; font-size: var(--t-small); line-height: 1.5; color: var(--gray); }
.a-list--sm li::before { flex-basis: 5px; height: 5px; margin-top: 0.6em; }

.a-steps {
  list-style: none; counter-reset: step;
  display: flex; flex-direction: column; gap: 1px; overflow: hidden;
  background: var(--border); border: 1px solid var(--border); border-radius: 12px;
}
.a-steps li {
  counter-increment: step;
  display: flex; align-items: flex-start; gap: 16px;
  background: var(--black); padding: 16px 20px;
  font-size: 0.96rem; line-height: 1.6; color: var(--prose);
}
.a-steps li::before {
  content: counter(step);
  flex: 0 0 28px; height: 28px; margin-top: -2px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--yellow); color: var(--black);
  font-weight: 900; font-size: 0.8rem; font-variant-numeric: tabular-nums;
}

/* Таблицы */
.a-table { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.a-table table { width: 100%; min-width: 480px; border-collapse: collapse; }
.a-table th {
  background: var(--dark-alt); padding: 12px 16px; text-align: left;
  font-size: var(--t-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--gray-dim);
}
.a-table td {
  padding: 14px 16px; vertical-align: top; border-top: 1px solid var(--border);
  font-size: 0.9rem; line-height: 1.55; color: var(--gray);
}
.a-table td:first-child { color: var(--white); }
.a-table td code { border: 0; background: none; padding: 0; }

/* Картинки */
.a-figure img { display: block; width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.a-figure figcaption { margin-top: 10px; font-size: var(--t-meta); color: var(--gray-dim); text-align: center; }

/* Код */
.a-code { background: var(--dark); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 24px; }
.a-code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px 8px 16px; background: var(--dark-alt); border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.76rem; color: var(--gray-dim);
}
.a-copy {
  font: 600 0.74rem/1 'Inter', sans-serif; color: var(--gray);
  background: transparent; border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  padding: 7px 10px; min-height: 30px; cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.a-copy:hover, .a-copy.is-done { color: var(--black); background: var(--yellow); border-color: var(--yellow); }
.a-code pre { margin: 0; padding: 16px 0; overflow-x: auto; }
.a-code pre code {
  all: unset; display: block; counter-reset: ln;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.7;
  color: #d4d4dc; white-space: pre; tab-size: 4;
}
.a-code .ln { display: inline-block; min-width: 100%; padding-right: 16px; }
.a-code .ln::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 44px; padding-right: 16px; text-align: right;
  color: #45454f; user-select: none; font-variant-numeric: tabular-nums;
}
.tk-k { color: var(--yellow); }
.tk-s { color: var(--ok); }
.tk-c { color: #767682; font-style: italic; }
.tk-t { color: #7cb4ff; }
.tk-b { color: #c3a6ff; }
.tk-n { color: var(--warn); }
.tk-p { color: #8a8a94; }

/* ── Карточки статей ── */
.a-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.a-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--white);
  transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.a-card[hidden] { display: none; }
@media (hover: hover) {
  .a-card:hover {
    color: var(--white); transform: translateY(-6px); border-color: var(--border-hover);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 40px var(--yellow-glow-sm);
  }
}
.a-card-cover { aspect-ratio: 16 / 9; border: 0; border-bottom: 1px solid var(--border); }
.a-card-cover.a-cover--auto { padding: 0 10%; }
.a-card-cover .a-cover-code { font-size: var(--t-meta); }
.a-card-body { display: flex; flex-direction: column; gap: 12px; padding: 24px; flex: 1; }
.a-card .a-tag { font-size: 0.68rem; padding: 3px 7px; }
.a-card-title { font-size: 1.12rem; font-weight: 700; letter-spacing: var(--ls-title); line-height: 1.35; margin: 0; text-wrap: balance; }
.a-card-excerpt { font-size: var(--t-small); line-height: 1.6; color: var(--gray); flex: 1; }
.a-card-meta {
  display: flex; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: var(--t-meta); color: var(--gray-dim); font-variant-numeric: tabular-nums;
}
.a-empty { color: var(--gray); }

/* Похожие статьи */
.a-related { background: var(--black); padding: var(--section-py) 0; }
.a-related[hidden] { display: none; }
.a-section-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 24px; margin-bottom: 40px; }
.a-section-head h2 { margin: 0; }
.a-all { font-size: var(--t-small); font-weight: 600; }

/* Секции, взятые с главной, идут на фоне через одну */
.a-body #services { background: var(--dark-alt); }

/* ── Адаптив ── */
@media (max-width: 1080px) {
  .a-layout { flex-direction: column; align-items: stretch; gap: 40px; }
  .a-article { max-width: 720px; flex-basis: auto; }
  .a-layout--focus .a-article { margin: 0 auto; }
  .a-side { flex-basis: auto; max-width: 720px; }
  .a-side--focus, .a-toc--box { display: none; }
  .a-side-sticky { position: static; }
  .a-toc-m { display: block; }
}
@media (max-width: 768px) {
  .a-main { padding-bottom: 72px; }
  .a-watermark { display: none; }
  .a-head h1 { margin-bottom: 24px; }
  .a-head--focus { margin-top: 8px; }
  .a-cover--classic, .a-cover--wide { aspect-ratio: 16 / 9; margin-bottom: 32px; border-radius: 12px; }
  .a-prose h2 { font-size: 1.4rem; margin-top: 40px; }
  .a-tg { flex-wrap: wrap; gap: 14px; padding: 18px; }
  .a-tg:not(.a-tg--sm) .a-tg-go { flex-basis: 100%; }
  .a-cta { padding: 22px; }
  .a-cta .btn { width: 100%; text-align: center; }
  .a-code pre code { font-size: 0.78rem; }
  .a-code .ln::before { width: 34px; padding-right: 12px; }
  .a-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .a-card, .a-tg { transition: none; }
}
