/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #ffffff;
    color: #1a1a1a;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

img { display: block; width: 100%; height: auto; }

/* ── Layout ───────────────────────────────────── */
.container,
.site-header__inner,
.site-footer__inner,
.articles-grid,
.article {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Header ───────────────────────────────────── */
.site-header {
    position: sticky;
    top: 0;
    background: #ffffff;
    border-bottom: 1px solid #ebebeb;
    z-index: 100;
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    gap: 16px;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1a1a1a;
}

.site-logo:hover { color: #555; }

.site-nav { display: flex; gap: 24px; }

/* ── Main ─────────────────────────────────────── */
.site-main { padding: 48px 0 80px; }

/* ── Footer ───────────────────────────────────── */
.site-footer {
    border-top: 1px solid #ebebeb;
    padding: 24px 0;
    color: #999;
    font-size: 0.875rem;
}

/* ── Articles Grid ────────────────────────────── */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 32px;
}

/* ── Article Card ─────────────────────────────── */
.article-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #ebebeb;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.article-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.article-card__image {
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: #f5f5f5;
}

.article-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.article-card:hover .article-card__image img { transform: scale(1.03); }

.article-card__image--placeholder { min-height: 180px; }

.article-card__body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.article-card__title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.35;
    color: #1a1a1a;
}

.article-card__preview {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.55;
    /* обрезаем до 3 строк */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* убираем встроенные отступы richtext внутри превью */
.article-card__preview p { margin: 0; }

.article-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.article-card__author {
    font-size: 0.85rem;
    font-weight: 500;
    color: #444;
}

.article-card__date {
    font-size: 0.8rem;
    color: #aaa;
}

.no-articles { text-align: center; color: #aaa; padding: 64px 0; }


/* ── Search Form ──────────────────────────────── */
.search-form {
    display: flex;
    gap: 6px;
    flex: 1;
    max-width: 400px;
}

.search-form__input {
    flex: 1;
    padding: 7px 14px;
    border: 1px solid #ebebeb;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #1a1a1a;
    outline: none;
    transition: border-color 0.15s;
}

.search-form__input:focus {
    border-color: #aaa;
}

.search-form__btn {
    padding: 7px 16px;
    border: 1px solid #1a1a1a;
    border-radius: 8px;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.search-form__btn:hover {
    background: #333;
    border-color: #333;
}

/* ── Article Page ─────────────────────────────── */
.article { padding-top: 0; }

.article__cover {
    max-width: 1100px;
    margin: 0 auto 40px;
    padding: 0 24px;
    border-radius: 12px;
    overflow: hidden;
}

.article__cover img {
    border-radius: 12px;
    max-height: 480px;
    object-fit: cover;
}

.article__header { margin-bottom: 32px; }


.back-link {
    display: inline-block;
    font-size: 0.875rem;
    color: #888;
    margin-bottom: 16px;
}

.back-link a {
    color: #888;
    transition: color 0.15s;
}

.back-link a:hover {
    color: #1a1a1a;
}

.article__title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.article__meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #ebebeb;
}

.article__author {
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
}

.article__author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    border: 1px solid #ebebeb;
}

.article__date {
    font-size: 0.9rem;
    color: #888;
    display: flex;
    align-items: center;
}

.article__date::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #ccc;
    margin-right: 16px;
}

/* ── Article Layout ───────────────────────────── */
.article__body {
    display: flex;
    align-items: flex-start;
    gap: 48px;
    position: relative;
}

.article__content {
    flex: 1;
    max-width: 700px;
}

.article__content .block-heading {
    margin: 32px 0 16px;
    line-height: 1.3;
    color: #1a1a1a;
    scroll-margin-top: 80px; /* To prevent header covering the title when anchored */
}

.article__content .block-paragraph { margin-bottom: 24px; font-size: 1.05rem; }

.article__content .block-paragraph p { margin-bottom: 1em; }

.article__content .block-image { margin: 32px 0; }

.article__content .block-image img { border-radius: 8px; }

.article__content .block-list { margin: 16px 0 24px 24px; }

.article__content .block-list li { margin-bottom: 6px; font-size: 1.05rem; }

/* ── Article Sidebar & TOC ────────────────────── */
.article__sidebar {
    width: 250px;
    flex-shrink: 0;
    position: sticky;
    top: 80px; /* Sticks to the top considering the fixed header */
}

.article-toc {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
}

.article-toc__title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #555;
    margin-bottom: 12px;
}

.article-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.article-toc__item {
    margin-bottom: 8px;
    line-height: 1.4;
}

.article-toc__item a {
    font-size: 0.9rem;
    color: #666;
    transition: color 0.2s;
}

.article-toc__item a:hover {
    color: #1a1a1a;
}

/* Indentation based on heading levels */
.article-toc__item--h3 { margin-left: 12px; }
.article-toc__item--h4 { margin-left: 24px; }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 900px) {
    .article__body {
        flex-direction: column;
    }

    .article__sidebar {
        display: none;
    }
}

@media (max-width: 600px) {
    .articles-grid { grid-template-columns: 1fr; }
    .article__title { font-size: 1.5rem; }
}

.no-articles { text-align: center; color: #aaa; padding: 64px 0; }

/* ── Article Page ─────────────────────────────── */
/* ... existing code ... */
@media (max-width: 600px) {
    .articles-grid { grid-template-columns: 1fr; }
    .article__title { font-size: 1.5rem; }
}

/* ── Pagination ───────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 48px;
}

.pagination__item {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ebebeb;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #1a1a1a;
    transition: background 0.15s, border-color 0.15s;
}

a.pagination__item:hover {
    background: #f5f5f5;
    border-color: #d0d0d0;
}

.pagination__item--active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
    font-weight: 600;
}

.pagination__item--disabled { color: #ccc; border-color: #f0f0f0; cursor: default; }

.pagination__dots { font-size: 0.875rem; color: #aaa; padding: 0 4px; }

/* ── Categories Navigation ──────────────────── */
.categories-nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 48px;
}

.categories-nav__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #1a1a1a;
}

.categories-nav__list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.category-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid #ebebeb;
    border-radius: 24px;
    font-size: 0.875rem;
    color: #1a1a1a;
    background: #ffffff;
    transition: all 0.15s ease;
    text-decoration: none;
}

.category-button:hover {
    border-color: #1a1a1a;
    background: #f9f9f9;
}

.category-button--all {
    background: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
    font-weight: 600;
}

.category-button--all:hover {
    background: #333;
}

.category-button__name {
    white-space: nowrap;
}

.category-button__count {
    background: #f0f0f0;
    color: #666;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.category-button--all .category-button__count {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

@media (max-width: 600px) {
    .categories-nav__list {
        gap: 8px;
    }

    .category-button {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}