/* ============================================================
   Блог: стили раздела (страница блога, статья, карточки).
   Подключается ТОЛЬКО на страницах блога (см. functions.php —
   erma_blog_styles), поэтому не влияет на остальной сайт.
   ============================================================ */

/* Header блога — в нормальном потоке, без наложения на контент. */
body.blog .site-header:not(.is-scrolled),
body.single-post .site-header:not(.is-scrolled),
body.archive .site-header:not(.is-scrolled) {
  position: relative;
  background: var(--bg);
}
body.blog .site-header:not(.is-scrolled) .header-inner,
body.single-post .site-header:not(.is-scrolled) .header-inner,
body.archive .site-header:not(.is-scrolled) .header-inner {
  padding-top: 0;
}

/* Контейнер контента блога. */
body.blog .site-main,
body.single-post .site-main,
body.archive .site-main {
  width: min(var(--container), calc(100% - 64px));
  margin: 0 auto;
  padding: 60px 0 80px;
}

/* Читаемая область отдельной статьи: максимум 1000px.
   H1, метаданные, изображение и весь контент статьи ограничены этим
   контейнером; на мобильных ширина остаётся резиновой (100% - отступы). */
body.single-post .site-main {
  max-width: 1000px;
}

/* Заголовки статей: Graphik Semibold 600 (семейство заголовков блога).
   Размеры H1/H2 заданы отдельно адаптивной шкалой ниже. */
body.blog .site-main .entry-title,
body.single-post .site-main .entry-title {
  margin: 0 0 24px;
  font-family: "Graphik", sans-serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--heading);
}
body.blog .site-main .entry-title a {
  color: var(--heading);
  text-decoration: none;
  transition: color .2s;
}
body.blog .site-main .entry-title a:hover { color: var(--red); }

/* Metadata статьи. */
body.blog .site-main .entry-meta,
body.single-post .site-main .entry-meta,
body.blog .site-main .posted-on,
body.single-post .site-main .posted-on {
  color: var(--muted);
  font-size: 14px;
}

/* Основной блочный текст статьи: Charter Regular 400 / 21px / line-height 1.5 /
   #000. Применяется только к контенту блога (blog.css загружается только на
   страницах блога), поэтому в header/footer/menu/кнопки шрифт не наследуется. */
body.blog .site-main .entry-content,
body.single-post .site-main .entry-content,
body.archive .site-main .entry-content {
  color: #000;
  font-family: "Charter", serif;
  font-weight: 400;
  font-size: 21px;
  line-height: 1.5;
}

/* <strong>: остаётся Charter Regular 400 — браузер не должен утолщать
   начертание из-за отсутствующего bold-файла. */
body.blog .site-main .entry-content strong,
body.single-post .site-main .entry-content strong,
body.archive .site-main .entry-content strong {
  font-family: "Charter", serif;
  font-weight: 600;
  background: #fffc00;
}

/* Заголовки внутри статьи: Graphik Regular (не наследуют шрифт основного
   текста). Размеры H2 заданы адаптивной шкалой ниже; H3+ используют
   существующую типографическую шкалу сайта. */
body.blog .site-main .entry-content h1,
body.blog .site-main .entry-content h2,
body.blog .site-main .entry-content h3,
body.blog .site-main .entry-content h4,
body.blog .site-main .entry-content h5,
body.blog .site-main .entry-content h6,
body.single-post .site-main .entry-content h1,
body.single-post .site-main .entry-content h2,
body.single-post .site-main .entry-content h3,
body.single-post .site-main .entry-content h4,
body.single-post .site-main .entry-content h5,
body.single-post .site-main .entry-content h6,
body.archive .site-main .entry-content h1,
body.archive .site-main .entry-content h2,
body.archive .site-main .entry-content h3,
body.archive .site-main .entry-content h4,
body.archive .site-main .entry-content h5,
body.archive .site-main .entry-content h6 {
  font-family: "Graphik", sans-serif;
  font-weight: 600;
}

/* Адаптивная шкала размеров заголовков блога.
   H1 (отдельная статья): 45px на больших экранах. */
body.single-post .site-main .entry-title,
body.single-post .site-main .entry-content h1 {
  font-size: clamp(38px, calc(38px + (100vw - 1200px) * 7 / 700), 45px);
}

/* H2 (секции статьи и заголовки на списках блога): 32px на больших экранах. */
body.blog .site-main .entry-title,
body.archive .site-main .entry-title,
body.blog .site-main .entry-content h2,
body.single-post .site-main .entry-content h2,
body.archive .site-main .entry-content h2 {
  font-size: clamp(28px, calc(28px + (100vw - 1200px) * 4 / 700), 32px);
}

