/** ---------- ITEM CARD ---------- **/
/* Карточка товара нужна и списку каталога, и блоку товаров под статьёй блога,
   поэтому её стили вынесены из catalog.css в отдельный компонент. */

.card {
    position: relative;
    padding: 10px;
    overflow: hidden;
    border-radius: 20px;

    height: 550px;

    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
}

.card:before {
    content: "";
    position: absolute;
    inset: 0;
    background: url(/images/ui/banner.dce1dfce49ec3dab6812.avif) center / cover no-repeat;
    opacity: 0.3;
    z-index: -1;
    transition: opacity 0.25s linear;
}

.card:hover:before {
    opacity: 0.15;
}

.card__image {
    width: 100%;
    height: 300px;
    min-height: 300px;

    border-radius: 20px;

    overflow: hidden;
}

.card__image-link {
    display: block;
}

.card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 0% 10%;
}

.card__info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    justify-content: space-between;
    height: 100%;
}

.card__text {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card__name {
    color: var(--color-text-primary);
    font-size: 22px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card__description {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.75;
}

.card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card__price {
    font-size: 22px;
    font-weight: 700;
}

.card__link {
    flex-shrink: 0;
}

@media only screen and (max-width: 640px) {
    .card {
        height: fit-content;
    }

    .card__link {
        text-align: center;
    }

    .card__price {
        font-size: 16px;
    }
}

:root {
    --blog-rule: rgba(134, 61, 12, 0.18);
    --blog-muted: rgba(67, 35, 13, 0.62);
    --blog-soft: rgba(134, 61, 12, 0.08);
    --blog-card-hover: #f0e1ce;
    --blog-measure: 720px;
    --blog-toc-width: 280px;
    --blog-gutter: 40px;
    --blog-control-height: 54px;
}

/** ---------- LIST HEADER ---------- **/

.blog__header {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding-left: 0;
}

.blog__title {
    font-family: var(--font-heading), serif;
    font-weight: 500;
    line-height: 105%;
    color: var(--color-text-primary);
}

.blog__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    flex-wrap: wrap;
}

.blog__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.blog__category {
    padding: 12px 20px;
    border: 1px solid var(--blog-rule);
    border-radius: 999px;
    background-color: var(--color-background-secondary);
    color: var(--color-text-primary);
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        color 0.25s ease;
}

.blog__category:hover {
    border-color: var(--color-decor-light);
}

.blog__category.--active {
    background-color: var(--color-button-primary);
    border-color: var(--color-button-primary);
    color: #fff;
}

/** ---------- SEARCH ---------- **/

.blog__search {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 1 460px;
}

.blog__search-field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

.blog__search-icon {
    position: absolute;
    left: 20px;
    width: 20px;
    height: 20px;
    color: var(--color-decor-light);
    opacity: 0.6;
    pointer-events: none;
}

.blog__search-input {
    width: 100%;
    height: var(--blog-control-height);
    padding: 0 20px 0 52px;
    border: 1px solid rgba(134, 61, 12, 0.5);
    border-radius: 15px;
    background-color: var(--color-background-secondary);
    color: var(--color-text-primary);
    font-family: var(--font-primary), sans-serif;
    font-size: 16px;
    font-weight: 500;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition:
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}

.blog__search-input::placeholder {
    color: rgba(67, 35, 13, 0.45);
    font-weight: 400;
}

.blog__search-input:focus {
    border-color: var(--color-decor-light);
    box-shadow: 0 0 0 3px rgba(134, 61, 12, 0.12);
}

.blog__search .button {
    display: inline-flex;
    align-items: center;
    height: var(--blog-control-height);
    padding: 0 28px;
    font-size: 16px;
}

.blog__filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.blog__filter-label {
    font-size: 14px;
    color: var(--blog-muted);
}

.blog__filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background-color: var(--blog-soft);
    color: var(--color-text-primary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.25s ease;
}

.blog__filter-chip:hover {
    background-color: rgba(134, 61, 12, 0.16);
}

.blog__filter-chip svg {
    width: 12px;
    height: 12px;
}

/** ---------- LIST ---------- **/

.blog__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

.blog__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 64px 40px;
    border-radius: 20px;
    background-color: var(--color-background-secondary);
    text-align: center;
}

