/**
 * Eurostyle Potolki Gallery — стили публичной части
 *
 * Структура файла:
 *  1. Переменные оформления
 *  2. Контейнер и типографика
 *  3. Хлебные крошки
 *  4. Фильтры
 *  5. SEO-текст
 *  6. Сетка галереи и карточки
 *  7. Пагинация и пустое состояние
 *  8. Управление галереей на главной
 *  9. Шапка отдельной работы и метаданные
 * 10. Мозаика отдельной работы
 * 11. Текст отдельной работы
 * 12. CTA-блок
 * 13. Другие работы
 * 14. Лайтбокс
 * 15. Адаптивные правила
 * 16. Шапка страницы галереи
 */

/* --------------------------------------------------------------------------
 * 1. Переменные оформления
 * -------------------------------------------------------------------------- */

:root {
    --espg-text: #17201c;
    --espg-muted: #66726c;
    --espg-bg: #f5f7f5;
    --espg-line: #dfe5e1;
    --espg-accent: #1f684c;
    --espg-accent-dark: #154b37;
    --espg-white: #fff;
    --espg-radius: 18px;
}

/* --------------------------------------------------------------------------
 * 2. Контейнер и типографика
 * -------------------------------------------------------------------------- */

.espg-container {
    width: min(var(--es-wrap, 1240px), calc(100% - var(--es-pad, 20px) - var(--es-pad, 20px)));
    margin: 0 auto;
    padding: 15px 0;
    color: var(--espg-text);
}

.espg-container h1 {
    font-size: clamp(34px, 5vw, 64px);
    line-height: 1.04;
    letter-spacing: -.035em;
    margin: 14px 0 18px;
}

.espg-container h2 {
    font-size: clamp(26px, 3.4vw, 42px);
    line-height: 1.12;
    letter-spacing: -.025em;
    margin: 34px 0 18px;
}

.espg-container p {
    font-size: 17px;
    line-height: 1.4;
}

/* --------------------------------------------------------------------------
 * 3. Хлебные крошки
 * -------------------------------------------------------------------------- */

.espg-breadcrumbs {
    font-size: 14px;
    color: var(--espg-muted);
    margin: 8px 0 22px;
}

.espg-breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.espg-breadcrumbs li:not(:last-child)::after {
    content: '›';
    margin-left: 10px;
    color: #9aa49f;
}

.espg-breadcrumbs a {
    color: inherit;
    text-decoration: none;
}

.espg-breadcrumbs a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
 * 4. Фильтры
 * -------------------------------------------------------------------------- */

.espg-filters {
    display: grid;
    gap: 14px;
    padding: 18px;
    margin: 24px 0;
    border: 1px solid var(--espg-line);
    border-radius: var(--espg-radius);
    background: var(--espg-white);
}

.espg-filter-group {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.espg-filter-label {
    flex: 0 0 118px;
    padding-top: 8px;
    font-weight: 700;
    font-size: 14px;
}

.espg-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.espg-filter {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid var(--espg-line);
    border-radius: 14px;
    background: #fff;
    color: var(--espg-text);
    font-size: 14px;
    text-decoration: none;
    transition: .2s ease;
}

.espg-filter:hover {
    border-color: #aebbb4;
    transform: translateY(-1px);
}

.espg-filter.is-active {
    background: var(--espg-accent);
    border-color: var(--espg-accent);
    color: #fff;
}

/* --------------------------------------------------------------------------
 * 5. SEO-текст
 * -------------------------------------------------------------------------- */

.espg-seo-copy {
    max-width: 960px;
    margin: 22px 0;
}

.espg-seo-copy p {
    margin: 0 0 14px;
    color: #3d4842;
}

/* --------------------------------------------------------------------------
 * 6. Сетка галереи и карточки
 * -------------------------------------------------------------------------- */

.espg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 24px 0;
}

.espg-card {
    min-width: 0;
}

