/* --- Сброс и базовые стили --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: Arial, sans-serif;
  background: #fff;
  color: #333;
  line-height: 1.5;
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Контейнер для всей страницы */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 15px;
}

/* --------- Теги --------- */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 30px;
}
.tags-container button {
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 20px;
  background: #fff;
  font-size: 0.7rem;
  color:#777777;
  cursor: pointer;
  transition: 0.3s;
}
.tags-container button:hover {
  background: #f3f3f3;
}

/* =========================
   ВЕРСТКА ДЛЯ ОДНОГО ПОСТА
   (.main-content, .main-article, .sidebar)
   ========================= */
.main-content {
  display: flex;
  gap: 20px;
  margin-bottom: 40px;
}
.main-article {
  flex: 2;
}
.main-article .image-container {
  position: relative;
  width: 100%;
  padding-top: 60%;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 20px;
}
.main-article .image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.main-article h1 {
  font-size: 1.6rem;
  font-weight: bold;
  margin-bottom: 10px;
}
.main-article .meta-data {
  font-size: 0.9rem;
  color: #777;
  margin-bottom: 20px;
}
.main-article .meta-data .sep {
  margin: 0 6px;
}
.main-article .content {
  font-size: 1rem;
  color: #555;
  line-height: 1.7;
}

.sidebar {
  flex: 1;
}
.sidebar h3 {
  font-size: 1.1rem;
  margin-bottom: 15px;
}

.sidebar .sidebar-post {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}
.sidebar .sidebar-post img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 10px;
}
.sidebar .sidebar-post-info a {
  font-size: 0.95rem;
  color: #333;
}
.sidebar .sidebar-post-date {
  font-size: 0.85rem;
  color: #999;
  margin-top: 2px;
}

/* =========================
   ВЕРСТКА ДЛЯ СПИСКА ПОСТОВ
   (Топ-пост + остальная сетка)
   ========================= */
/* Топ-пост + сайдбар */
.top-post-container {
  display: flex;
  gap: 30px;
  margin-bottom: 40px;
}
.top-post {
  flex: 2;
}
.top-post .image-container {
  position: relative;
  width: 100%;
  padding-top: 60%;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}
.top-post .image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.top-post-content h1 {
  font-size: 1.6rem;
  font-weight: bold;
  margin-bottom: 10px;
  line-height: 1.3;
}
.top-post-content .meta-data {
  font-size: 0.9rem;
  color: #777;
  margin-bottom: 20px;
}
.top-post-content .meta-data .sep {
  margin: 0 6px;
}
.top-post-content .excerpt {
  font-size: 1rem;
  color: #555;
  line-height: 1.5;
}

/* Сайдбар справа */
.sidebar-latest {
  flex: 1;
}
.sidebar-latest h3 {
  font-size: 1.1rem;
  margin-bottom: 15px;
}
.sidebar-latest .sidebar-post {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}
.sidebar-latest .sidebar-post img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 10px;
}
.sidebar-latest .sidebar-post-info a {
  font-size: 0.95rem;
  color: #333;
}
.sidebar-latest .sidebar-post-date {
  font-size: 0.85rem;
  color: #999;
  margin-top: 2px;
}

/* ----- Сетка для остальных постов (2 колонки) ----- */
.post-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 40px;
}
.post-card {
  display: flex;
  flex-direction: column;
}
.post-card .image-container {
  position: relative;
  width: 100%;
  padding-top: 60%;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 15px;
}
.post-card .image-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-card .post-meta {
  font-size: 0.85rem;
  color: #777;
  margin-bottom: 8px;
}
.post-card .post-meta .sep {
  margin: 0 5px;
}
.post-card h2 {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 8px;
  line-height: 1.3;
}
.post-card .excerpt {
  font-size: 0.95rem;
  color: #555;
  line-height: 1.4;
  margin-bottom: 10px;
}
/* Теги под карточкой */
.post-card .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
}
.post-card .card-tags .tag a {
  font-size: 0.8rem;
  padding: 5px 10px;
  background: #f4f4f4;
  border-radius: 14px;
  display: inline-block;
  transition: 0.2s;
}
.post-card .card-tags .tag a:hover {
  background: #e6e6e6;
}

/* ----- Адаптивность ----- */
@media (max-width: 992px) {
  .top-post-container {
    flex-direction: column;
  }
  .sidebar-latest {
    margin-top: 30px;
  }
  .post-grid {
    grid-template-columns: 1fr; /* Переходим в один столбец */
  }
}
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }
  .sidebar {
    margin-top: 30px;
  }
  .tags-container {
    justify-content: flex-start;
    overflow-x: auto; 
  }
}

/* =========================
   ВЛОЖЕННЫЕ (ИЕРАРХИЧЕСКИЕ) ПОСТЫ
   ========================= */

/* Каждый узел (пост) в дереве */
.nested-post {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 20px;
  background: #fff;
}

/* Шапка вложенного поста: заголовок, метаданные */
.nested-post .post-header h2,
.nested-post .post-header h3,
.nested-post .post-header h4 {
  margin-bottom: 6px;
  color: #222;
}
.nested-post .post-header .post-meta {
  font-size: 0.85rem;
  color: #888;
}

/* Контент вложенного поста */
.nested-post .post-content p {
  margin-bottom: 1em;
  color: #555;
}

/* Список "детей" (дочерние посты) */
.nested-children {
  list-style: none;
  margin-top: 15px;
  padding-left: 20px; /* отступ для «ветки» слева */
}

/* Иерархические линии (для красоты) */
.nested-children > li {
  position: relative;
  margin-left: 15px;
  padding-left: 15px;
  border-left: 2px dashed #ccc; /* вертикальная «ветка» */
  margin-bottom: 20px;
}
.nested-children > li::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 15px;
  width: 10px;
  height: 2px;
  background: #ccc; /* горизонтальный сегмент, соединяющий ветку с потомком */
}

/* Изменяем фон/отступы на более глубоких уровнях вложенности */
.nested-children .nested-children {
  margin-left: 10px;
  padding-left: 20px;
  border-left-color: #ddd;
}
.nested-children .nested-post {
  background: #fafafa;
}
.nested-children .nested-children .nested-post {
  background: #fdfdfd;
}

/* Адаптивно уменьшаем отступы, если нужно */
@media (max-width: 768px) {
  .nested-post {
    margin-bottom: 15px;
    padding: 10px;
  }
  .nested-post .post-header h2 {
    font-size: 1.2rem;
  }
}