.blog__empty-title {
    font-family: var(--font-heading), serif;
    font-size: 28px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-text-primary);
}

.blog__empty-text {
    max-width: 480px;
    font-size: 16px;
    color: var(--blog-muted);
}

.blog__pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.blog__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--blog-rule);
    border-radius: 999px;
    background-color: var(--color-background-secondary);
    color: var(--color-text-primary);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        color 0.25s ease;
}

.blog__page:hover {
    border-color: var(--color-decor-light);
}

.blog__page.--active {
    background-color: var(--color-button-primary);
    border-color: var(--color-button-primary);
    color: #fff;
    text-decoration: none;
}

/** ---------- CARD ---------- **/

.blog-card {
    display: flex;
    height: 100%;
    border-radius: 20px;
    background-color: var(--color-background-secondary);
    overflow: hidden;
    transition: background-color 0.25s ease;
}

.blog-card:hover {
    background-color: var(--blog-card-hover);
}

.blog-card__link {
    display: flex;
    flex-direction: column;
    width: 100%;
    color: inherit;
    text-decoration: none;
}

.blog-card__image {
    overflow: hidden;
}

.blog-card__image img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
}

.blog-card__body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 12px;
    padding: 24px;
}

.blog-card__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.blog-card__category {
    padding: 6px 12px;
    border-radius: 999px;
    background-color: var(--blog-soft);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.blog-card__date {
    font-size: 14px;
    color: var(--blog-muted);
}

.blog-card__title {
    font-family: var(--font-heading), serif;
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--color-text-primary);
}

.blog-card__excerpt {
    display: -webkit-box;
    flex-grow: 1;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    font-size: 16px;
    line-height: 1.6;
    color: var(--blog-muted);
}

.blog-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 4px;
}

.blog-card__reading {
    font-size: 14px;
    color: var(--blog-muted);
}

.blog-card__arrow {
    width: 24px;
    height: 24px;
    background: url(/images/ui/arrow.d3bfc7305ae546ef9d9b.svg) center / contain no-repeat;
    transition: transform 0.25s ease;
}

.blog-card:hover .blog-card__arrow {
    transform: rotate(-45deg);
}

/** ---------- POST ---------- **/

/* Три колонки: статья остаётся ровно по центру страницы, а оглавление уходит
   в свободное левое поле. Ниже 1400px поля не хватает — там раскладка
   возвращается к обычной колонке. */
.blog-post {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--blog-measure)) minmax(0, 1fr);
    column-gap: var(--blog-gutter);
    width: 100%;
    margin: 0 auto;
}

.blog-post > * {
    grid-column: 2;
}

/* Вертикальные отступы держит margin, а не row-gap: оглавление растянуто
   на все строки сетки, и пустые строки под ним не должны её раздвигать. */
.blog-post > *:not(:first-child):not(.blog-toc) {
    margin-top: 32px;
}

.blog-post__header {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.blog-post__category {
    align-self: flex-start;
    padding: 8px 16px;
    border-radius: 999px;
    background-color: var(--blog-soft);
    color: var(--color-text-primary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.25s ease;
}

.blog-post__category:hover {
    background-color: rgba(134, 61, 12, 0.16);
}

.blog-post__title {
    font-family: var(--font-heading), serif;
    font-weight: 500;
    line-height: 110%;
    color: var(--color-text-primary);
}

.blog-post__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--blog-rule);
    font-size: 15px;
    color: var(--blog-muted);
}

.blog-post__meta > *,
.blog-post__meta time {
    font-size: 15px;
    color: var(--blog-muted);
}

.blog-post__meta > * + *::before {
    content: "·";
    margin-right: 12px;
    opacity: 0.6;
}

