/* ═══════════════════════════════════════════════════════════════════════
   LIDERIK · блог (/blog и /blog/<slug>)

   Страницы собирает сервис блога на сервере (/opt/blogapi/liderik) из
   шаблонов blog-templates/*.template.html этого репозитория. SEO-агент
   присылает только текст статьи — шапка, подвал, карточки и оформление наши.

   Правила — брендбук Liderik v6: прямые углы; заливка вместо обводки;
   кобальт только на действиях, цифрах, статусах и пикселях; ритм секций
   белая — paper — белая; заголовки секций по центру; пиксельная рамка —
   клетки в полях серой секции, плотнее к краям. Цифры — Newsreader
   (у него нет кириллицы, русский текст идёт Inter, как в самом брендбуке).
   Подключается ПОСЛЕ style.css: .bar, .foot, .btn, .lead, .wrap — оттуда.
   ═══════════════════════════════════════════════════════════════════════ */

:root { --serif: "Newsreader", Inter, Georgia, serif; }

/* ── Пиксельная рамка серой секции ───────────────────────────────────── */
.bpx {
  position: absolute;
  display: grid;
  grid-template-columns: repeat(4, 34px);
  grid-auto-rows: 34px;
  gap: 4px;
  pointer-events: none;
}
.bpx i { display: block; }
.bpx .w { background: var(--white); }
.bpx .t { background: var(--accent-tint); }
.bpx .a { background: var(--accent); }
.bpx-tr { right: -4px; top: -4px; }
.bpx-bl { left: -4px; bottom: -4px; }
.bpx-tl { left: -4px; top: -4px; }
.bpx-br { right: -4px; bottom: -4px; }
@media (max-width: 760px) { .bpx { display: none; } }

/* ── Шапка страницы (список и статья) ───────────────────────────────── */
.bh {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  padding: clamp(56px, 7vw, 112px) 0 clamp(56px, 6vw, 96px);
  text-align: center;
}
.bh .wrap { position: relative; }
.blog-crumbs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; margin: 0 0 28px; font-size: 14px; color: var(--ink-2); }
.blog-crumbs a { color: var(--ink-2); }
.blog-crumbs a:hover { color: var(--accent); }
.blog-crumbs span[aria-hidden] { opacity: .45; }
.bh h1 {
  margin: 0 auto;
  max-width: 15em;
  font-size: clamp(40px, 5.6vw, 80px);
  font-weight: 300;
  line-height: 1.0;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.bh .lead { margin: 28px auto 0; max-width: 36em; text-wrap: pretty; }
.bh-intro { margin: 28px auto 0; max-width: 46em; display: grid; gap: 10px; }
.bh-intro p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--ink-2); }

/* Мета статьи: подпись автора (её переносит сюда blog-ui.js из тела статьи)
   и дата. Без скрипта остаётся одна дата. */
.bh-meta {
  margin-top: 36px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px 28px;
  font-size: 14px;
  color: var(--ink-2);
}
.bh-meta .sb-byline { margin: 0; text-align: left; }
.bh-meta time { display: flex; align-items: center; gap: 28px; }
.bh-meta .sb-byline + time::before { content: ""; width: 1px; height: 32px; background: var(--line); }

/* ── Список статей ───────────────────────────────────────────────────── */
.blog-list { padding: clamp(56px, 7vw, 112px) 0; }

/* Карточки собирает общий для трёх сайтов blog.js со встроенными стилями
   чужой вёрстки (скругления, рамки, Unbounded). Код общий — не трогаем, а
   перекрываем: встроенный стиль бьётся только через !important. Разметка
   карточки та, что даёт blog.js: h3 > a, p, div с датой. */
