/* main.css — общие стили для всех страниц.
   Onest — текст, Playfair Display — заголовки. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
img, video { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; }

/* accessibility baseline */
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---- design tokens (light + dark) ---- */
:root {
  --c-bg: #F5F5F7;
  --c-surface: #FFFFFF;
  --c-line: #EAEAEF;
  --bg: var(--c-bg);
  --surface: var(--c-surface);
  --bg-soft: #ECECEF;
  --glass: rgba(255,255,255,0.62);
  --blur: saturate(180%) blur(20px);
  --line: var(--c-line);
  --line-2: rgba(29,29,31,0.06);
  --ink: #1D1D1F;
  --ink-2: rgba(29,29,31,0.62);
  --ink-3: rgba(29,29,31,0.42);
  --black: #1D1D1F;
  --red: #E0271D;
  --red-ink: #C21F16;
  --radius: 14px;
  --radius-card: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(0,0,0,0.03), 0 4px 14px rgba(0,0,0,0.04);
  --shadow-card: var(--shadow);
  --shadow-hover: 0 1px 3px rgba(0,0,0,0.04), 0 10px 26px rgba(0,0,0,0.07);
  --ease: cubic-bezier(0.2,0,0,1);
  --display: 'Playfair Display', Georgia, 'Times New Roman', serif;
}
html[data-theme="dark"] {
  --c-bg: #17181B;
  --c-surface: #1E2024;
  --c-line: #2B2D32;
  --bg-soft: #26282D;
  --glass: rgba(30,32,36,0.72);
  --line-2: rgba(255,255,255,0.08);
  --ink: #F2F2F4;
  --ink-2: rgba(242,242,244,0.64);
  --ink-3: rgba(242,242,244,0.42);
  --black: #3A3C42;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 14px rgba(0,0,0,0.35);
  --shadow-hover: 0 1px 3px rgba(0,0,0,0.35), 0 10px 26px rgba(0,0,0,0.42);
}

body { font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; letter-spacing: -0.011em; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 18px; }

/* ---- header (popup trigger + theme toggle live here) ---- */
.site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.site-header__inner { display: flex; align-items: center; gap: 12px; max-width: 1160px; margin: 0 auto; padding: 13px 18px; }
.logo { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; margin-right: auto; min-width: 0; }
.logo-mark { width: 42px; height: 42px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--red); font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: -0.04em; }
.logo-brand { display: flex; flex-direction: column; min-width: 0; }
.logo-name { font-weight: 600; font-size: 17px; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-sub { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.site-header__actions { display: flex; align-items: center; gap: 2px; flex: none; }
.popup-toggle, .theme-toggle { width: 44px; height: 44px; border: none; background: transparent; border-radius: var(--radius-pill); color: var(--ink-2); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.14s var(--ease), color 0.14s var(--ease); }
.popup-toggle:hover, .theme-toggle:hover { background: var(--bg-soft); color: var(--ink); }
.popup-toggle svg, .theme-toggle svg { width: 21px; height: 21px; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: flex; }

/* ---- header popup (markup lives inside <header>) ---- */
.popup { position: fixed; inset: 0; z-index: 60; display: none; }
.popup.is-open { display: block; }
.popup__scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.28); opacity: 0; transition: opacity 0.18s var(--ease); }
.popup.is-open .popup__scrim { opacity: 1; }
/* top/right проставляет main.js — привязка к кнопке; тут запасные значения */
.popup__panel { position: absolute; top: 64px; right: 12px; width: 244px; max-width: calc(100vw - 24px); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-hover); padding: 8px; transform-origin: top right; transform: scale(0.96) translateY(-6px); opacity: 0; transition: transform 0.16s var(--ease), opacity 0.16s var(--ease); }
.popup.is-open .popup__panel { transform: none; opacity: 1; }
.popup__link { display: block; padding: 12px 13px; border-radius: 11px; text-decoration: none; color: var(--ink); font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; transition: background 0.12s var(--ease); }
.popup__link:hover { background: var(--bg-soft); }

/* ---- page shell (header / main / footer grid) ---- */
.page-shell { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; min-height: 100vh; }
.page-main { padding: 24px 0 56px; }

/* ---- сетка страницы: центр + два рейла. Одна колонка на мобиле,
   центр+правый с 1024px, все три с 1180px ---- */