.blog-post__cover {
    border-radius: 20px;
    overflow: hidden;
}

.blog-post__cover img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

/** ---------- POST TABLE OF CONTENTS ---------- **/

.blog-toc {
    grid-column: 1;
    /* Строк с запасом: оглавление занимает всю высоту статьи, поэтому липнет
       от заголовка до конца текста, а не только на высоте своей строки. */
    grid-row: 1 / span 20;
    justify-self: end;
    align-self: start;
    position: sticky;
    /* Совпадает со scroll-margin-top заголовков: компенсация фиксированной шапки. */
    top: 120px;
    width: 100%;
    max-width: var(--blog-toc-width);
}

.blog-toc__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    /* На широких экранах заголовок работает подписью, а не переключателем:
       сворачивать оглавление там незачем. */
    pointer-events: none;
    color: var(--blog-muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    list-style: none;
}

.blog-toc__summary::-webkit-details-marker {
    display: none;
}

.blog-toc__summary::after {
    content: "";
    display: none;
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    margin-bottom: 3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
}

.blog-toc__nav {
    margin-top: 14px;
}

.blog-toc__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    list-style: none;
}

.blog-toc__link {
    display: block;
    padding: 7px 12px;
    border-radius: 10px;
    color: var(--blog-muted);
    font-size: 15px;
    line-height: 1.45;
    text-decoration: none;
    transition:
        background-color 0.25s ease,
        color 0.25s ease;
}

.blog-toc__link:hover {
    background-color: var(--blog-soft);
    color: var(--color-text-primary);
}

.blog-toc__link.--active {
    background-color: var(--blog-soft);
    color: var(--color-text-primary);
    font-weight: 600;
}

/** ---------- POST CONTENT ---------- **/

.blog-post__content {
    color: var(--color-text-primary);
}

.blog-post__content > *:first-child {
    margin-top: 0;
}

.blog-post__content > *:last-child {
    margin-bottom: 0;
}

.blog-post__content p,
.blog-post__content li {
    font-size: 18px;
    line-height: 1.75;
}

.blog-post__content p {
    margin-bottom: 20px;
}

.blog-post__content h2,
.blog-post__content h3,
.blog-post__content h4 {
    font-family: var(--font-heading), serif;
    font-weight: 500;
    line-height: 1.25;
    color: var(--color-text-primary);
    /* Шапка становится фиксированной при скролле — компенсируем её высоту,
       чтобы переход по якорю не прятал заголовок. */
    scroll-margin-top: 120px;
}

.blog-post__content h2 {
    margin: 48px 0 16px;
    font-size: 32px;
}

.blog-post__content h3 {
    margin: 36px 0 14px;
    font-size: 24px;
}

.blog-post__content h4 {
    margin: 28px 0 12px;
    font-size: 20px;
}

.blog-post__content ul,
.blog-post__content ol {
    margin-bottom: 20px;
    padding-left: 22px;
}

.blog-post__content li + li {
    margin-top: 8px;
}

.blog-post__content li::marker {
    color: var(--color-decor-light);
}

.blog-post__content a {
    color: var(--color-button-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.blog-post__content a:hover {
    color: var(--color-button-primary-hover);
}

.blog-post__content strong,
.blog-post__content b {
    font-weight: 700;
}

.blog-post__content figure {
    margin: 32px 0;
}

.blog-post__content img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 20px;
}

.blog-post__content figcaption {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    color: var(--blog-muted);
}

.blog-post__content blockquote {
    margin: 32px 0;
    padding: 24px 28px;
    border-left: 3px solid var(--color-decor-light);
    border-radius: 0 15px 15px 0;
    background-color: var(--color-background-secondary);
}

.blog-post__content blockquote > *:last-child {
    margin-bottom: 0;
}

.blog-post__content hr {
    margin: 40px 0;
    border: 0;
    border-top: 1px solid var(--blog-rule);
}

.blog-post__content code {
    padding: 2px 6px;
    border-radius: 6px;
    background-color: var(--blog-soft);
    font-size: 15px;
}

.blog-post__content pre {
    margin: 32px 0;
    padding: 20px 24px;
    border-radius: 15px;
    background-color: var(--color-background-secondary);
    overflow-x: auto;
}

.blog-post__content pre code {
    padding: 0;
    background: none;
}

.blog-post__content table {
    display: block;
    width: 100%;
    margin: 32px 0;
    border-collapse: collapse;
    overflow-x: auto;
}

.blog-post__content th,
.blog-post__content td {
    padding: 12px 16px;
    border: 1px solid var(--blog-rule);
    font-size: 16px;
    text-align: left;
}

.blog-post__content th {
    background-color: var(--color-background-secondary);
    font-weight: 600;
}

/** ---------- POST FOOTER ---------- **/

.blog-post__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
}