.post-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  counter-reset: post;
}
@media (min-width: 640px) { .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .post-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.post-grid > article {
  position: relative;
  counter-increment: post;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: var(--paper) !important;
  transition: background var(--t-hover) var(--ease);
}
/* Кадр сверху — язык обложек базы знаний: светлая ступень кобальта,
   номер антиквой и пиксельное пятно в углу. Подпись — под кадром. */
.post-grid > article::before {
  content: counter(post, decimal-leading-zero);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  aspect-ratio: 16 / 9;
  padding: 0 24px 6px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--serif);
  font-size: clamp(88px, 8vw, 128px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.04em;
  transition: background var(--t-hover) var(--ease);
}
/* Пятно — клетки по 14 px с шагом 16: фоны-квадраты одного псевдоэлемента.
   Четыре рисунка по кругу, чтобы соседние карточки не повторялись. */
.post-grid > article::after {
  content: "";
  position: absolute;
  left: 24px;
  top: 24px;
  width: 78px;
  height: 62px;
  pointer-events: none;
  --c: var(--accent);
  --l: #b9bfff;
  background:
    linear-gradient(var(--c), var(--c)) 0 0 / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 16px 0 / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 16px 16px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 32px 16px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 0 32px / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 48px 32px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 32px 48px / 14px 14px no-repeat;
}
.post-grid > article:nth-child(4n+2)::after {
  background:
    linear-gradient(var(--l), var(--l)) 0 0 / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 32px 0 / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 0 16px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 16px 16px / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 48px 16px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 16px 32px / 14px 14px no-repeat;
}
.post-grid > article:nth-child(4n+3)::after {
  background:
    linear-gradient(var(--c), var(--c)) 16px 0 / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 0 16px / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 32px 16px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 48px 32px / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 16px 32px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 0 48px / 14px 14px no-repeat;
}
.post-grid > article:nth-child(4n+4)::after {
  background:
    linear-gradient(var(--l), var(--l)) 16px 0 / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 48px 0 / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 0 16px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 32px 16px / 14px 14px no-repeat,
    linear-gradient(var(--c), var(--c)) 32px 32px / 14px 14px no-repeat,
    linear-gradient(var(--l), var(--l)) 16px 48px / 14px 14px no-repeat;
}
.post-grid > article:hover { background: #ececf1 !important; }
.post-grid > article:hover::before { background: #dfe2ff; }

.post-grid > article h3 {
  margin: 24px 28px 12px !important;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif !important;
  font-size: 22px !important;
  font-weight: 500 !important;
  line-height: 1.22 !important;
  letter-spacing: -0.02em !important;
  text-wrap: balance;
}
.post-grid > article h3 a {
  color: var(--ink) !important;
  transition: color var(--t-hover) var(--ease);
}
/* Вся карточка — ссылка: растянутый ::after у заголовка. */
.post-grid > article h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.post-grid > article:hover h3 a { color: var(--accent) !important; }
.post-grid > article h3 a:focus-visible { outline: none; }
.post-grid > article:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.post-grid > article p {
  margin: 0 28px 24px !important;
  font-size: 15px !important;
  line-height: 1.6 !important;
  color: var(--ink-2) !important;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-grid > article > div {
  margin: auto 28px 0 !important;
  padding: 0 0 26px !important;
  border-top: 0 !important;
  font-size: 13.5px !important;
  color: var(--ink-2) !important;
}
/* Время чтения на карточке считает blog.js (160 слов в минуту), а в статье
   его пишет агент по-своему — цифры расходились. На карточке только дата. */
.post-grid > article > div span:not(:first-child) { display: none; }

/* Свежая статья — во всю ширину двух колонок: кадр слева, подпись справа. */
@media (min-width: 1040px) {
  .post-grid > article:first-child {
    grid-column: span 2;
    display: grid !important;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
  }
  .post-grid > article:first-child::before { grid-row: 1 / span 3; aspect-ratio: auto; min-height: 340px; font-size: 176px; }
  .post-grid > article:first-child h3 { grid-column: 2; margin: 40px 40px 16px !important; font-size: 32px !important; line-height: 1.12 !important; }
  .post-grid > article:first-child p { grid-column: 2; margin: 0 40px 24px !important; font-size: 16px !important; -webkit-line-clamp: 5; }
  .post-grid > article:first-child > div { grid-column: 2; margin: auto 40px 0 !important; padding-bottom: 36px !important; align-self: end; }
}

/* ── Призыв внизу (общий для списка и статьи) ───────────────────────── */
.bcta { position: relative; overflow: hidden; background: var(--paper); padding: clamp(72px, 9vw, 128px) 0; text-align: center; }
.bcta .wrap { position: relative; }
.bcta h2 { margin: 0 auto; max-width: 14em; font-size: clamp(32px, 4vw, 56px); font-weight: 400; line-height: 1.04; letter-spacing: -0.03em; text-wrap: balance; }
.bcta .lead { margin: 22px auto 0; max-width: 32em; }
.bcta-act { margin-top: 36px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

/* ── Статья ──────────────────────────────────────────────────────────── */
.ab {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 64px;
  padding-top: clamp(48px, 6vw, 88px);
  padding-bottom: clamp(72px, 9vw, 128px);
}
@media (min-width: 1100px) {
  .ab { grid-template-columns: minmax(0, 760px) 300px; justify-content: space-between; }
}
.ab-main { min-width: 0; }

/* align-self: start — иначе колонка растянута на высоту статьи и липнуть
   ей некуда: sticky двигает элемент только внутри его ячейки. */
.ab-side { display: grid; gap: 16px; align-content: start; align-self: start; }
@media (min-width: 1100px) { .ab-side { position: sticky; top: calc(var(--bar-h) + 32px); } }
.ab-card { background: var(--accent-tint); padding: 28px; }
.ab-card h3 { font-size: 21px; font-weight: 500; line-height: 1.2; letter-spacing: -0.02em; }
.ab-card p { margin: 10px 0 22px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.ab-card .btn { width: 100%; }

/* Тело статьи присылает агент со своим <style>: скругления, градиент,
   тени, капслок, зебра в таблицах — всё мимо брендбука. Перекрываем через
   .ab-main: селектор длиннее агентского и выигрывает, хотя его <style>
   стоит в документе позже. Текст и разметку статьи не трогаем. */
.ab-main .sb-article { max-width: none; font-size: 18px; line-height: 1.65; letter-spacing: -0.005em; color: var(--ink); }
.ab-main .sb-article p { margin: 0 0 1.2em; }
.ab-main .sb-article h2 {
  margin: 2.1em 0 .65em;
  font-size: clamp(28px, 2.7vw, 38px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--ink);
  scroll-margin-top: calc(var(--bar-h) + 24px);
}
.ab-main .sb-article h2:first-of-type { margin-top: .2em; }
.ab-main .sb-article h3 {
  margin: 1.7em 0 .5em;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
  scroll-margin-top: calc(var(--bar-h) + 24px);
}
.ab-main .sb-article a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ab-main .sb-article a:hover { color: var(--accent-hover); }
.ab-main .sb-article ul,
.ab-main .sb-article ol { padding-left: 1.3em; }
.ab-main .sb-article ul { list-style: square; }
.ab-main .sb-article li::marker { color: var(--accent); }
.ab-main .sb-article ol > li::marker { font-family: var(--serif); font-weight: 500; }
.ab-main .sb-article strong { font-weight: 600; }

.ab-main .sb-article img,
.ab-main .sb-cover img,
.ab-main .sb-figure img { border-radius: 0; box-shadow: none; }
.ab-main .sb-cover figcaption,
.ab-main .sb-figure figcaption { text-align: left; font-size: 14px; color: var(--ink-2); }

/* Подпись автора в теле — пока скрипт не перенёс её в шапку. */
.ab-main .sb-byline,
.bh-meta .sb-byline { display: flex; align-items: center; gap: 12px; }
.sb-byline .sb-ava,
.ab-main .sb-ava { border-radius: 0; background: var(--accent); }
.bh-meta .sb-ava { width: 40px; height: 40px; flex-basis: 40px; font-size: 14px; }
.bh-meta .sb-bl-name { font-size: 15px; font-weight: 600; color: var(--ink); }
.bh-meta .sb-bl-role { font-size: 13.5px; color: var(--ink-2); }

/* Оглавление в теле (узкий экран или без скрипта) — плоскость paper. */
.ab-main .sb-toc { background: var(--paper); border: 0; border-radius: 0; padding: 26px 30px; margin: 0 0 40px; }
.sb-toc .sb-toc-t { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 14px; }
.sb-toc ol { font-size: 15.5px; }
.sb-toc li::before { font-family: var(--serif); color: var(--accent) !important; font-size: 1.05em; }
/* .ab-main впереди: правило ссылок статьи (.ab-main .sb-article a) иначе
   красит оглавление кобальтом с подчёркиванием. */
.sb-toc a,
.ab-main .sb-toc a { text-decoration: none; color: var(--ink); opacity: 1; }
.sb-toc a:hover,
.ab-main .sb-toc a:hover { color: var(--accent); }

/* Оглавление в боковой колонке (переносит blog-ui.js): без плашки,
   текущий раздел — кобальтом и полосой слева (кобальт на статусе). */
.ab-side .sb-toc { background: transparent; border: 0; border-radius: 0; padding: 0; margin: 0; }
.ab-side .sb-toc ol { font-size: 14.5px; }
.ab-side .sb-toc li { margin: 0; padding: 7px 0 7px 14px; box-shadow: inset 2px 0 0 var(--line); grid-template-columns: 2.1em 1fr; }
.ab-side .sb-toc li.is-on { box-shadow: inset 2px 0 0 var(--accent); }
.ab-side .sb-toc li.is-on a { color: var(--accent); }
.ab-side .sb-toc a { color: var(--ink-2); line-height: 1.35; }

/* «Коротко»: плоскость категории A, подпись — ярлык на маркере
   (Inter 600, строчными, белая заливка с наклоном −0.6°). */
.ab-main .sb-answer { background: var(--tone-a); border: 0; border-radius: 0; padding: 26px 30px; margin: 0 0 36px; }
.ab-main .sb-answer-t {
  display: inline-block;
  margin: 0 0 14px;
  padding: 5px 11px;
  background: var(--white);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: lowercase;
  transform: rotate(-0.6deg);
}
.ab-main .sb-answer p { font-size: 18px; line-height: 1.6; }
.ab-main .sb-callout { background: var(--tone-b); border: 0; border-radius: 0; padding: 22px 26px; margin: 28px 0; }

/* Цитата: светлый гротеск крупно и кобальтовая кавычка антиквой. */
.ab-main .sb-quote {
  margin: 40px 0;
  border: 0;
  padding: 0;
  font-size: clamp(22px, 2vw, 27px);
  font-style: normal;
  font-weight: 300;
  line-height: 1.35;
  letter-spacing: -0.02em;
  opacity: 1;
}
.ab-main .sb-quote::before {
  content: "\201C";
  display: block;
  height: .5em;
  margin-bottom: .25em;
  font-family: var(--serif);
  font-size: 3.2em;
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
}

/* Таблица: линии тоном заливки, без зебры и вертикальных линеек. */
.ab-main .sb-article table { font-size: 15.5px; }
.ab-main .sb-article th,
.ab-main .sb-article td { border: 0; border-bottom: 1px solid var(--line); padding: 12px 16px 12px 0; }
.ab-main .sb-article th { background: transparent; font-size: 13.5px; font-weight: 600; color: var(--ink-2); border-bottom-color: var(--ink); }
.ab-main .sb-article tbody tr:nth-child(even) { background: transparent; }

/* FAQ: плоскости paper, квадрат раскрытия с обводкой ink — одно из трёх
   мест, где брендбук оставляет обводку. */
.ab-main .sb-faq { background: var(--paper); border: 0; border-radius: 0; margin: 8px 0; }
.ab-main .sb-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  font-weight: 500;
  list-style: none;
}
.ab-main .sb-faq summary::-webkit-details-marker { display: none; }
.ab-main .sb-faq summary::after {
  content: "+";
  flex: 0 0 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}
.ab-main .sb-faq[open] summary::after { content: "\2212"; }
.ab-main .sb-faq summary:hover { color: var(--accent); }
.ab-main .sb-faq .a { padding: 0 22px 10px; color: var(--ink-2); }

/* «Читайте также» — плитками, как карточки списка. */
.ab-main .sb-related { border: 0; margin-top: 56px; padding-top: 0; }
.ab-main .sb-related h2 { margin: 0 0 18px; text-transform: none; letter-spacing: -0.02em; font-size: 26px; font-weight: 400; color: var(--ink); }
.ab-main .sb-related ul { list-style: none; padding: 0; display: grid; gap: 8px; }
@media (min-width: 640px) { .ab-main .sb-related ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ab-main .sb-related li { margin: 0; }
.ab-main .sb-related li::marker { content: none; }
.ab-main .sb-related a {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  height: 100%;
  padding: 18px 20px;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
  text-decoration: none;
  transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.ab-main .sb-related a::after { content: "\2192"; color: var(--accent); }
.ab-main .sb-related a:hover { background: var(--accent-tint); color: var(--ink); text-decoration: none; }

.ab-main .sb-author { border: 0; margin-top: 48px; padding: 24px 26px; background: var(--paper); }
.ab-main .sb-src a { color: var(--accent); }

@media (max-width: 760px) {
  .ab-main .sb-article { font-size: 17px; }
  .ab-main .sb-toc, .ab-main .sb-answer { padding: 20px 20px; }
  .bh-meta .sb-byline + time::before { display: none; }
}