.page-columns { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "center" "left" "right"; gap: 22px; align-items: start; }
.page-center { grid-area: center; min-width: 0; }
/* колонка статьи — на своей карточке-поверхности */
.page-center--article { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 24px 28px 20px; }
.rail { min-width: 0; }
.rail--left { grid-area: left; }
.rail--right { grid-area: right; }
.rail:empty, .page-center:empty { min-height: 320px; border: 1px dashed var(--line); border-radius: var(--radius-card); }
@media (max-width: 1023.98px) { .rail:empty { display: none; } }
@media (min-width: 1024px) {
  .page-columns { grid-template-columns: minmax(0, 1fr) 280px; grid-template-areas: "center right"; }
  .rail { position: sticky; top: 78px; }
  .rail--left { display: none; }
}
@media (min-width: 1180px) {
  .page-columns { grid-template-columns: 240px minmax(0, 1fr) 280px; grid-template-areas: "left center right"; }
  .rail--left { display: block; }
}

/* ---- article left rail: news headlines nav ---- */
.rail-nav { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 16px; }
.rail-nav__title { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }
.rail-nav__link { display: block; padding: 9px 0; font-size: 13.5px; font-weight: 600; line-height: 1.35; text-decoration: none; color: var(--ink); transition: color 0.12s var(--ease); }
.rail-nav__link:hover, .rail-nav__link.active { color: var(--red); }
.rail-nav__link + .rail-nav__link { border-top: 1px solid var(--line-2); }

.site-footer { border-top: 1px solid var(--line); margin-top: auto; background: var(--surface); }
.site-footer__inner { max-width: 1160px; margin: 0 auto; padding: 28px 18px calc(30px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.site-footer__brand { display: flex; align-items: center; gap: 9px; }
.site-footer__mark { width: 30px; height: 30px; flex: none; color: var(--red); font-weight: 800; font-size: 26px; line-height: 1; letter-spacing: -0.04em; display: flex; align-items: center; justify-content: center; }
.site-footer__name { font-size: 14px; font-weight: 600; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 9px 18px; }
.site-footer__links a { font-size: 13px; font-weight: 600; color: var(--ink-2); text-decoration: none; transition: color 0.12s var(--ease); }
.site-footer__links a:hover { color: var(--red); }
.site-footer__links a.site-footer__contact { color: var(--red); }
.site-footer__legal { font-size: 12px; color: var(--ink-3); line-height: 1.55; margin: 0; }

/* ---- homepage: сводка города — компактная строка виджетов ---- */
.brief-stats { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.bs { flex: 1 1 90px; min-width: 0; background: var(--surface); border: 1px solid var(--line-2); border-radius: 13px; box-shadow: var(--shadow-card); padding: 9px 13px 10px; display: flex; flex-direction: column; gap: 3px; transition: box-shadow 0.16s var(--ease), transform 0.16s var(--ease); }
@media (hover: hover) { .bs:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.08); transform: translateY(-1px); } }
.bs-k { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-v { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.bs-v em { font-style: normal; font-size: 10px; font-weight: 700; }
.bs-v .up { color: #1E8E3E; }
.bs-v .dn { color: var(--red); }

/* ---- tags — wrap into multiple rows (no horizontal scroll) ---- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.tag { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 40px; text-decoration: none; background: var(--surface); border: 1px solid var(--line-2); color: var(--ink); font-size: 13.5px; font-weight: 600; padding: 0 8px 0 14px; border-radius: var(--radius-pill); white-space: nowrap; transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.16s var(--ease); }
.tag:not(.is-active):hover { border-color: rgba(29,29,31,0.14); box-shadow: 0 2px 8px rgba(0,0,0,0.08); transform: translateY(-1px); }
.tag__count { font-size: 11.5px; font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; background: var(--bg-soft); padding: 2px 8px; border-radius: var(--radius-pill); line-height: 1; }
.tag.is-active { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 4px 14px rgba(224,39,29,0.3); }
.tag.is-active .tag__count { color: #fff; background: rgba(255,255,255,0.22); }

/* ---- сегмент-переключатель разделов (Apple-стиль) ---- */
.seg { position: relative; display: flex; width: 100%; margin-bottom: 22px; background: var(--bg-soft); border-radius: var(--radius-pill); padding: 4px; box-shadow: inset 0 0 0 1px rgba(29,29,31,0.05); }
.seg-thumb { position: absolute; top: 4px; left: 0; width: 0; height: calc(100% - 8px); background: var(--surface); border-radius: var(--radius-pill); box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 1px rgba(0,0,0,0.04); }
.seg-btn { position: relative; z-index: 1; flex: 1 1 0; text-align: center; border: none; background: none; font-family: inherit; font-size: 15px; font-weight: 600; letter-spacing: -0.012em; color: var(--ink-2); padding: 11px 20px; border-radius: var(--radius-pill); cursor: pointer; white-space: nowrap; transition: color 0.22s var(--ease); }
.seg-btn:hover:not(.is-active) { color: var(--ink); }
.seg-btn.is-active { color: var(--ink); }
.seg-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
@media (max-width: 460px) { .seg-btn { padding: 11px 12px; font-size: 13px; } }

/* ---- section heading ---- */
.section-head { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 16px; }

/* ---- editorial feed cards ---- */
.feed { display: flex; flex-direction: column; gap: 18px; margin-bottom: 26px; scroll-margin-top: 78px; }
.post { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-card); transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease); }
@media (hover: hover) { .post:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); } }