.blog-post__tag {
    padding: 8px 14px;
    border-radius: 999px;
    background-color: var(--blog-soft);
    color: var(--blog-muted);
    font-size: 14px;
    text-decoration: none;
    transition:
        background-color 0.25s ease,
        color 0.25s ease;
}

.blog-post__tag:hover {
    background-color: rgba(134, 61, 12, 0.16);
    color: var(--color-text-primary);
}

.blog-post__cta {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
    padding: 48px 40px;
    border-radius: 20px;
    overflow: hidden;
    text-align: center;
}

.blog-post__cta:before {
    content: "";
    position: absolute;
    inset: 0;
    background: url(/images/ui/banner.dce1dfce49ec3dab6812.avif) center / cover no-repeat;
    opacity: 0.3;
    z-index: -1;
}

.blog-post__cta-title {
    font-family: var(--font-heading), serif;
    font-size: 30px;
    font-weight: 500;
    line-height: 1.2;
}

.blog-post__cta-text {
    max-width: 460px;
}

.blog-post__cta .button {
    margin-top: 6px;
}

/* Повторяет сетку статьи: содержимое занимает колонки оглавления и текста,
   поэтому левый край блока совпадает с левым краем оглавления, а правый —
   с правым краем текста. */
.blog-post__related,
.blog-post__products {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--blog-measure)) minmax(0, 1fr);
    column-gap: var(--blog-gutter);
    row-gap: 30px;
    width: 100%;
    /* Оба блока — вставки после статьи, поэтому отделяются от соседа сильнее
       обычного шага секции: 40px гэпа плюс собственный отступ. */
    margin: 40px auto 0;
}

.blog-post__related > *,
.blog-post__products > * {
    grid-column: 1 / span 2;
    justify-self: end;
    width: 100%;
    max-width: calc(var(--blog-measure) + var(--blog-toc-width) + var(--blog-gutter));
}

/** ---------- POST PRODUCTS ---------- **/

/* Заголовок ужимается, кнопка остаётся в строке на любой ширине:
   общий .section__header уходит в колонку с 1060px, здесь это не нужно. */
.blog-post__products .section__header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.blog-post__products .section__header .button {
    flex-shrink: 0;
}

/* Ширина колонки, а не их число: три товара встают в ряд на широком блоке
   и сами перестраиваются в две колонки и одну на узких экранах. */
.blog-post__products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/** ---------- ACCESSIBILITY ---------- **/

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    border: 0;
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}

.blog__category:focus-visible,
.blog__page:focus-visible,
.blog__filter-chip:focus-visible,
.blog-card__link:focus-visible,
.blog-post__category:focus-visible,
.blog-post__tag:focus-visible,
.blog-post__content a:focus-visible,
.blog-toc__summary:focus-visible,
.blog-toc__link:focus-visible {
    outline: 2px solid var(--color-decor-light);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .blog-card,
    .blog-card__arrow,
    .blog-toc__link,
    .blog-toc__summary::after {
        transition: none;
    }

    .blog-card:hover .blog-card__arrow {
        transform: none;
    }
}

/** ---------- RESPONSIVE ---------- **/