@media (max-width: 1200px) {
  body.single-post .site-main .entry-title,
  body.single-post .site-main .entry-content h1 {
    font-size: clamp(32px, calc(32px + (100vw - 960px) * 6 / 240), 38px);
  }
  body.blog .site-main .entry-title,
  body.archive .site-main .entry-title,
  body.blog .site-main .entry-content h2,
  body.single-post .site-main .entry-content h2,
  body.archive .site-main .entry-content h2 {
    font-size: clamp(25px, calc(25px + (100vw - 960px) * 3 / 240), 28px);
  }
}
@media (max-width: 960px) {
  body.single-post .site-main .entry-title,
  body.single-post .site-main .entry-content h1 {
    font-size: clamp(28px, calc(28px + (100vw - 640px) * 4 / 320), 32px);
  }
  body.blog .site-main .entry-title,
  body.archive .site-main .entry-title,
  body.blog .site-main .entry-content h2,
  body.single-post .site-main .entry-content h2,
  body.archive .site-main .entry-content h2 {
    font-size: clamp(23px, calc(23px + (100vw - 640px) * 2 / 320), 25px);
  }
}
@media (max-width: 640px) {
  body.single-post .site-main .entry-title,
  body.single-post .site-main .entry-content h1 {
    font-size: clamp(25px, calc(25px + (100vw - 480px) * 3 / 160), 28px);
  }
  body.blog .site-main .entry-title,
  body.archive .site-main .entry-title,
  body.blog .site-main .entry-content h2,
  body.single-post .site-main .entry-content h2,
  body.archive .site-main .entry-content h2 {
    font-size: clamp(22px, calc(22px + (100vw - 480px) * 1 / 160), 23px);
  }
}
@media (max-width: 480px) {
  body.single-post .site-main .entry-title,
  body.single-post .site-main .entry-content h1 {
    font-size: clamp(24px, calc(24px + (100vw - 320px) * 1 / 160), 25px);
  }
  body.blog .site-main .entry-title,
  body.archive .site-main .entry-title,
  body.blog .site-main .entry-content h2,
  body.single-post .site-main .entry-content h2,
  body.archive .site-main .entry-content h2 {
    font-size: 22px;
  }
}

/* Списки внутри статьи: минимальный левый отступ (маркеры ближе к тексту),
   нижний внешний отступ 40px. */
body.blog .site-main .entry-content ul,
body.blog .site-main .entry-content ol,
body.single-post .site-main .entry-content ul,
body.single-post .site-main .entry-content ol,
body.archive .site-main .entry-content ul,
body.archive .site-main .entry-content ol {
  margin: 0 0 40px;
  padding-left: 1.2em;
}

/* Секции статьи. */
body.blog .site-main .entry-content .article__section,
body.single-post .site-main .entry-content .article__section,
body.archive .site-main .entry-content .article__section {
  margin-bottom: 80px;
}

/* Параграфы основного текста статьи: вертикальные отступы контролируются
   нашей CSS (убираем неявный браузерный margin-block-start у <p>). */
body.blog .site-main .entry-content p,
body.single-post .site-main .entry-content p,
body.archive .site-main .entry-content p {
  margin-block-start: 0;
  margin-block-end: 1.5em;
}

/* Плашка-ярлык секции статьи (сам тоже <p> — его отступ задан точечно). */
body.blog .site-main .entry-content p.article__section-label,
body.single-post .site-main .entry-content p.article__section-label,
body.archive .site-main .entry-content p.article__section-label {
  width: fit-content;
  margin: 0 0 20px;
  padding: 5px 15px;
  border-radius: 50px;
  background: var(--soft);
  color: var(--muted);
  font-family: "Graphik", sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

/* Сайдбар-виджеты (Свежие записи / Архивы / Рубрики). */
.widget-area {
  float: none;
  width: auto;
  padding: 60px 0 80px;
}
.widget-area .widget {
  margin: 0 0 40px;
}
.widget-area .widget-title {
  margin: 0 0 16px;
  font-family: 'Unbounded';
  font-size: 18px;
  line-height: 1.4;
  letter-spacing: -.03em;
  color: var(--heading);
}
.widget-area ul {
  margin: 0;
  list-style: none;
}
.widget-area ul li {
  margin: 8px 0;
}
.widget-area ul li a {
  color: var(--text);
  text-decoration: none;
  transition: color .2s;
}
.widget-area ul li a:hover { color: var(--red); }

/* Мобильный header блога: логотип и слоган компактнее. */
@media (max-width: 700px) {
  body.blog .site-header .brand svg,
  body.single-post .site-header .brand svg,
  body.archive .site-header .brand svg {
    width: 96px;
    height: auto;
  }
  body.blog .site-header .logo-tagline,
  body.single-post .site-header .logo-tagline,
  body.archive .site-header .logo-tagline {
    font-size: 11px;
    line-height: 13px;
  }
}

/* ============ Отдельная статья: meta-блок, картинка, метки ============ */

/* H1 → 5px → meta. */
body.single-post .site-main .entry-title {
  margin-bottom: 5px;
}

/* Meta-блок отдельной статьи: слева категория, справа дата + время чтения.
   Автор сохранён в разметке, но скрыт. */
body.single-post .entry-meta.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: 24px;
  row-gap: 8px;
  margin-bottom: 25px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
body.single-post .entry-meta.article-meta .byline {
  display: none;
}
body.single-post .entry-meta.article-meta time {
  color: var(--muted);
}
body.single-post .entry-meta.article-meta .article-meta__right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 24px;
}