/* медиа карточки — 1 / 2 / 3 фото и карусель */
.post-media { position: relative; background: var(--bg-soft); }
.post-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-media--1 { aspect-ratio: 16 / 9; }
.post-media--2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; aspect-ratio: 16 / 9; }
.post-media--3 { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; aspect-ratio: 16 / 9; }
.post-media--3 > :first-child { grid-row: 1 / 3; }
/* лёгкое затемнение снизу, чтобы пилюля-рубрика читалась */
.post-media::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.26), transparent 46%); pointer-events: none; }
.post-media--carousel { padding: 12px 12px 14px; background: var(--surface); }
.post-media--carousel::after { display: none; }
/* одно видео как медиа поста — оживляет video.js */
.post-media--video { aspect-ratio: 16 / 9; background: #000; }
.post-media--video::after { display: none; }
.post-media--video .video-wrap, .post-media--video video { width: 100%; height: 100%; }
.post-media--video video { object-fit: cover; display: block; }
.post-rubric { position: absolute; left: 14px; bottom: 14px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.94); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: #1D1D1F; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; padding: 6px 12px 6px 9px; border-radius: var(--radius-pill); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.post-rubric .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex: none; }
/* цвет точки по рубрике */
.post-rubric .dot--transport { background: #3B5BDB; }
.post-rubric .dot--city { background: #16A34A; }
.post-rubric .dot--incident { background: #E0271D; }
.post-rubric .dot--money { background: #E0AE22; }
.post-rubric .dot--tech { background: #7E57C2; }
.post-rubric .dot--photo { background: #EC4899; }

/* body */
.post-in { padding: 16px 18px 15px; }
.post-title { font-size: 20px; font-weight: 600; line-height: 1.28; letter-spacing: -0.022em; color: var(--ink); text-wrap: pretty; margin: 0; }
.post-title a { color: inherit; text-decoration: none; transition: color 0.12s var(--ease); }
.post:hover .post-title a { color: var(--red); }
.post-body { font-size: 15px; line-height: 1.55; color: var(--ink-2); margin-top: 8px; text-wrap: pretty; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-foot { display: flex; align-items: center; gap: 10px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line-2); }
.post-mark { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; line-height: 1; letter-spacing: -0.04em; }
.post-byname { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-time { font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.post-actions { display: flex; align-items: center; gap: 2px; flex: none; margin-left: auto; }
.share-btn { width: 38px; height: 38px; border: none; background: transparent; cursor: pointer; border-radius: var(--radius-pill); color: var(--ink-3); display: flex; align-items: center; justify-content: center; text-decoration: none; transition: background 0.12s var(--ease), color 0.12s var(--ease); }
.share-btn:hover { background: var(--bg-soft); color: var(--ink); }
.share-btn svg { width: 18px; height: 18px; }
.share-btn .max-mark { width: 16px; height: 16px; border: 1.6px solid currentColor; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; line-height: 1; }
.share-btn.is-copied { color: #1E8E3E; }

/* hero (первая карточка) — serif-заголовок с 640px */
.post.hero .post-media--1 { aspect-ratio: 3 / 2; }
.post.hero .post-title { font-size: 21px; font-weight: 700; line-height: 1.3; letter-spacing: -0.02em; }
.post.hero .post-body { font-size: 16px; }
@media (min-width: 640px) {
  .post.hero .post-title { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.14; letter-spacing: -0.01em; }
}

/* ---- pagination ---- */
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.pagination__btn { min-width: 40px; height: 40px; padding: 0 8px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-pill); font-size: 14px; font-weight: 700; color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums; transition: border-color 0.13s var(--ease), transform 0.13s var(--ease); }
.pagination__btn:not(:disabled):not(.is-active):hover { border-color: var(--ink-3); transform: translateY(-1px); }
.pagination__btn.is-active { background: var(--red); border-color: var(--red); color: #fff; }
.pagination__btn:disabled { opacity: 0.4; cursor: default; }

/* ---- article: breadcrumbs / title ---- */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 16px; }
.breadcrumbs a { text-decoration: none; color: var(--red); }
.breadcrumbs a:hover { text-decoration: underline; }
.article-title { max-width: 720px; font-family: var(--display); font-size: 29px; font-weight: 700; line-height: 1.16; letter-spacing: -0.015em; color: var(--ink); margin: 0 0 10px; text-wrap: balance; }
.article-meta { max-width: 720px; font-size: 13px; font-weight: 600; color: var(--ink-3); margin-bottom: 22px; }

/* ---- типографика статьи через контейнер (в контенте нет классов).
   Первый абзац — лид: темнее и чуть крупнее ---- */
.article-content { max-width: 720px; }
.article-content p { font-size: 17px; line-height: 1.72; color: var(--ink-2); margin: 0 0 16px; }
.article-content > p:first-of-type { font-size: 18px; line-height: 1.6; color: var(--ink); font-weight: 500; }
.article-content h2 { font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; color: var(--ink); margin: 34px 0 14px; }
.article-content h3 { font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--ink); margin: 26px 0 12px; }
.article-content ul, .article-content ol { margin: 0 0 16px; padding-left: 22px; color: var(--ink-2); font-size: 17px; line-height: 1.65; }
.article-content li { margin-bottom: 7px; }
.article-content blockquote { margin: 26px 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--red); font-family: var(--display); font-size: 21px; line-height: 1.4; font-weight: 600; color: var(--ink); }
.article-content blockquote p { font-family: inherit; font-size: inherit; line-height: inherit; font-weight: inherit; color: inherit; margin: 0; }
.article-content img { width: 100%; border-radius: var(--radius-md); margin: 22px 0; }
.article-content video { width: 100%; border-radius: var(--radius-md); margin: 22px 0; background: #000; }
.article-content a { color: var(--red); font-weight: 600; text-decoration-color: rgba(224,39,29,0.4); }

/* ---- служебный блок после первого абзаца: галерея статьи ---- */
.service-slot { max-width: 720px; margin: 22px 0; }

/* ---- article: read-next block ---- */
.news-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 38px; padding-top: 24px; border-top: 1px solid var(--line-2); max-width: 720px; }
.news-switch__link { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; padding: 15px 17px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-md); box-shadow: var(--shadow-card); transition: box-shadow 0.18s var(--ease), transform 0.18s var(--ease); }
.news-switch__link:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.news-switch__link.is-next { text-align: right; align-items: flex-end; }
.news-switch__dir { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--red); }
.news-switch__title { font-size: 14px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 480px) { .news-switch { grid-template-columns: 1fr; } .news-switch__link.is-next { text-align: left; align-items: flex-start; } }

/* ---- кнопка-постер видео (её вешает video.js) ---- */
.video-wrap { position: relative; }
.video-play-btn { position: absolute; inset: 0; width: 100%; height: 100%; border: none; background: rgba(0,0,0,0.22); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.video-play-btn__circle { width: 56px; height: 56px; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; display: flex; align-items: center; justify-content: center; }
.video-play-btn__circle svg { width: 24px; height: 24px; }

@media (max-width: 560px) {
  .article-title { font-size: 25px; }
  .article-content p, .article-content ul, .article-content ol { font-size: 16.5px; }
  .article-content > p:first-of-type { font-size: 17.5px; }
  .page-center--article { padding: 22px 18px; }
  .section-head { font-size: 20px; }
}