@media only screen and (max-width: 1700px) {
    .blog__grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }

    .blog-card__title {
        font-size: 20px;
    }

    .blog-post__content p,
    .blog-post__content li {
        font-size: 16px;
    }

    .blog-post__content h2 {
        font-size: 28px;
    }

    .blog-post__content h3 {
        font-size: 22px;
    }

    .blog-post__content h4 {
        font-size: 18px;
    }

    .blog-post__cta-title {
        font-size: 26px;
    }

    .blog__empty-title {
        font-size: 24px;
    }
}

/* Свободного бокового поля больше нет: статья снова обычная колонка,
   а оглавление встаёт в поток над текстом отдельным сворачиваемым блоком. */
@media only screen and (max-width: 1400px) {
    .blog-post {
        display: flex;
        flex-direction: column;
        gap: 32px;
        max-width: var(--blog-measure);
    }

    .blog-post > *:not(:first-child):not(.blog-toc) {
        margin-top: 0;
    }

    .blog-toc {
        position: static;
        max-width: 100%;
    }

    /* Оглавление ушло в колонку текста — блоки выравниваются по ней же. */
    .blog-post__related,
    .blog-post__products {
        display: flex;
        flex-direction: column;
        gap: 30px;
        max-width: var(--blog-measure);
    }

    .blog-post__related > *,
    .blog-post__products > * {
        max-width: 100%;
    }

    .blog-toc__details {
        padding: 16px 20px;
        border-radius: 15px;
        background-color: var(--color-background-secondary);
    }

    .blog-toc__summary {
        pointer-events: auto;
        cursor: pointer;
    }

    .blog-toc__summary::after {
        display: block;
    }

    .blog-toc__details[open] .blog-toc__summary::after {
        margin-bottom: -3px;
        transform: rotate(-135deg);
    }

    .blog-toc__link {
        padding: 8px 10px;
    }
}

@media only screen and (max-width: 1200px) {
    .blog__header {
        gap: 24px;
    }

    .blog__toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }

    .blog__search {
        flex: 1 1 auto;
    }

    .blog-card__body {
        padding: 20px;
    }

    .blog-card__excerpt,
    .blog-post__content th,
    .blog-post__content td {
        font-size: 14px;
    }

    .blog-post {
        gap: 24px;
    }

    .blog-post__content h2 {
        margin: 36px 0 14px;
        font-size: 24px;
    }

    .blog-post__content h3 {
        margin: 28px 0 12px;
        font-size: 20px;
    }

    .blog-post__content h4 {
        font-size: 16px;
    }

    .blog-post__cta {
        padding: 32px 24px;
    }

    .blog-post__cta-title {
        font-size: 22px;
    }
}

@media only screen and (max-width: 700px) {
    .blog__grid {
        grid-template-columns: 1fr;
    }

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

    .blog__search .button {
        justify-content: center;
        width: 100%;
    }

    .blog__category {
        padding: 10px 16px;
        font-size: 14px;
    }

    .blog__page {
        min-width: 44px;
        min-height: 44px;
        font-size: 14px;
    }

    .blog__empty {
        padding: 40px 24px;
    }

    .blog__empty-title {
        font-size: 20px;
    }

    .blog-card__title {
        font-size: 18px;
    }

    .blog-post__cover img {
        aspect-ratio: 3 / 2;
    }

    .blog-post__content p,
    .blog-post__content li {
        font-size: 14px;
        line-height: 1.7;
    }

    .blog-post__content h2 {
        font-size: 20px;
    }

    .blog-post__content h3 {
        font-size: 18px;
    }

    .blog-post__content blockquote {
        padding: 16px 20px;
    }

    .blog-post__meta,
    .blog-post__meta > *,
    .blog-post__meta time {
        font-size: 13px;
    }

    .blog-post__cta-title {
        font-size: 18px;
    }

    .blog-post__related,
    .blog-post__products {
        margin-top: 20px;
    }

    .blog-post__products .section__header {
        gap: 16px;
    }
}

