/*
 * Full-screen просмотр содержательных фотографий на внутренних страницах.
 * Главная не подключает этот модуль: её изображения остаются навигацией.
 */

html.dd-image-gallery-open,
body.dd-image-gallery-open {
    overflow: hidden;
}

.dd-image-gallery-target {
    cursor: zoom-in;
}

.dd-image-gallery {
    position: fixed;
    /* Поверх cookie-баннера, виджета записи и фиксированной навигации. */
    z-index: 2147483647;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;

    background: rgba(0, 16, 19, .88);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.dd-image-gallery[hidden] {
    display: none;
}

.dd-image-gallery.is-open {
    opacity: 1;
    pointer-events: auto;
}

.dd-image-gallery__dialog {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    outline: 0;
}

.dd-image-gallery__figure {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 0;
    height: 0;
    margin: 0;
}

.dd-image-gallery__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;

    border-radius: 4px;
    box-shadow: 0 18px 56px rgba(0, 0, 0, .44);
}

.dd-image-gallery__caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;

    margin: 0;
    padding: clamp(32px, 5vw, 76px) clamp(16px, 3vw, 28px) clamp(14px, 2vw, 22px);

    color: var(--dd-white, #fff);
    background: linear-gradient(180deg, rgba(0, 16, 19, 0) 0%, rgba(0, 16, 19, .9) 100%);
    font-family: var(--dd-font-body, sans-serif);
    font-size: clamp(.9rem, 1.4vw, 1.125rem);
    line-height: 1.35;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .44);
}

.dd-image-gallery__caption[hidden],
.dd-image-gallery__previous[hidden],
.dd-image-gallery__next[hidden],
.dd-image-gallery__counter[hidden] {
    display: none;
}

.dd-image-gallery__close,
.dd-image-gallery__previous,
.dd-image-gallery__next {
    position: absolute;
    z-index: 1;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;

    color: var(--dd-white, #fff);
    background: rgba(0, 16, 19, .58);
    border: 1px solid rgba(255, 255, 255, .42);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease;
}

.dd-image-gallery__close:hover,
.dd-image-gallery__close:focus-visible,
.dd-image-gallery__previous:hover,
.dd-image-gallery__previous:focus-visible,
.dd-image-gallery__next:hover,
.dd-image-gallery__next:focus-visible {
    color: var(--dd-white, #fff);
    background: var(--dd-accent, #e7382b);
    outline: none;
}

.dd-image-gallery__close {
    top: 10px;
    right: 10px;
    width: 42px;
    height: 42px;
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
}

.dd-image-gallery__previous,
.dd-image-gallery__next {
    top: 50%;
    width: 46px;
    height: 46px;
    font-size: 2rem;
    line-height: 1;
    transform: translateY(-50%);
}

.dd-image-gallery__previous {
    left: 10px;
}

.dd-image-gallery__next {
    right: 10px;
}

.dd-image-gallery__previous:hover,
.dd-image-gallery__previous:focus-visible,
.dd-image-gallery__next:hover,
.dd-image-gallery__next:focus-visible {
    transform: translateY(-50%) scale(1.06);
}

.dd-image-gallery__counter {
    position: absolute;
    top: clamp(4px, 1vw, 14px);
    left: 50%;
    padding: 5px 10px;

    color: var(--dd-white, #fff);
    background: rgba(0, 16, 19, .58);
    border-radius: 99px;
    font-family: var(--dd-font-ui, sans-serif);
    font-size: .8125rem;
    line-height: 1;
    transform: translateX(-50%);
}

@media (max-width: 600px) {

    .dd-image-gallery {
        padding: 12px;
    }

    .dd-image-gallery__close {
        top: 4px;
        right: 4px;
        width: 38px;
        height: 38px;
        font-size: 1.75rem;
    }

    .dd-image-gallery__previous,
    .dd-image-gallery__next {
        bottom: 12px;
        top: auto;
        width: 42px;
        height: 42px;
        font-size: 1.75rem;
        transform: none;
    }

    .dd-image-gallery__previous {
        left: 10px;
    }

    .dd-image-gallery__next {
        right: 10px;
    }

    .dd-image-gallery__previous:hover,
    .dd-image-gallery__previous:focus-visible,
    .dd-image-gallery__next:hover,
    .dd-image-gallery__next:focus-visible {
        transform: scale(1.06);
    }

    .dd-image-gallery__caption {
        padding-right: 60px;
        padding-left: 60px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .dd-image-gallery,
    .dd-image-gallery__close,
    .dd-image-gallery__previous,
    .dd-image-gallery__next {
        transition: none;
    }
}
