/* ==========================================================================
   Gallery — Masonry-сетка, карточки пинов, детальная страница
   Фильтры: базовые стили из your_poodles.css (.poodle-filters)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Masonry grid (CSS Grid + JS высоты)
   -------------------------------------------------------------------------- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    align-items: start;
}

.gallery-grid--related {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.gallery-grid__empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary-color);
    opacity: 0.6;
    font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Pin card
   -------------------------------------------------------------------------- */

.gallery-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.04);
    break-inside: avoid;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.gallery-card__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.gallery-card__image-wrap {
    width: 100%;
    overflow: hidden;
    line-height: 0;
}

.gallery-card__image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.gallery-card:hover .gallery-card__image {
    transform: scale(1.04);
}

.gallery-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-card:hover .gallery-card__overlay {
    opacity: 1;
}

.gallery-card__tag {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

/* --------------------------------------------------------------------------
   Detail page
   -------------------------------------------------------------------------- */

.gallery-detail__article {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 32px;
    align-items: start;
    margin-bottom: 48px;
}

.gallery-detail__image-wrap {
    border-radius: 16px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.04);
}

.gallery-detail__image {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-detail__info {
    position: sticky;
    top: 100px;
}

.gallery-detail__title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--secondary-color, #191A23);
}

.gallery-detail__table-wrap {
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    overflow: hidden;
}

.gallery-detail__table {
    width: 100%;
    border-collapse: collapse;
}

.gallery-detail__table tr {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.gallery-detail__table tr:last-child {
    border-bottom: none;
}

.gallery-detail__table td {
    padding: 0.75rem 1rem;
    vertical-align: top;
}

.gallery-detail__table-icon {
    width: 28px;
    color: var(--secondary-color, #555);
    opacity: 0.85;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.gallery-detail__table-icon i {
    font-size: 1rem;
}

.gallery-detail__table-label {
    width: 100px;
    font-weight: 500;
    color: var(--secondary-color, #444);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.gallery-detail__table-value {
    color: var(--text-color, #222);
}

.gallery-detail__table-value a {
    color: #2d5a1a;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.gallery-detail__table-value a:hover {
    color: #1e3d12;
}

/* Related */
.gallery-related {
    margin-top: 32px;
}

.gallery-related__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--secondary-color, #191A23);
}

/* --------------------------------------------------------------------------
   Pagination — 1 в 1 nurseries
   -------------------------------------------------------------------------- */

.gallery-main .blog-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 40px;
}

.gallery-main .blog-pagination__list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.gallery-main .blog-pagination__item {
    margin: 0;
}

.gallery-main .blog-pagination__control,
.gallery-main .blog-pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--secondary-color);
    background-color: var(--body-color);
    border: 1px solid var(--secondary-color);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}

.gallery-main .blog-pagination__control:hover,
.gallery-main .blog-pagination__link:hover {
    background-color: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
}

.gallery-main .blog-pagination__link--current {
    background-color: var(--secondary-color);
    color: white;
}

.gallery-main .blog-pagination__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--secondary-color);
    opacity: 0.6;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Gallery filters — Desktop: дополнительная обёртка .gallery-filters__buttons
   На десктопе ведёт себя как обычный flex column (наследуя poodle-filters)
   -------------------------------------------------------------------------- */

.gallery-filters-toggle {
    display: none;
}

.gallery-filters__buttons {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
    .gallery-detail__article {
        grid-template-columns: 1fr;
    }

    .gallery-detail__info {
        position: static;
    }
}

@media (max-width: 768px) {

    /* Кнопка «Фильтры» — видна только на мобильных */
    .gallery-filters-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 12px 20px;
        margin-bottom: 12px;
        background: var(--body-color, #fff);
        border: 2px solid var(--secondary-color, #191A23);
        border-radius: 14px;
        font-size: 15px;
        font-weight: 600;
        color: var(--secondary-color, #191A23);
        cursor: pointer;
        transition: background 0.2s ease;
        position: relative;
    }

    .gallery-filters-toggle:hover {
        background: rgba(0, 0, 0, 0.03);
    }

    .gallery-filters-toggle__badge {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--primary-color, #B9FF66);
        border: 1px solid var(--secondary-color, #191A23);
    }

    /* Панель фильтров — скрыта по умолчанию */
    .gallery-filters {
        display: none;
    }

    .gallery-filters--open {
        display: block;
    }

    /* Группа фильтров — отступы */
    .gallery-filters .poodle-filters__group {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 16px;
        gap: 0;
    }

    .gallery-filters .poodle-filters__group:last-child {
        margin-bottom: 0;
    }

    .gallery-filters .poodle-filters__label {
        width: 100%;
        margin-bottom: 8px;
        padding-bottom: 4px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        opacity: 0.7;
    }

    /* Кнопки фильтров — CSS Grid с равной шириной */
    .gallery-filters .gallery-filters__buttons {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .gallery-filters .poodle-filters__btn {
        padding: 8px 6px;
        font-size: 13px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border-radius: 10px;
    }

    /* Стрижки — длинные названия, 2 колонки */
    .gallery-filters .poodle-filters__group:nth-child(3) .gallery-filters__buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-filters .poodle-filters__group:nth-child(3) .poodle-filters__btn {
        white-space: normal;
        font-size: 12px;
        line-height: 1.3;
        padding: 8px;
    }

    /* Возраст и Пол — всё в одну строку */
    .gallery-filters .poodle-filters__group:nth-child(4) .gallery-filters__buttons,
    .gallery-filters .poodle-filters__group:nth-child(5) .gallery-filters__buttons {
        grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .gallery-main .blog-pagination {
        gap: 10px;
    }

    .gallery-main .blog-pagination__control,
    .gallery-main .blog-pagination__link {
        min-width: 40px;
        min-height: 40px;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .gallery-card {
        border-radius: 8px;
    }

    /* 2 колонки для всех фильтров на маленьких экранах */
    .gallery-filters .gallery-filters__buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-filters .poodle-filters__group:nth-child(4) .gallery-filters__buttons,
    .gallery-filters .poodle-filters__group:nth-child(5) .gallery-filters__buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}
