/**
 * Тёмная тема для блога поверх legacy blog.css
 * Согласована с site.css (пепельный фон, жёлтый/зелёный).
 */

body.page-blog,
body.page-blog p,
body.page-blog li,
body.page-blog input,
body.page-blog textarea,
body.page-blog button {
  font-family: var(--font-body) !important;
}

body.page-blog h1,
body.page-blog h2,
body.page-blog h3,
body.page-blog h4,
body.page-blog h5,
body.page-blog h6 {
  font-family: var(--font-display) !important;
  font-weight: 700;
  line-height: 1.3;
}

.blog-layout {
  display: block;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.page-blog .blog-main {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
}

.blog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

.blog-toolbar__back {
  color: var(--color-text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
}

.blog-toolbar__back:hover {
  color: var(--color-yellow);
  text-decoration: none;
}

.blog-toolbar__count {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.blog-toolbar__rss {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 197, 24, 0.35);
  background: rgba(245, 197, 24, 0.1);
  color: var(--color-yellow);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.blog-toolbar__rss:hover {
  background: rgba(245, 197, 24, 0.2);
  color: var(--color-text);
  text-decoration: none;
}

.blog-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
}

.blog-sidebar__inner {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.blog-sidebar__stats {
  color: var(--color-green-bright);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.blog-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.blog-sidebar__nav a {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.blog-sidebar__nav a:hover {
  color: var(--color-yellow);
  text-decoration: none;
}

/* Поиск статей */
.blog-search {
  margin: 0 0 1.75rem;
}

.blog-sidebar__search .blog-search {
  margin: 0 0 1.25rem;
}

.blog-search__label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.blog-search__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  align-items: stretch;
}

.blog-search__input {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 2.625rem;
  padding: 0.55rem 0.85rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.blog-search__input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.blog-search__input:focus {
  outline: none;
  border-color: var(--color-yellow);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.15);
}

.blog-search__btn {
  flex: 0 0 auto;
  min-height: 2.625rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.blog-sidebar__search .blog-search__row {
  flex-direction: column;
}

.blog-sidebar__search .blog-search__btn {
  width: 100%;
}

.blog-search__summary {
  margin: 0 0 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.blog-search__summary strong {
  color: var(--color-yellow);
}

.blog-search__query {
  color: var(--color-text);
  font-weight: 600;
}

.blog-search__hint {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.blog-sidebar__heading {
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-yellow);
  margin: 1rem 0 0.5rem;
}

.blog-sidebar__list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--color-text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.blog-sidebar__list a {
  color: var(--color-text);
}

.blog-sidebar__list a:hover {
  color: var(--color-yellow);
}

.blog-sidebar-toggle {
  display: none;
}

/* Сброс legacy #sidebar из blog.css */
.page-blog #sidebar.blog-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
  right: auto;
  left: auto;
  width: auto;
  height: auto;
  opacity: 1;
  visibility: visible;
  transform: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  transition: none;
}

/* ---------- Заголовки блога ---------- */
.list-title,
.detail-title,
.normal-title,
.tag-title {
  font-family: var(--font-display) !important;
  line-height: 1.3 !important;
  margin-left: 0 !important;
}

.list-title {
  background: var(--color-bg-elevated) !important;
  color: var(--color-yellow) !important;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem !important;
  font-size: clamp(1.45rem, 3vw, 2rem) !important;
  font-weight: 700 !important;
  text-align: center;
  margin-bottom: 2rem !important;
}

.detail-title {
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  color: var(--color-text) !important;
  font-size: clamp(1.5rem, 3vw, 1.75rem) !important;
  font-weight: 700 !important;
  text-align: left !important;
  letter-spacing: -0.01em;
}

.tag-title {
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  margin-bottom: 1.5rem !important;
  color: var(--color-text) !important;
}

.list-title__emblem {
  width: 52px;
  height: 52px;
  vertical-align: middle;
  margin-right: 0.65rem;
  border-radius: 10px;
  object-fit: cover;
}

/* ---------- Карточка поста в списке ---------- */
.post-preview {
  margin-bottom: 2.25rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

.post-preview:last-of-type {
  border-bottom: none;
}

.post-preview__title {
  font-family: var(--font-display) !important;
  font-size: clamp(1.3rem, 2.8vw, 1.75rem) !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  margin: 0 0 0.65rem !important;
  letter-spacing: -0.01em;
}

.post-preview__title a {
  color: var(--color-text) !important;
  text-decoration: none;
  transition: color var(--transition);
}

.post-preview__title a:hover {
  color: var(--color-yellow) !important;
  text-decoration: none;
}

.post-preview__meta {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--color-text-muted) !important;
  font-style: normal;
}

.post-preview__meta time {
  color: var(--color-green-bright);
  font-weight: 600;
}

.post-preview__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.post-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-yellow) !important;
  background: rgba(245, 197, 24, 0.12);
  border: 1px solid rgba(245, 197, 24, 0.25);
  text-decoration: none !important;
}

.post-tag:hover {
  background: rgba(245, 197, 24, 0.22);
  color: var(--color-text) !important;
}

.post-preview__more {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-green-bright) !important;
  text-decoration: none !important;
}

.post-preview__more:hover {
  color: var(--color-yellow) !important;
}

/* Не дублировать заголовок из markdown в анонсе */
.post-body--excerpt h1:first-child,
.post-body--excerpt h2:first-child {
  display: none !important;
}

.post-body,
.post-body p {
  color: var(--color-text-muted) !important;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
}

.post-body--excerpt p {
  margin-top: 0;
}

.page-blog .blog-main a:not(.post-tag):not(.post-preview__more) {
  color: var(--color-green-bright);
}

.page-blog .blog-main a:not(.post-tag):not(.post-preview__more):hover {
  color: var(--color-yellow);
}

.date,
.tags,
p.tags {
  color: var(--color-text-muted) !important;
}

.post-divider {
  display: none;
}

body.page-blog {
  background-image: none;
  height: auto !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  font-family: var(--font-body);
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

.page-blog .site-main {
  padding-left: clamp(0.75rem, 3vw, 1.25rem);
  padding-right: clamp(0.75rem, 3vw, 1.25rem);
  overflow-x: hidden;
}

.page-blog .blog-layout {
  display: block !important;
  width: 100%;
  min-width: 0;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.page-blog .blog-main {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

body.page-blog h1,
body.page-blog h2 {
  line-height: 1.3 !important;
}

.post-body pre,
.post-body code {
  background: var(--color-bg) !important;
  border-radius: 6px;
}

.post-body--article {
  color: var(--color-text);
  font-family: var(--font-body) !important;
  font-size: 1rem;
  line-height: 1.6;
}

.post-body--article p,
.post-body--article li {
  color: var(--color-text-muted) !important;
  font-size: 0.95rem;
  line-height: 1.6;
}

.post-body--article h1,
.post-body--article h2,
.post-body--article h3,
.post-body--article h4,
.post-body--article h5,
.post-body--article h6 {
  font-family: var(--font-display) !important;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.post-body--article h1 {
  color: #b0d0ea;
  font-size: 1.35rem;
  margin: 2rem 0 0.75rem;
}

.post-body--article h2 {
  color: #a3c5e0;
  font-size: 1.2rem;
  margin: 1.75rem 0 0.65rem;
}

.post-body--article h3 {
  color: #97b9d6;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.55rem;
}

.post-body--article h4 {
  color: #8eafc9;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
}

.post-body--article h5,
.post-body--article h6 {
  color: #84a6c0;
  font-size: 1rem;
  font-weight: 600;
  margin: 1rem 0 0.45rem;
}

.post-body--article h1:first-child,
.post-body--article h2:first-child,
.post-body--article h3:first-child {
  margin-top: 0;
}

.pagination {
  margin-top: 2rem;
  font-family: var(--font-body);
  color: var(--color-text-muted);
}

.pagination a {
  color: var(--color-yellow) !important;
  font-weight: 600;
}

/* ---------- Страница статьи ---------- */
.post-detail__header {
  margin-bottom: 1.5rem;
}

.post-detail__meta {
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
  color: var(--color-text-muted);
}

.post-detail__meta time {
  color: var(--color-green-bright);
  font-weight: 600;
}

.post-body--article {
  margin-bottom: 2rem;
}

.post-image {
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.post-image img {
  display: block;
  width: 100%;
  height: auto;
}

.post-share-panel {
  margin: 2rem 0 2.5rem;
}

.blog-panel__lead {
  margin: 0 0 1.25rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.post-detail__back {
  margin: 0 0 1.25rem;
}

.post-detail__back a {
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.post-detail__back a:hover {
  color: var(--color-yellow);
}

.post-share-panel__link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  text-decoration: none !important;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.post-share-panel__link:hover {
  border-color: rgba(245, 197, 24, 0.35);
  background: rgba(245, 197, 24, 0.06);
  transform: translateX(4px);
}

.post-share-panel__label {
  display: block;
  font-weight: 600;
  color: var(--color-text);
}

.post-share-panel__link:hover .post-share-panel__label {
  color: var(--color-yellow);
}

.post-share-panel__hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.section-heading {
  font-family: var(--font-display) !important;
  font-size: clamp(1.15rem, 2.2vw, 1.45rem) !important;
  font-weight: 700 !important;
  color: var(--color-yellow) !important;
  margin: 0 0 1.25rem !important;
  line-height: 1.3 !important;
}

.section-empty {
  margin: 0 0 1.5rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* ---------- Похожие посты ---------- */
.similar-posts {
  margin-bottom: 2.5rem;
  padding: 1.5rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.similar-posts__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.similar-posts__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--color-bg-elevated);
  border: 1px solid transparent;
  text-decoration: none !important;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}

.similar-posts__item:hover {
  border-color: rgba(245, 197, 24, 0.35);
  background: rgba(245, 197, 24, 0.06);
  transform: translateX(4px);
}

.similar-posts__arrow {
  color: var(--color-yellow);
  font-weight: 700;
}

.similar-posts__title {
  color: var(--color-text) !important;
  font-weight: 600;
  line-height: 1.35;
}

.similar-posts__item:hover .similar-posts__title {
  color: var(--color-yellow) !important;
}

.similar-posts__date {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------- Комментарии ---------- */
.comments-section {
  padding-top: 0.5rem;
}

.comment-card {
  margin-bottom: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.comment-card__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.comment-card__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: rgba(245, 197, 24, 0.15);
  color: var(--color-yellow);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.comment-card__author {
  display: block;
  font-weight: 600;
  color: var(--color-text);
}

.comment-card__date {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.comment-card__body {
  color: var(--color-text-muted);
  line-height: 1.65;
}

.comment-card__body p {
  margin: 0 0 0.5rem;
}

.comment-form-panel {
  margin-top: 2rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--color-bg-elevated);
  border: 1px solid rgba(245, 197, 24, 0.2);
  border-radius: var(--radius);
}

.post-share-panel.comment-form-panel {
  margin-top: 2rem;
}

.comment-form__title {
  font-family: var(--font-display) !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: var(--color-text) !important;
  margin: 0 0 1.25rem !important;
}

.comment-form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .comment-form__grid {
    grid-template-columns: 1fr;
  }

  .similar-posts__item {
    grid-template-columns: auto 1fr;
  }

  .similar-posts__date {
    grid-column: 2;
    padding-left: 1.6rem;
  }
}

.comment-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.comment-form__field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.blog-field {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.blog-field:focus {
  outline: none;
  border-color: var(--color-yellow);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.15);
}

.blog-field--area {
  min-height: 120px;
  resize: vertical;
}

.comment-form__submit {
  margin-top: 0.5rem;
  border: none;
  cursor: pointer;
}

.comment-form__errors,
.comment-form__error {
  color: #ff8a80;
  font-size: 0.85rem;
}

.comment-form__errors {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

/* Скрыть legacy-стили blog.css для форм на тёмной теме */
.page-blog input[type="text"],
.page-blog input[type="email"],
.page-blog textarea {
  background: var(--color-bg) !important;
  border: 1px solid var(--color-border) !important;
  color: var(--color-text) !important;
}

.page-blog input[type="submit"] {
  all: unset;
}

.page-blog .comment {
  background: transparent !important;
}

.comment-notice {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
}

.comment-notice--success {
  color: var(--color-green-bright);
  background: rgba(61, 153, 112, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.35);
}

.comment-notice--limit {
  color: var(--color-yellow);
  background: rgba(245, 197, 24, 0.1);
  border: 1px solid rgba(245, 197, 24, 0.35);
  margin-bottom: 0;
}

.comment-form__hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
}

.comment-card--new {
  border-color: rgba(245, 197, 24, 0.55);
  box-shadow: 0 0 0 1px rgba(245, 197, 24, 0.2);
  animation: comment-highlight 1.8s ease;
}

@keyframes comment-highlight {
  0% {
    background: rgba(245, 197, 24, 0.22);
  }
  100% {
    background: var(--color-bg-card);
  }
}

/* ---------- Адаптив: текст и медиа в экран ---------- */
.page-blog .post-body,
.page-blog .post-body p,
.page-blog .post-body li {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.page-blog .post-body img,
.page-blog .post-body video,
.page-blog .post-body iframe,
.page-blog .post-image img {
  max-width: 100% !important;
  height: auto !important;
}

.page-blog .post-body pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.page-blog .post-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.page-blog .post-body blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--color-yellow);
}

.list-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  text-align: center;
}

.list-title__emblem {
  flex-shrink: 0;
}

.detail-title,
.post-detail__header .detail-title {
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

@media (max-width: 900px) {
  .post-share-panel__link {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .post-share-panel__hint {
    grid-column: 1;
  }

  .list-title {
    font-size: 1.2rem !important;
    padding: 0.9rem 1rem !important;
  }

  .list-title__emblem {
    width: 44px;
    height: 44px;
  }

  .detail-title {
    font-size: 1.35rem !important;
    padding: 0 !important;
  }

  .post-preview__title {
    font-size: 1.15rem !important;
  }

  .page-blog .blog-main {
    font-size: 1rem;
  }

  .blog-search__row {
    flex-direction: column;
    align-items: stretch;
  }

  .page-blog .blog-search__input {
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
    min-height: 0;
    height: 2.5rem;
    padding: 0 0.75rem;
    line-height: 2.5rem;
    font-size: 16px;
  }

  .page-blog .blog-search__btn.btn {
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
    height: 2.5rem;
    padding: 0 1rem;
    line-height: 2.5rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .page-blog .site-main {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
  }

  .similar-posts,
  .comment-form-panel {
    padding: 1rem;
  }

  .comment-card {
    padding: 0.85rem 1rem;
  }
}