/* «Категория:» — обычный текст, как дата/время; категории — красные плашки. */
body.single-post .entry-meta.article-meta .cat-links {
  color: var(--muted);
}
body.single-post .entry-meta.article-meta .cat-links a,
body.single-post .entry-meta.article-meta .cat-links a:visited {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 5px 15px;
  border-radius: var(--radius-lg);
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}
body.single-post .entry-meta.article-meta .cat-links a:hover {
  background: var(--red-dark);
  color: #fff;
  opacity: 1;
}

/* Основное изображение статьи: существующий крупный радиус дизайн-системы. */
body.single-post .post-thumbnail img {
  border-radius: var(--radius-xl);
}

/* Метки-пилюли (каждая — отдельный элемент со ссылкой на tag archive). */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
}
.article-tags__item,
.article-tags__item:visited {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 50px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}
.article-tags__item::before {
  content: "#";
}
.article-tags__item:hover {
  background: var(--red-dark);
  color: #fff;
  opacity: 1;
}

/* Метка «Теги этой статьи:» над списком тегов. */
.article-tags__label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Progress-bar чтения статьи: красная полоса под плавающей шапкой.
   Элемент присутствует только на страницах отдельных записей. */
.article-progress {
  position: absolute;
  left: 0;
  bottom: -5px;
  width: 0;
  height: 5px;
  background: var(--red);
  z-index: 0;
}

/* Декоративные слои шапки (скруглённые углы снизу) — выше progress bar. */
.site-header::before,
.site-header::after {
  z-index: 1;
}

/* Сайдбар скрыт только на странице отдельной статьи. */
body.single-post .widget-area {
  display: none;
}

/* ============ Доп. стили контента статьи ============ */

/* H3 внутри статьи: 26px на больших экранах, ниже H2 на остальных
   (учитываем фиксированный основной текст 21px). */
body.blog .site-main .entry-content h3,
body.single-post .site-main .entry-content h3,
body.archive .site-main .entry-content h3 {
  font-size: clamp(24px, calc(24px + (100vw - 1200px) * 2 / 700), 26px);
  margin-bottom: 15px;
  color: #000;
}
@media (max-width: 1200px) {
  body.blog .site-main .entry-content h3,
  body.single-post .site-main .entry-content h3,
  body.archive .site-main .entry-content h3 {
    font-size: clamp(22px, calc(22px + (100vw - 960px) * 2 / 240), 24px);
  }
}
@media (max-width: 960px) {
  body.blog .site-main .entry-content h3,
  body.single-post .site-main .entry-content h3,
  body.archive .site-main .entry-content h3 {
    font-size: clamp(21px, calc(21px + (100vw - 640px) * 1 / 320), 22px);
  }
}
@media (max-width: 640px) {
  body.blog .site-main .entry-content h3,
  body.single-post .site-main .entry-content h3,
  body.archive .site-main .entry-content h3 {
    font-size: 20px;
  }
}

/* Список шагов. */
body.blog .site-main .entry-content ol.article__steps li,
body.single-post .site-main .entry-content ol.article__steps li,
body.archive .site-main .entry-content ol.article__steps li {
  margin-bottom: 40px;
}
body.blog .site-main .entry-content ol.article__steps li:last-child,
body.single-post .site-main .entry-content ol.article__steps li:last-child,
body.archive .site-main .entry-content ol.article__steps li:last-child {
  margin-bottom: 0;
}