.espg-card-link {
    position: relative;
    display: block;
    aspect-ratio: 1/1;
    overflow: hidden;
    border-radius: 14px;
    background: #edf1ee;
    color: #fff;
    text-decoration: none;
}

.espg-card-media,
.espg-card-media img {
    display: block;
    width: 100%;
    height: 100%;
}

.espg-card-media img {
    object-fit: cover;
    transition: transform .35s ease;
}

.espg-card-overlay {
    position: absolute;
    inset: auto 0 0;
    padding: 46px 15px 14px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .72));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
}

.espg-card-title {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 400;
}

.espg-card-id {
    flex: 0 0 auto;
    font-size: 11px;
    opacity: .8;
}

.espg-card-link:hover .espg-card-media img {
    transform: scale(1.035);
}

.espg-card-placeholder {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #edf1ee, #d9e2dd);
}

/* --------------------------------------------------------------------------
 * 7. Пагинация и пустое состояние
 * -------------------------------------------------------------------------- */

.espg-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 30px 0;
}

.espg-pagination a,
.espg-pagination span {
    display: grid;
    place-items: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--espg-line);
    border-radius: 10px;
    text-decoration: none;
    color: var(--espg-text);
}

.espg-pagination .is-current {
    background: var(--espg-accent);
    border-color: var(--espg-accent);
    color: #fff;
}

.espg-empty {
    padding: 28px;
    border-radius: 14px;
    background: var(--espg-bg);
    color: var(--espg-muted);
}

/* --------------------------------------------------------------------------
 * 8. Управление галереей на главной
 * -------------------------------------------------------------------------- */

.espg-home-gallery__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-top: 20px;
}

.espg-load-more,
.espg-cta-button {
    border: 0;
    border-radius: 12px;
    background: var(--espg-accent);
    color: #fff;
    padding: 13px 20px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.espg-load-more:hover,
.espg-cta-button:hover {
    background: var(--espg-accent-dark);
    color: #fff;
}

.espg-home-gallery__status {
    font-size: 14px;
    color: var(--espg-muted);
}

.espg-home-gallery.is-loading {
    opacity: .72;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
 * 9. Шапка отдельной работы и метаданные
 * -------------------------------------------------------------------------- */

.espg-single {
    background: #fff;
}

.espg-single-header {
    max-width: 1050px;
    padding: 28px 0 12px;
}

.espg-eyebrow {
    margin: 0 !important;
    color: var(--espg-accent) !important;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 12px !important;
    font-weight: 800;
}

.espg-single-lead {
    max-width: 820px;
    color: #536059;
}

.espg-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.espg-chip {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: #f0f4f1;
    color: #2f3d36;
    text-decoration: none;
    font-size: 13px;
}

.espg-chip--primary {
    background: #e1eee7;
    color: #174c38;
    font-weight: 700;
}

.espg-chip--geo {
    background: #f5f0e7;
    color: #5b4a32;
}

/* --------------------------------------------------------------------------
 * 10. Мозаика отдельной работы
 * -------------------------------------------------------------------------- */

.espg-single-gallery-section {
    margin-top: 26px;
}

.espg-mosaic {
    width: 100%;
    margin: 18px 0 38px;
}

.espg-mosaic-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: stretch;
}

.espg-mosaic-row.is-justified .espg-mosaic-item {
    flex-grow: 1;
}

.espg-mosaic-item {
    display: block;
    overflow: hidden;
    border-radius: 12px;
    background: #edf1ee;
    flex: 0 0 auto;
    min-width: 0;
}

.espg-mosaic-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .28s ease;
}

.espg-mosaic-item:hover img {
    transform: scale(1.018);
}

/* --------------------------------------------------------------------------
 * 11. Текст отдельной работы
 * -------------------------------------------------------------------------- */

.espg-work-copy {
    max-width: 960px;
    margin: 52px 0;
}

