/* Блог: /blog/ (лента, рубрики) и /blog/<статья>/. Страницы собирает сервер (server/app/blog.py).
   Ориентир — kinzhal.media: тёмная лента, крупные карточки со срезанным углом, статья в одной панели. */

.page--blog { background: var(--ink-900); }
.blog-wrap { width: min(1200px, 100% - 2 * var(--gutter)); }

/* ---------- шапка ленты ---------- */
.blog-hero { padding: calc(var(--header-h) + 56px) 0 28px; background: radial-gradient(55% 120% at 90% 0%, rgba(var(--acc-rgb), .16), transparent 70%), var(--ink-900); }
.blog-hero__title { font-family: var(--f-display); font-weight: var(--fw-display); font-size: clamp(44px, 7vw, 96px); line-height: .98; letter-spacing: var(--ls-display, -0.04em); }
.blog-hero__lead { margin-top: 18px; max-width: 60ch; font-size: clamp(16px, 1.3vw, 18px); line-height: 1.55; color: var(--fg-2); }
.blog-cats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }
.blog-cats a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 16px; border-radius: var(--r-pill);
  background: var(--ink-700); color: #E6E2D8; text-decoration: none; font-size: 15px; font-weight: 500; transition: background-color .2s ease, color .2s ease;
}
.blog-cats a span { font-size: 13px; color: var(--fg-3); }
.blog-cats a:hover { background: var(--ink-600); }
.blog-cats a[aria-current="page"] { background: var(--acc-fill); color: #fff; }
.blog-cats a[aria-current="page"] span { color: rgba(255, 255, 255, .75); }

/* ---------- лента ---------- */
.blog-list { padding: 24px 0 clamp(64px, 8vw, 112px); }
.blog-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.blog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.blog-empty { grid-column: 1 / -1; padding: 48px 0; font-size: 18px; color: var(--fg-2); }
.blog-empty a { color: var(--acc-text); }

.card { min-width: 0; }
.card__link {
  display: flex; flex-direction: column; height: 100%; overflow: hidden; text-decoration: none; color: #F2EFE6;
  background: var(--ink-800); border: 1px solid rgba(255, 255, 255, .06); border-radius: 20px 20px 4px 20px;
  transition: transform .25s var(--ease), border-color .25s ease, background-color .25s ease;
}
.card__media { aspect-ratio: 16 / 9; overflow: hidden; background: var(--ink-700); }
.card__img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease); }
.card__body { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: 20px 22px 22px; }
.card__title { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: clamp(20px, 1.7vw, 24px); line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
.card__lead { font-size: 15.5px; line-height: 1.45; color: var(--fg-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 8px; font-size: 14px; color: var(--fg-3); }
.card__time { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.card--big .card__title { font-size: clamp(24px, 2.4vw, 32px); }
.card--big .card__body { padding: 24px 26px 26px; }
/* без обложки: цветная плашка (как короткие заметки у Кинжала) */
.card--noimg .card__link { background: var(--ink-700); }
.card--noimg .card__title { font-size: clamp(22px, 2vw, 28px); }
.blog-grid .card--noimg:nth-child(3n+1) .card__link { background: var(--acc-fill); border-color: transparent; }
.blog-grid .card--noimg:nth-child(3n+1) .card__lead,
.blog-grid .card--noimg:nth-child(3n+1) .card__meta { color: rgba(255, 255, 255, .8); }
.blog-grid .card--noimg:nth-child(3n+1) .chip { background: rgba(255, 255, 255, .16); color: #fff; }
.blog-grid .card--noimg:nth-child(3n+2) .card__link { background: transparent; border-color: rgba(var(--acc-rgb), .55); }
.blog-top .card--noimg .card__link { background: var(--acc-fill); border-color: transparent; }
.blog-top .card--noimg .card__title { font-size: clamp(28px, 3.2vw, 44px); line-height: 1.06; }
.blog-top .card--noimg .card__lead, .blog-top .card--noimg .card__meta { color: rgba(255, 255, 255, .82); }
.blog-top .card--noimg .chip { background: rgba(255, 255, 255, .16); color: #fff; }
.blog-top .card--noimg .chip i { color: #fff; }
.card--noimg .card__body { padding-top: 26px; }
@media (hover: hover) and (pointer: fine) {
  html:not(.lite) .card__link:hover { transform: translateY(-4px); border-color: rgba(var(--acc-rgb), .6); }
  html:not(.lite) .card__link:hover .card__img { transform: scale(1.03); }
}
.card__link:focus-visible { outline: 2px solid var(--acc-text); outline-offset: 3px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--ink-600); color: #D9D5CA; font-size: 13px; font-weight: 500; line-height: 1.2; text-decoration: none; white-space: nowrap;
}
.chip i { font-size: 15px; color: var(--acc-text); }
a.chip:hover { background: var(--acc-fill); color: #fff; }
a.chip:hover i { color: #fff; }

.feed-cta {
  grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; gap: 8px 32px; align-items: center;
  padding: clamp(24px, 3vw, 36px); border-radius: var(--r-panel); background: var(--acc-fill); color: #fff;
}
.feed-cta__title { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: clamp(22px, 2.2vw, 30px); line-height: 1.15; letter-spacing: -0.02em; }
.feed-cta p:not(.feed-cta__title) { color: rgba(255, 255, 255, .85); font-size: 16px; }
.feed-cta .btn { grid-column: 2; grid-row: 1 / span 2; }

.blog-pager { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 40px; }
.blog-pager a { display: grid; place-items: center; min-width: 46px; height: 46px; padding: 0 12px; border-radius: var(--r-pill); background: var(--ink-700); color: #E6E2D8; text-decoration: none; font-weight: 500; }
.blog-pager a[aria-current="page"] { background: var(--acc-fill); color: #fff; }

/* ---------- статья ---------- */
.read-progress { position: fixed; z-index: 60; left: 0; right: 0; top: 0; height: 3px; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--acc-fill); transform-origin: 0 50%; transform: scaleX(0); }
.preview-bar { position: sticky; top: 0; z-index: 70; padding: 10px 20px; background: #F4B740; color: #14130F; font-weight: 600; text-align: center; font-size: 14px; }

.post-page { padding: calc(var(--header-h) + 40px) 0 clamp(48px, 6vw, 88px); }
.post-page .crumbs { margin-bottom: 16px; }
.post { background: var(--ink-800); border-radius: 32px; padding: clamp(14px, 2.4vw, 28px); }
/* шапка как у Т—Ж: рубрика, заголовок, лид, автор — сверху вниз по линии текста, затем обложка 16:9 целиком */
.post-head { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; padding: clamp(18px, 3vw, 40px) clamp(4px, 2.5vw, 44px) 0; }
.post-head__title { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: clamp(32px, 4.2vw, 56px); line-height: 1.06; letter-spacing: -0.03em; text-wrap: balance; max-width: 24ch; }
.post-head__lead { font-size: clamp(18px, 1.5vw, 21px); line-height: 1.5; color: var(--fg-2); max-width: 720px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; }
/* обложка не шире колонки текста: видна целиком, но не отодвигает текст на второй экран */
.post-cover { margin: clamp(24px, 3vw, 36px) 0 0; padding-inline: clamp(4px, 2.5vw, 44px); }
.post-cover__img { display: block; width: 100%; max-width: 720px; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 18px; background: var(--ink-700); }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 7px 16px; border-radius: var(--r-pill); background: var(--ink-700); font-size: 14.5px; color: #D9D5CA; }
.pill i { font-size: 16px; color: var(--acc-text); }
.pill--author { padding-left: 6px; }
.pill__ava { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--acc-fill); color: #fff; font-weight: 600; font-size: 13px; }

.post-grid { display: grid; grid-template-columns: minmax(0, 720px) minmax(0, 1fr); gap: 56px; padding: clamp(24px, 3.5vw, 48px) clamp(4px, 2.5vw, 44px) clamp(16px, 2vw, 24px); }
.post-side { position: relative; }
.post-side > * { position: sticky; top: calc(var(--header-h) + 32px); }
.post-side .share { position: static; margin-top: 20px; }
.post-toc { padding: 20px 22px; border-radius: 20px; background: var(--ink-700); }
.post-toc__title { font-size: 13px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 12px; }
.post-toc ol { display: grid; gap: 4px; counter-reset: t; }
.post-toc li { counter-increment: t; }
.post-toc a { display: grid; grid-template-columns: 24px 1fr; padding: 6px 0; font-size: 15px; line-height: 1.35; color: var(--fg-2); text-decoration: none; }
.post-toc a::before { content: counter(t); color: var(--fg-3); font-variant-numeric: tabular-nums; }
.post-toc a:hover, .post-toc a.is-current { color: #fff; }
.post-toc a.is-current::before { color: var(--acc-text); }
.post-toc-m { display: none; }

/* типографика текста */
.post-body { font-size: 19px; line-height: 1.62; color: #E6E2D8; min-width: 0; }
.post-body > * + * { margin-top: 22px; }
.post-body h2 { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: clamp(26px, 2.3vw, 32px); line-height: 1.15; letter-spacing: -0.02em; color: #fff; margin-top: 56px; scroll-margin-top: calc(var(--header-h) + 24px); text-wrap: balance; }
.post-body h3 { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: clamp(21px, 1.8vw, 24px); line-height: 1.2; color: #fff; margin-top: 40px; scroll-margin-top: calc(var(--header-h) + 24px); }
.post-body h4 { font-size: 19px; font-weight: 600; color: #fff; margin-top: 32px; }
.post-body h2 + *, .post-body h3 + *, .post-body h4 + * { margin-top: 14px; }
.post-body a { color: var(--acc-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.post-body a:hover { color: #fff; }
.post-body b, .post-body strong { color: #fff; }
.post-body mark { background: rgba(var(--acc-rgb), .35); color: #fff; padding: 0 3px; border-radius: 4px; }
.post-body code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .86em; padding: 2px 6px; border-radius: 6px; background: var(--ink-600); }
.post-body ul, .post-body ol { display: grid; gap: 10px; padding-left: 0; }
.post-body ul > li { position: relative; padding-left: 28px; }
.post-body ul > li::before { content: ""; position: absolute; left: 4px; top: .62em; width: 9px; height: 9px; border-radius: 50%; background: var(--acc-fill); }
.post-body ol { counter-reset: li; }
.post-body ol > li { position: relative; padding-left: 36px; counter-increment: li; }
.post-body ol > li::before { content: counter(li) "."; position: absolute; left: 0; top: 0; font-weight: 600; color: var(--acc-text); font-variant-numeric: tabular-nums; }
.post-body li > ul, .post-body li > ol { margin-top: 10px; }
.post-body ul.post-check > li::before { display: none; }
.post-check__box { position: absolute; left: 0; top: .3em; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--acc-text); }
.post-check__box.is-on { background: var(--acc-fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3L15 7' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat; border-color: transparent; }

.post-fig { margin: 36px 0; }
.post-fig img { width: 100%; height: auto; border-radius: 18px; }
.post-fig--border img { border: 1px solid rgba(255, 255, 255, .14); }
.post-fig--bg { padding: clamp(16px, 3vw, 32px); border-radius: 22px; background: var(--ink-700); }
.post-fig--bg img { width: auto; max-width: min(100%, 520px); margin: 0 auto; border-radius: 10px; }
.post-fig--wide { margin-inline: calc(-1 * clamp(0px, 2.5vw, 44px)); }
.post-fig figcaption { margin-top: 10px; font-size: 14.5px; line-height: 1.45; color: var(--fg-3); }

/* цитата: крупная синяя кавычка, текст акцидентным шрифтом, подпись с тире */
.post-quote { position: relative; margin: 40px 0; padding: 4px 0 4px 64px; }
.post-quote::before { content: "\201C"; position: absolute; left: 0; top: -6px; font: 800 76px/1 var(--f-display); color: var(--acc-text); }
.post-quote p { font-family: var(--f-display); font-weight: 500; font-size: clamp(21px, 1.9vw, 25px); line-height: 1.4; letter-spacing: -.01em; color: #fff; }
.post-quote cite { display: block; margin-top: 14px; font-style: normal; font-size: 15px; color: var(--fg-3); }
.post-quote cite::before { content: "\2014\00a0"; }
/* врезка «Важно»: спокойная подсветка, иконка, текст обычного цвета — не путать с рекламным баннером */
.post-note { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 16px; align-items: baseline; margin: 32px 0; padding: 22px 26px; border-radius: 18px; background: rgba(var(--acc-rgb), .1); border: 1px solid rgba(var(--acc-rgb), .3); }
/* значок «!» стоит в сетке на одной базовой линии с первой строкой — визуально по её центру */
.post-note::before { content: "!"; grid-column: 1; grid-row: 1 / span 9; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--acc-fill); color: #fff; font: 800 16px/1 var(--f-display); }
.post-note > * { grid-column: 2; }
.post-note p { color: var(--fg); font-size: .95em; line-height: 1.6; }
.post-note p + p { margin-top: 8px; }
.post-note__title + p { margin-top: 4px; }
.post-note__title { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: 18px; line-height: 1.3; }
.post-note a { color: var(--acc-text); }
.post-hr { margin: 48px 0; border: 0; height: 1px; background: rgba(255, 255, 255, .12); }
.post-code { margin: 28px 0; padding: 20px 22px; overflow-x: auto; border-radius: 16px; background: var(--ink-950); font-size: 15px; line-height: 1.55; }
.post-code code { padding: 0; background: none; font-size: inherit; }

.post-table { margin: 32px 0; overflow-x: auto; border-radius: 16px; background: var(--ink-700); -webkit-overflow-scrolling: touch; }
.post-table:focus-visible { outline: 2px solid var(--acc-text); }
.post-table table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 16px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.post-table th, .post-table td { padding: 12px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.post-table thead th { font-weight: 600; color: #fff; background: var(--ink-600); }
.post-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, .025); }
.post-table tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) {
  .post-table th:first-child, .post-table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--ink-700); box-shadow: 1px 0 0 rgba(255, 255, 255, .08); }
  .post-table thead th:first-child { background: var(--ink-600); }
}

.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 40px; }
.tag { padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid rgba(255, 255, 255, .14); font-size: 14px; color: var(--fg-2); }
.post-cta { margin-top: 40px; padding: clamp(22px, 3vw, 32px); border-radius: 22px 22px 6px 22px; background: var(--acc-fill); color: #fff; }
.post-cta__title { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: clamp(22px, 2vw, 28px); line-height: 1.15; }
.post-cta p:not(.post-cta__title) { margin: 10px 0 18px; font-size: 16.5px; line-height: 1.5; color: rgba(255, 255, 255, .88); }
.post-share-end { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 28px; padding-top: 22px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 15px; color: var(--fg-2); }
.share { display: flex; gap: 8px; }
.share__btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ink-700); color: #E6E2D8; font-size: 19px; text-decoration: none; transition: background-color .2s ease; }
.share__btn:hover { background: var(--acc-fill); color: #fff; }
.share__vk { font-size: 13px; font-weight: 700; letter-spacing: .02em; }

.related { padding: 0 0 clamp(56px, 7vw, 96px); }
.related__title { font-family: var(--f-display); font-weight: var(--fw-display-2); font-size: clamp(28px, 3vw, 40px); letter-spacing: -0.02em; margin-bottom: 24px; }

@media (max-width: 1199px) {
  .post-grid { grid-template-columns: minmax(0, 1fr); gap: 0; max-width: 760px; margin: 0 auto; }
  .post-head, .post-cover { max-width: 760px; margin-inline: auto; }
  .post-side { display: none; }
  .post-toc-m { display: block; margin-bottom: 28px; border-radius: 18px; background: var(--ink-700); }
  .post-toc-m summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 12px 20px; cursor: pointer; font-weight: 600; color: #fff; list-style: none; }
  .post-toc-m summary::-webkit-details-marker { display: none; }
  .post-toc-m summary span { font-weight: 400; font-size: 14px; color: var(--fg-3); }
  .post-toc-m ol { display: grid; gap: 2px; padding: 0 20px 16px; counter-reset: t; }
  .post-toc-m li { padding-left: 0; counter-increment: t; }
  .post-toc-m li::before { display: none; }
  .post-toc-m a { display: block; padding: 7px 0; font-size: 16px; color: var(--fg-2); text-decoration: none; }
  .post-toc-m a::before { content: counter(t) ". "; color: var(--fg-3); }
}
@media (max-width: 900px) {
  .blog-top { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); scrollbar-width: none; }
  .blog-top::-webkit-scrollbar { display: none; }
  .blog-top .card { flex: 0 0 86%; scroll-snap-align: start; }
  .blog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feed-cta { grid-template-columns: 1fr; }
  .feed-cta .btn { grid-column: auto; grid-row: auto; justify-self: start; margin-top: 8px; }
}
@media (max-width: 640px) {
  .blog-grid { grid-template-columns: 1fr; }
  .blog-cats { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scrollbar-width: none; }
  .blog-cats a { flex: none; }
  .post { border-radius: 24px; padding: 10px; }
  .post-head { gap: 14px; padding: 14px 8px 0; }
  .post-cover { margin-top: 22px; padding-inline: 8px; }
  .post-cover__img { border-radius: 16px; }
  .post-grid { padding: 22px 8px 12px; }
  .post-body { font-size: 17px; line-height: 1.6; }
  .post-body > * + * { margin-top: 18px; }
  .post-body h2 { margin-top: 44px; }
  .post-fig--wide { margin-inline: 0; }
  .post-note { padding: 18px; grid-template-columns: 26px minmax(0, 1fr); column-gap: 12px; }
  .post-note::before { width: 26px; height: 26px; }
  .post-quote { padding-left: 48px; }
  .post-quote::before { font-size: 60px; }
}