/* Оглавление. */
body.blog .site-main .entry-content .article__toc,
body.single-post .site-main .entry-content .article__toc,
body.archive .site-main .entry-content .article__toc {
  background: var(--soft);
  padding: 20px 50px;
  border-radius: var(--radius-lg);
  margin: 40px 0 80px;
}
body.blog .site-main .entry-content .article__toc a,
body.single-post .site-main .entry-content .article__toc a,
body.archive .site-main .entry-content .article__toc a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* Footer статьи. */
body.blog .site-main .entry-content .article__footer,
body.single-post .site-main .entry-content .article__footer,
body.archive .site-main .entry-content .article__footer {
  background: var(--soft);
  padding: 30px 50px 20px;
  border-radius: var(--radius-lg);
}

/* Мобильные отступы плашек (без изменения desktop-значений). */
@media (max-width: 640px) {
  body.blog .site-main .entry-content .article__toc,
  body.single-post .site-main .entry-content .article__toc,
  body.archive .site-main .entry-content .article__toc {
    padding: 20px 24px;
    margin: 32px 0 56px;
  }
  body.blog .site-main .entry-content .article__footer,
  body.single-post .site-main .entry-content .article__footer,
  body.archive .site-main .entry-content .article__footer {
    padding: 24px 20px 16px;
  }
}

/* ============ Якоря в статье ============ */

/* Старые якоря `<a name="...">` внутри/перед заголовками не должны
   выглядеть как ссылки (без красного цвета и подчёркивания). */
.site-main .entry-content a[name] {
  color: inherit;
  text-decoration: none;
}
.site-main .entry-content a[name]:hover {
  color: inherit;
  opacity: 1;
}

/* Запас при переходе по якорю из оглавления: фиксированная шапка (~96px
   desktop / ~70px mobile) + полоса прогресса 5px + визуальный буфер. */
.site-main .entry-content h1,
.site-main .entry-content h2,
.site-main .entry-content h3,
.site-main .entry-content h4,
.site-main .entry-content h5,
.site-main .entry-content h6,
.site-main .entry-content a[name] {
  scroll-margin-top: 120px;
}
@media (max-width: 700px) {
  .site-main .entry-content h1,
  .site-main .entry-content h2,
  .site-main .entry-content h3,
  .site-main .entry-content h4,
  .site-main .entry-content h5,
  .site-main .entry-content h6,
  .site-main .entry-content a[name] {
    scroll-margin-top: 90px;
  }
}

/* ============ Просмотры, «Поделиться», оценка статьи ============ */

/* Счётчик просмотров в meta (рядом с датой и временем чтения). */
.article-views {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  white-space: nowrap;
}
.article-views__icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}
.article-views__icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

/* «Поделиться статьёй». */
.article-share {
  margin-top: 40px;
}
.article-share__title {
  margin: 0 0 14px;
  color: var(--heading);
  font-family: "Graphik", sans-serif;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.4;
}
.article-share__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.article-share__btn,
.article-share__btn:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 50px;
  background: transparent;
  color: var(--heading);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.article-share__btn:hover {
  border-color: var(--red);
  color: var(--red);
  opacity: 1;
}

/* Оценка полезности статьи. */
.article-rating {
  margin: 32px auto 0;
  width: fit-content;
  max-width: 100%;
  padding: 30px 60px;
  background: var(--soft);
  border-radius: var(--radius-lg);
  text-align: center;
}
.article-rating__title {
  margin: 0 0 16px;
  color: var(--heading);
  font-family: "Graphik", sans-serif;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.4;
}
.article-rating__buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.article-rating__btn,
.article-rating__btn:visited {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 50px;
  background: transparent;
  color: var(--heading);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.article-rating__btn:hover {
  border-color: var(--red);
  color: var(--red);
  opacity: 1;
}
.article-rating__btn.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.article-rating__error {
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

/* Мобильная адаптация блоков вовлечённости. */
@media (max-width: 640px) {
  .article-rating {
    padding: 24px 20px;
  }
}

/* ============ Общая строка: оценка (слева) + «Поделиться» (справа) ============ */
.article__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px 48px;
  margin-top: 48px;
}
.article__actions .article-rating {
  margin: 0;
}
.article__actions .article-share {
  margin: 0;
  text-align: right;
}
.article__actions .article-share__buttons {
  justify-content: flex-end;
}

/* На планшетных/мобильных ширинах — вертикальная компоновка. */
@media (max-width: 960px) {
  .article__actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 32px;
  }
  .article__actions .article-share {
    text-align: left;
  }
  .article__actions .article-share__buttons {
    justify-content: flex-start;
  }
}