.espg-work-copy p {
    margin: 0 0 18px;
    color: #36413b;
}

.espg-editor-content {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--espg-line);
}

/* --------------------------------------------------------------------------
 * 12. CTA-блок
 * -------------------------------------------------------------------------- */

.espg-single-cta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 28px;
    align-items: center;
    padding: 30px;
    border-radius: 22px;
    background: #eef5f1;
    margin: 44px 0;
}

.espg-single-cta h2 {
    margin: 6px 0 10px;
}

.espg-single-cta p:not(.espg-eyebrow) {
    margin: 0;
    color: #46534c;
}

.espg-cta-button {
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
 * 13. Другие работы
 * -------------------------------------------------------------------------- */

.espg-related {
    margin: 56px 0 20px;
}

.espg-related-head h2 {
    margin-top: 6px;
}

.espg-related-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 12px;
    scrollbar-width: thin;
    cursor: grab;
    -webkit-overflow-scrolling: touch;
}

.espg-related-track.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.espg-related-card {
    flex: 0 0 min(290px, 34vw);
    color: inherit;
    text-decoration: none;
}

.espg-related-image {
    display: block;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 13px;
    background: #edf1ee;
}

.espg-related-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.espg-related-caption {
    display: block;
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.4;
}

/* --------------------------------------------------------------------------
 * 14. Лайтбокс
 * -------------------------------------------------------------------------- */

.espg-lightbox[hidden] {
    display: none !important;
}

.espg-lightbox {
    position: fixed;
    z-index: 999999;
    inset: 0;
    background: rgba(10, 14, 12, .94);
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) 72px;
    align-items: center;
}

.espg-lightbox-stage {
    height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 10px;
}

.espg-lightbox-stage img {
    max-width: 100%;
    max-height: calc(100vh - 56px);
    object-fit: contain;
}

.espg-lightbox-close {
    position: absolute;
    right: 18px;
    top: 14px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 32px;
    cursor: pointer;
}

.espg-lightbox-prev,
.espg-lightbox-next {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 60px;
    cursor: pointer;
    height: 100%;
}

.espg-lightbox-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, .45);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
}

.espg-lightbox-open {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
 * 15. Адаптивные правила
 * -------------------------------------------------------------------------- */

@media (max-width: 991px) {
    .espg-gallery-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .espg-single-cta {
        grid-template-columns: 1fr;
    }

    .espg-related-card {
        flex-basis: 42vw;
    }
}

@media (max-width: 720px) {
    .espg-container {
        width: calc(100% - var(--es-pad, 20px) - var(--es-pad, 20px));
        padding-top: 40px;
        padding-bottom: 56px;
    }

    .espg-filter-group {
        display: block;
    }

    .espg-filter-label {
        display: block;
        margin-bottom: 9px;
    }

    .espg-gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .espg-card-overlay {
        padding: 36px 10px 10px;
    }

    .espg-card-title {
        font-size: 12px;
    }

    .espg-card-id {
        display: none;
    }

    .espg-single-cta {
        padding: 22px;
    }

    .espg-related-card {
        flex-basis: 72vw;
    }

    .espg-lightbox {
        grid-template-columns: 48px minmax(0, 1fr) 48px;
    }

    .espg-lightbox-prev,
    .espg-lightbox-next {
        font-size: 46px;
    }

    .espg-home-gallery__footer {
        align-items: stretch;
        flex-direction: column;
    }

    .espg-load-more {
        width: 100%;
    }
}

/* --------------------------------------------------------------------------
 * 16. Шапка страницы галереи
 * -------------------------------------------------------------------------- */

.espg-gallery-page__header {
    max-width: 980px;
}

.espg-gallery-page__header h1 {
    margin-bottom: 16px;
}

.espg-gallery-page__header h2 {
    margin-top: 0;
    color: var(--espg-muted);
    font-size: clamp(22px, 2.6vw, 34px);
    font-weight: 600;
}
