/* ============================================================
   Sun Gallery — стили фронтенда
   CSS variables на root экземпляра: --sun-cols-desktop, --sun-cols-mobile,
   --sun-gap, --tile-aspect (per-tile). Это позволяет иметь несколько
   галерей с разными настройками на одной странице.
   ============================================================ */

.sun-gallery,
.sun-gallery * {
    box-sizing: border-box;
}

.sun-gallery {
    /* Локальные переменные с дефолтами на случай отсутствия inline-style. */
    --sun-cols-desktop: 4;
    --sun-cols-mobile: 3;
    --sun-gap: 4px;
    --sun-chip-radius: 16px;
    --sun-tile-radius: 18px;
    --sun-accent: #b7b2a8;
    --sun-text: #2b2b2b;
    --sun-muted: #888;

    color: var(--sun-text);
    /* Наследуем шрифт темы — не навязываем свой. */
    font-family: inherit;
    margin: 24px 0;
}

/* Все вложенные элементы тоже наследуют шрифт темы. */
.sun-gallery * {
    font-family: inherit;
}

.sun-gallery-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 16px;
    padding: 0 16px;
}

/* ----------- Чипсы фильтров ----------- */
.sun-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding: 0 16px;
}

.sun-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sun-filter-label {
    font-size: 13px;
    color: var(--sun-muted);
    font-weight: 500;
    min-width: 70px;
}

.sun-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Чипсы фильтров — полностью залиты цветом термина, без обводки.
   В неактивном состоянии — слегка приглушены (75% непрозрачности). */
.sun-chip {
    --chip-color: var(--sun-accent);
    --chip-text: #ffffff;
    appearance: none;
    border: none;
    background: var(--chip-color);
    color: var(--chip-text);
    padding: 6px 14px;
    border-radius: var(--sun-chip-radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
    opacity: 0.5;
    transition: opacity 0.22s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sun-chip:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.sun-chip:active {
    transform: translateY(0) scale(0.96);
}

.sun-chip.is-active {
    opacity: 1;
}

/* Приглушённый чип — у термина 0 кейсов с учётом других фильтров. */
.sun-chip.sun-chip-empty {
    opacity: 0.25;
    cursor: not-allowed;
}

.sun-chip.sun-chip-empty:hover {
    opacity: 0.4;
    transform: none;
}

/* Кнопка «Сбросить фильтры» — появляется когда что-то выбрано. */
.sun-filters-reset {
    appearance: none;
    background: transparent;
    border: 1px dashed #999;
    color: #666;
    padding: 5px 12px;
    border-radius: var(--sun-chip-radius);
    font-size: 12px;
    cursor: pointer;
    margin-left: auto;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.sun-filters-reset:hover {
    color: #d63638;
    border-color: #d63638;
}

/* Класс на плитке, скрытой фильтром (отличается от пагинационного [hidden]
   только семантикой — для применения CSS правил при анимации). */
.sun-tile-hidden-filter {
    display: none !important;
}

.sun-chip-count {
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.25);
    padding: 1px 7px;
    border-radius: 8px;
}

/* ----------- Сетка ----------- */
/* !important чтобы перебить стили темы (Eva имеет .wpb_wrapper > div { display: block }). */
.sun-gallery .sun-grid {
    display: grid !important;
    grid-template-columns: repeat(var(--sun-cols-desktop, 4), 1fr) !important;
    gap: var(--sun-gap, 4px);
    padding: 0 16px;
}

/* Квадратная сетка — все плитки строго 1:1, без переопределений темой.
   Селектор .sun-grid .sun-tile (плитки лежат внутри .sun-grid внутри .sun-gallery). */
.sun-gallery.sun-grid-square .sun-grid .sun-tile,
.sun-gallery.sun-grid-square article.sun-tile {
    aspect-ratio: 1 / 1 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    width: 100% !important;
    min-width: 0 !important;
    float: none !important;
    box-sizing: border-box !important;
    align-self: stretch !important;
    display: block !important;
}

/* Masonry-режим через CSS Columns (плитки разной высоты). */
.sun-grid-masonry .sun-grid {
    display: block;
    column-count: var(--sun-cols-desktop);
    column-gap: var(--sun-gap);
    padding: 0 16px;
}

.sun-gallery.sun-grid-masonry .sun-tile {
    display: block !important;
    margin-bottom: var(--sun-gap) !important;
    break-inside: avoid;
    /* В masonry высоту задаёт натуральная высота фото, не aspect-ratio. */
}

.sun-grid-masonry .sun-tile-inner {
    height: auto;
}

.sun-grid-masonry .sun-tile img,
.sun-grid-masonry .sun-tile .sun-img {
    height: auto;
    object-fit: contain;
}

/* ----------- Плитка ----------- */
.sun-tile {
    position: relative;
    background: transparent;
    /* Container query — текст внутри overlay масштабируется относительно ширины плитки. */
    container-type: inline-size;
    /* Само окошко не имеет overflow:hidden — это позволяет «нарисовать» обводку СНАРУЖИ. */
    /* Скругление задаётся на inner (само «окошко» с фото). */
}

/* WOW-анимация появления плиток: slide-up снизу + spring overshoot.
   Активна когда у root класс sun-has-anim. JS проставляет animation-delay для stagger. */
.sun-has-anim .sun-tile {
    animation: sun-tile-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes sun-tile-pop {
    0% {
        opacity: 0;
        transform: translateY(24px) scale(0.94);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Reduce motion — для пользователей с системной настройкой «уменьшить движение».
   Заменяем slide+scale на простой fade. */
@media (prefers-reduced-motion: reduce) {
    .sun-has-anim .sun-tile {
        animation: sun-tile-fade 0.3s ease backwards;
    }
    @keyframes sun-tile-fade {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
}

/* Внутренний контейнер — без overflow:hidden и без mask.
   Фото внутри клипится своим border-radius. Обводка рисуется псевдоэлементом ::after поверх.
   Никаких transition/transform на inner — иначе при hover будет мерцание из-за repaint. */
.sun-tile-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: var(--sun-tile-radius);
    background: #f0f0f0;
}

/* Псевдоэлемент-«рамка» поверх плитки: рисует обводку и финальную скруглённую рамку.
   Не клипит контент — только рисует. */
.sun-tile-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--sun-tile-radius);
    pointer-events: none;
    z-index: 4;
}

/* ===== Обводка ВНУТРИ плитки (inside) — рамка занимает место внутри плитки.
   Между плитками = настройка gap (чистый отступ). ===== */
.sun-has-borders.sun-borders-inside .sun-tile {
    z-index: 1;
}
.sun-has-borders.sun-borders-inside .sun-tile-rings .sun-tile-inner::after {
    box-shadow:
        inset 0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent);
}
.sun-has-borders.sun-borders-inside .sun-tile-rings-2 .sun-tile-inner::after {
    box-shadow:
        inset 0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent),
        inset 0 0 0 calc(var(--sun-border-w, 3px) * 2) var(--ring-2, transparent);
}
.sun-has-borders.sun-borders-inside .sun-tile-rings-3 .sun-tile-inner::after {
    box-shadow:
        inset 0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent),
        inset 0 0 0 calc(var(--sun-border-w, 3px) * 2) var(--ring-2, transparent),
        inset 0 0 0 calc(var(--sun-border-w, 3px) * 3) var(--ring-3, transparent);
}
.sun-has-borders.sun-borders-inside .sun-tile-rings-4 .sun-tile-inner::after {
    box-shadow:
        inset 0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent),
        inset 0 0 0 calc(var(--sun-border-w, 3px) * 2) var(--ring-2, transparent),
        inset 0 0 0 calc(var(--sun-border-w, 3px) * 3) var(--ring-3, transparent),
        inset 0 0 0 calc(var(--sun-border-w, 3px) * 4) var(--ring-4, transparent);
}

/* ===== Обводка СНАРУЖИ плитки (outside) — рамка вокруг плитки, фото не обрезается.
   Gap между плитками автоматически увеличивается так, чтобы между обводками
   соседей оставался чистый отступ = настройка gap. ===== */
.sun-has-borders.sun-borders-outside .sun-tile {
    z-index: 1;
}
.sun-has-borders.sun-borders-outside .sun-tile-rings .sun-tile-inner::after {
    box-shadow:
        0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent);
}
.sun-has-borders.sun-borders-outside .sun-tile-rings-2 .sun-tile-inner::after {
    box-shadow:
        0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent),
        0 0 0 calc(var(--sun-border-w, 3px) * 2) var(--ring-2, transparent);
}
.sun-has-borders.sun-borders-outside .sun-tile-rings-3 .sun-tile-inner::after {
    box-shadow:
        0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent),
        0 0 0 calc(var(--sun-border-w, 3px) * 2) var(--ring-2, transparent),
        0 0 0 calc(var(--sun-border-w, 3px) * 3) var(--ring-3, transparent);
}
.sun-has-borders.sun-borders-outside .sun-tile-rings-4 .sun-tile-inner::after {
    box-shadow:
        0 0 0 var(--sun-border-w, 3px) var(--ring-1, transparent),
        0 0 0 calc(var(--sun-border-w, 3px) * 2) var(--ring-2, transparent),
        0 0 0 calc(var(--sun-border-w, 3px) * 3) var(--ring-3, transparent),
        0 0 0 calc(var(--sun-border-w, 3px) * 4) var(--ring-4, transparent);
}

/* Для outside-режима: добавляем к gap двойную ширину обводок (по 4 кольца с каждой стороны
   = 8 толщин). Так между ВНЕШНИМИ кольцами соседних плиток остаётся ровно настройка gap. */
.sun-has-borders.sun-borders-outside .sun-grid {
    gap: calc(var(--sun-gap) + var(--sun-border-w, 3px) * 8);
}
.sun-grid-masonry.sun-has-borders.sun-borders-outside .sun-grid {
    column-gap: calc(var(--sun-gap) + var(--sun-border-w, 3px) * 8);
}
.sun-grid-masonry.sun-has-borders.sun-borders-outside .sun-tile {
    margin-bottom: calc(var(--sun-gap) + var(--sun-border-w, 3px) * 8);
}

@keyframes sun-tile-in {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.sun-tile.is-hidden {
    display: none;
}

.sun-tile-btn {
    appearance: none;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    width: 100%;
    height: 100%;
    cursor: pointer;
    display: block;
    /* НЕ overflow:hidden — иначе обводка снаружи плитки обрезается. */
    overflow: visible;
    /* Явный 0 чтобы Safari/Chrome не подставляли свои дефолтные углы button. */
    border-radius: 0;
    -webkit-tap-highlight-color: transparent;
}

.sun-tile img,
.sun-tile .sun-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: var(--sun-tile-radius);
    /* Принудительно отменяем эффекты сторонних lazy-загрузчиков. */
    opacity: 1 !important;
    filter: none !important;
    background-image: none !important;
}

/* Зум плитки целиком (фото + обводка + пилюли + оверлей) поверх соседних плиток.
   Активен когда у галереи класс sun-has-hover-zoom (настройка). */
.sun-has-hover-zoom .sun-tile {
    transition:
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.45s ease,
        /* z-index без перехода — мгновенно при hover, с задержкой при unhover чтобы не «утопало». */
        z-index 0s 0.5s;
    transform-origin: center;
    will-change: transform;
}

/* Боковые плитки зумятся в сторону центра экрана — не вылазят за края.
   data-mobile-col проставляется JS из расчёта col-индекса в текущей сетке. */
.sun-has-hover-zoom .sun-tile[data-mobile-col="first"] {
    transform-origin: 0% center;
}
.sun-has-hover-zoom .sun-tile[data-mobile-col="last"] {
    transform-origin: 100% center;
}

/* Белая «прокладка» вокруг плитки при hover, толщиной = расстоянию между плитками.
   Это отделяет увеличенную плитку от соседей если обводка цветными кольцами выключена. */
.sun-has-hover-zoom .sun-tile .sun-tile-inner {
    transition: box-shadow 0.45s ease;
}

@media (hover: hover) and (pointer: fine) {
    .sun-has-hover-zoom .sun-tile:hover,
    .sun-has-hover-zoom .sun-tile:focus-within {
        transform: scale(var(--sun-hover-scale, 1.2));
        z-index: 50;
        /* Тень переехала на inner (см. ниже), иначе прямоугольник под скруглённой плиткой. */
        transition:
            transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
            z-index 0s;
    }
    /* Изящная белая обводка + drop-shadow рисуются на inner (повторяют скругление). */
    .sun-has-hover-zoom .sun-tile:hover .sun-tile-inner,
    .sun-has-hover-zoom .sun-tile:focus-within .sun-tile-inner {
        box-shadow:
            0 0 0 var(--sun-gap) #fff,
            0 18px 48px rgba(0, 0, 0, 0.22);
    }
}

/* Touch-устройство: первый тап → плитка получает is-touched → зум и обводка как при hover.
   Второй тап → JS открывает фуллскрин. */
.sun-has-hover-zoom .sun-tile.is-touched {
    transform: scale(var(--sun-hover-scale, 1.2));
    z-index: 50;
    transition:
        transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        z-index 0s;
}
.sun-has-hover-zoom .sun-tile.is-touched .sun-tile-inner {
    box-shadow:
        0 0 0 var(--sun-gap) #fff,
        0 18px 48px rgba(0, 0, 0, 0.22);
}

/* WOW-оверлей с заголовком, разделителем и подписью.
   Каждый элемент разворачивается от центра наружу с задержкой (stagger).
   Сам контейнер фейдится и движется снизу вверх.
   Нижние углы скруглены по форме плитки, чтобы фон не торчал за обводкой. */
.sun-tile-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 22px 14px 14px;
    background: linear-gradient(to top,
        rgba(0,0,0,0.78) 0%,
        rgba(0,0,0,0.55) 55%,
        rgba(0,0,0,0) 100%);
    color: #fff;
    pointer-events: none;
    opacity: 0;
    transform: translateY(30%);
    transition:
        opacity 0.42s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    /* Скругление снизу — соответствует скруглению плитки. */
    border-bottom-left-radius: var(--sun-tile-radius);
    border-bottom-right-radius: var(--sun-tile-radius);
}

.sun-has-overlay .sun-tile:hover .sun-tile-overlay,
.sun-has-overlay .sun-tile:focus-within .sun-tile-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* Внутренний контейнер overlay — для marquee и full-cover режима. */
.sun-tile-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: center;
}

/* Заголовок — текст по центру плитки, до 3 строк, балансировка по словам. */
.sun-tile-overlay-title {
    /* Современные браузеры красиво распределяют слова по строкам. */
    text-wrap: balance;
    -webkit-hyphens: auto;
    hyphens: auto;
    /* Ограничение в 3 строки с многоточием в конце если не помещается. */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* Адаптивный размер шрифта — больше на больших плитках, меньше на мелких. */
    font-size: clamp(11px, 3.4vw, 15px);
    line-height: 1.25;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    transform: scaleX(0);
    transform-origin: center;
    opacity: 0;
    transition:
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.05s,
        opacity   0.45s ease 0.10s;
    letter-spacing: 0.01em;
    width: 100%;
}

/* Разделитель — линия, раздвигается от центра в стороны. */
.sun-tile-overlay-divider {
    width: 40%;
    max-width: 80px;
    height: 1px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
    transform: scaleX(0);
    transform-origin: center;
    opacity: 0;
    transition:
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.20s,
        opacity   0.35s ease 0.25s;
}

/* Подпись — тоже разворачивается из центра, но с большей задержкой. */
.sun-tile-overlay-desc {
    text-wrap: balance;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: clamp(10px, 2.8vw, 12px);
    line-height: 1.25;
    opacity: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    transform: scaleX(0);
    transform-origin: center;
    transition:
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.32s,
        opacity   0.45s ease 0.36s;
    width: 100%;
    font-style: italic;
}

/* Marquee удалён — текст помещается по центру плитки с line-clamp. */
.sun-marq { display: inline; }
.sun-marq-dup { display: none; }

/* Подсветка аккордеона удалена по запросу пользователя — оригинальное поведение темы. */

@media (max-width: 768px) {
    /* На мобильниках overflow:hidden на inner — самый надёжный клип в WebKit.
       Обводки на мобильнике inside (через box-shadow inset на ::after) — не обрезаются. */
    .sun-tile-inner {
        overflow: hidden;
    }
}

/* При hover/focus-внутри — раздвигаем всё. */
.sun-has-overlay .sun-tile:hover .sun-tile-overlay-title,
.sun-has-overlay .sun-tile:focus-within .sun-tile-overlay-title {
    transform: scaleX(1);
    opacity: 1;
}

.sun-has-overlay .sun-tile:hover .sun-tile-overlay-divider,
.sun-has-overlay .sun-tile:focus-within .sun-tile-overlay-divider {
    transform: scaleX(1);
    opacity: 1;
}

.sun-has-overlay .sun-tile:hover .sun-tile-overlay-desc,
.sun-has-overlay .sun-tile:focus-within .sun-tile-overlay-desc {
    transform: scaleX(1);
    opacity: 0.92;
}

/* ====== Full-cover overlay: занимает ВСЮ плитку (от верха до низа). ====== */
.sun-overlay-cover .sun-tile-overlay {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    /* Лёгкое затемнение чтобы текст читался, но фото оставалось видно. */
    background: linear-gradient(180deg, rgba(0,0,0,0.30), rgba(0,0,0,0.55)) !important;
    /* Скругление со всех сторон. */
    border-radius: var(--sun-tile-radius) !important;
    padding: 8px !important;
    /* Контент центрируется и заполняет всю плитку. */
    align-items: center !important;
    justify-content: center !important;
}
.sun-overlay-cover .sun-tile-overlay-inner {
    margin: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
}
.sun-overlay-cover .sun-tile-overlay-title {
    font-size: clamp(11px, 3.6cqi, 16px);
    /* До 5 строк если очень длинно. */
    -webkit-line-clamp: 5 !important;
}

.sun-tile-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--sun-muted);
    font-size: 12px;
    padding: 10px;
    text-align: center;
}

/* Иконка play на видео-плитке. */
.sun-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.2s ease;
}

.sun-tile:hover .sun-play-icon {
    background: rgba(0, 0, 0, 0.7);
    transform: translate(-50%, -50%) scale(1.08);
}

/* ---- Пилюли категорий поверх плитки ----
   Отступ внутрь плитки = ширина обводки (если есть) + 10px, чтобы пилюли
   не наезжали на цветную рамку. */
.sun-tile-pills {
    position: absolute;
    left: calc(var(--sun-border-w, 0px) + 10px);
    right: calc(var(--sun-border-w, 0px) + 10px);
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    z-index: 3;
    pointer-events: none;
}

.sun-pills-top .sun-tile-pills {
    top: calc(var(--sun-border-w, 0px) + 10px);
}

.sun-pills-bottom .sun-tile-pills {
    bottom: calc(var(--sun-border-w, 0px) + 10px);
    /* Когда снизу — выравнивание к правому краю, чтобы не пересекаться с overlay-описанием. */
    justify-content: flex-end;
}

/* Пилюли на плитке — точно в том же стиле что активные чипсы фильтров:
   полностью залиты цветом термина, без обводки. */
.sun-tile-pill {
    --pill-color: rgba(0, 0, 0, 0.55);
    --pill-text: #ffffff;
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    background: var(--pill-color);
    color: var(--pill-text);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    border-radius: var(--sun-chip-radius, 16px);
    border: none;
    /* Лёгкая тень — пилюля «парит» над фото. */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
}

.sun-tile-pill-name {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* Счётчик «сколько в группе». */
.sun-tile-count {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 10px;
    pointer-events: none;
    line-height: 1;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ----------- Пусто ----------- */
.sun-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--sun-muted);
    font-size: 15px;
}

/* ----------- Загрузить ещё ----------- */
.sun-load-more-wrap {
    display: flex;
    justify-content: center;
    padding: 20px 16px 4px;
}

.sun-load-more {
    appearance: none;
    border: 1.5px solid var(--sun-accent);
    background: transparent;
    color: var(--sun-accent);
    padding: 10px 28px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
    transition: background-color 0.22s ease, color 0.22s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.sun-load-more:hover {
    background: var(--sun-accent);
    color: #fff;
    transform: translateY(-1px);
}

.sun-load-more:active {
    transform: translateY(0) scale(0.97);
}

.sun-load-more[disabled] {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.sun-load-more-count {
    font-size: 12px;
    opacity: 0.7;
    font-weight: 400;
}

.sun-load-more.is-loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Скрытая плитка (для пагинации или фильтрации).
   Специфичность повышена чтобы перебить .sun-grid-square .sun-grid .sun-tile { display:block !important } выше. */
.sun-gallery.sun-grid-square .sun-grid .sun-tile[hidden],
.sun-gallery.sun-grid-square article.sun-tile[hidden],
.sun-gallery.sun-grid-masonry .sun-tile[hidden],
.sun-gallery .sun-tile[hidden],
.sun-gallery .sun-tile.sun-tile-hidden,
.sun-gallery .sun-tile.sun-tile-hidden-filter,
.sun-tile-hidden,
.sun-tile[hidden] {
    display: none !important;
}

/* ====================================================
   FULLSCREEN VIEWER (Фаза 6)
   ==================================================== */

body.sun-fs-open {
    overflow: hidden;
    /* position:fixed гарантирует что iOS Safari не скроллит страницу из-под фуллскрина. */
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
}

.sun-fs {
    position: fixed;
    inset: 0;
    z-index: 999999;
    color: #fff;
    font-family: inherit;
    opacity: 0;
    transition: opacity 0.26s ease;
}
.sun-fs.is-open { opacity: 1; }

.sun-fs-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 18, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Layout: на ПК — фото слева 70%, описание справа 30%. На мобильном — фото 60%, описание снизу. */
.sun-fs-layout {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

.sun-fs-stage {
    position: relative;
    flex: 1 1 70%;
    overflow: hidden;
    padding: 0;
}

.sun-fs-track {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* One-page scroll контейнер — вертикальный, с scroll-snap. */
.sun-fs-media-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    /* Touch-action: pan-y разрешает только вертикальный нативный scroll. */
    touch-action: pan-y;
    overscroll-behavior: contain;
    user-select: none;
    -webkit-user-select: none;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}
.sun-fs-media-wrap::-webkit-scrollbar { display: none; }

/* Каждый слайд — отдельная страница high=100% контейнера. */
.sun-fs-slide {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
}

.sun-fs-slide-inner {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--sun-tile-radius, 18px);
    overflow: hidden;
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.18),
        0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sun-fs-img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 80px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--sun-tile-radius, 18px);
    -webkit-user-drag: none;
}

.sun-fs-iframe {
    width: min(90vw, 1280px);
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: var(--sun-tile-radius, 18px);
    display: block;
}

/* Боковая панель с описанием. */
.sun-fs-side {
    flex: 0 0 320px;
    padding: 28px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(0, 0, 0, 0.2);
}

.sun-fs-title {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.25;
    margin: 0;
    color: #fff;
    letter-spacing: 0.01em;
}

.sun-fs-divider {
    width: 60px;
    height: 1px;
    background: rgba(255, 255, 255, 0.4);
    margin: 0;
}

.sun-fs-caption {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    font-style: italic;
}

.sun-fs-desc {
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
}

.sun-fs-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0;
}

.sun-fs-pill {
    --pill-color: rgba(255, 255, 255, 0.15);
    --pill-text: #fff;
    background: var(--pill-color);
    color: var(--pill-text);
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: opacity 0.18s ease;
}

.sun-fs-pill:hover {
    opacity: 0.85;
}

.sun-fs-cta {
    display: inline-block;
    margin-top: auto;
    padding: 12px 22px;
    background: #fff;
    color: #1a1a1a;
    text-decoration: none;
    text-align: center;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.18s ease;
}

.sun-fs-cta:hover {
    transform: translateY(-2px) scale(1.02);
    background: #f4f4f4;
}

.sun-fs-counter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    z-index: 2;
    pointer-events: none;
}

/* Кнопка закрытия. */
.sun-fs-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: background 0.18s ease, transform 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.sun-fs-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* Стрелки навигации. */
.sun-fs-nav {
    position: absolute;
    width: 48px;
    height: 48px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, transform 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

/* Атрибут [hidden] перекрывается display:flex выше — явно скрываем. */
.sun-fs-nav[hidden] {
    display: none !important;
}

/* WOW-анимация привлечения внимания к стрелке ↓ когда у кейса есть группа фото.
   Появление: всплытие + лёгкая пульсация 3 раза, потом успокаивается. */
.sun-fs-down.sun-fs-nav-wow {
    animation: sun-down-wow 1.6s ease 0.4s 2;
}

@keyframes sun-down-wow {
    0%   { transform: translateX(-50%) translateY(-6px) scale(0.7); opacity: 0; }
    25%  { transform: translateX(-50%) translateY(0)    scale(1.18); opacity: 1; background: rgba(255,255,255,0.32); }
    50%  { transform: translateX(-50%) translateY(8px)  scale(1);    opacity: 1; }
    75%  { transform: translateX(-50%) translateY(0)    scale(1.1);  opacity: 1; }
    100% { transform: translateX(-50%) translateY(0)    scale(1);    opacity: 1; }
}

.sun-fs-nav:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.08);
}

.sun-fs-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.sun-fs-prev:hover { transform: translateY(-50%) scale(1.08); }
.sun-fs-next { right: 20px; top: 50%; transform: translateY(-50%); }
.sun-fs-next:hover { transform: translateY(-50%) scale(1.08); }
.sun-fs-up   { top: 20px; left: 50%; transform: translateX(-50%); margin-top: 50px; }
.sun-fs-up:hover { transform: translateX(-50%) scale(1.08); }
.sun-fs-down { bottom: 20px; left: 50%; transform: translateX(-50%); }
.sun-fs-down:hover { transform: translateX(-50%) scale(1.08); }

/* На мобильном — layout вертикальный, описание под фото. */
@media (max-width: 768px) {
    .sun-fs-layout {
        flex-direction: column;
    }
    .sun-fs-stage {
        flex: 1 1 60vh;
        padding: 16px 12px;
    }
    .sun-fs-side {
        flex: 0 0 auto;
        max-height: 40vh;
        padding: 16px 16px 24px;
    }
    .sun-fs-title { font-size: 17px; }
    .sun-fs-caption { font-size: 13px; }
    .sun-fs-desc { font-size: 13px; }
    /* Стрелки видны и на мобильнике — для понимания что есть навигация. Меньше размером. */
    .sun-fs-prev, .sun-fs-next {
        width: 38px;
        height: 38px;
        font-size: 20px;
        background: rgba(255, 255, 255, 0.18);
    }
    .sun-fs-prev { left: 6px; }
    .sun-fs-next { right: 6px; }
    .sun-fs-img {
        max-height: 55vh;
    }
}

/* ====================================================
   Мобильная вёрстка — точка излома 768px (планшеты вниз).
   ==================================================== */
@media (max-width: 768px) {

    .sun-gallery {
        margin: 12px 0;
    }

    /* Пробивка боковых padding'ов темы — галерея растягивается на полную ширину экрана.
       100vw + отрицательные margin = занять всю ширину viewport независимо от родителя. */
    .sun-breakout-mobile {
        width: 100vw !important;
        max-width: 100vw !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
        position: relative;
        left: 0;
        right: 0;
    }

    .sun-gallery-title {
        font-size: 18px;
        padding: 0 12px;
        margin-bottom: 12px;
    }

    .sun-filters {
        padding: 0 12px;
    }

    .sun-filter-row {
        gap: 6px;
    }

    .sun-filter-label {
        min-width: auto;
        flex-basis: 100%;
        font-size: 12px;
        margin-bottom: 2px;
    }

    .sun-chip {
        font-size: 12px;
        padding: 5px 10px;
    }

    /* Колонки на мобильных — из настройки галереи.
       Боковые поля и gap — отдельные мобильные переменные.
       !important нужен чтобы перебить стили темы Eva (.wpb_wrapper и подобные). */
    .sun-gallery .sun-grid {
        grid-template-columns: repeat(var(--sun-cols-mobile, 3), 1fr) !important;
        gap: var(--sun-gap-mobile, var(--sun-gap, 4px)) !important;
        padding-left: var(--sun-edge-mobile, 12px);
        padding-right: var(--sun-edge-mobile, 12px);
    }
    .sun-grid-masonry .sun-grid {
        column-count: var(--sun-cols-mobile);
        column-gap: var(--sun-gap-mobile, var(--sun-gap));
        padding-left: var(--sun-edge-mobile, 12px);
        padding-right: var(--sun-edge-mobile, 12px);
    }
    .sun-grid-masonry .sun-tile {
        margin-bottom: var(--sun-gap-mobile, var(--sun-gap));
    }

    /* Если edge-to-edge включён — игнорирует setting, ставит 0. */
    .sun-gallery.sun-edge-to-edge-mobile .sun-grid {
        padding-left: 0;
        padding-right: 0;
    }

    /* Скрыть пилюли категорий на мобильных. */
    .sun-hide-pills-mobile .sun-tile-pills {
        display: none;
    }

    /* Отключить обводку на мобильных. */
    .sun-no-border-mobile .sun-tile-inner::after {
        box-shadow: none !important;
    }

    /* Переопределение толщины обводки на мобильных (multi-layer box-shadow по числу колец). */
    .sun-has-borders.sun-borders-inside .sun-tile-rings .sun-tile-inner::after {
        box-shadow:
            inset 0 0 0 var(--sun-border-w-mobile, var(--sun-border-w, 3px)) var(--ring-1, transparent);
    }
    .sun-has-borders.sun-borders-inside .sun-tile-rings-2 .sun-tile-inner::after {
        box-shadow:
            inset 0 0 0 var(--sun-border-w-mobile, var(--sun-border-w, 3px)) var(--ring-1, transparent),
            inset 0 0 0 calc(var(--sun-border-w-mobile, var(--sun-border-w, 3px)) * 2) var(--ring-2, transparent);
    }
    .sun-has-borders.sun-borders-inside .sun-tile-rings-3 .sun-tile-inner::after {
        box-shadow:
            inset 0 0 0 var(--sun-border-w-mobile, var(--sun-border-w, 3px)) var(--ring-1, transparent),
            inset 0 0 0 calc(var(--sun-border-w-mobile, var(--sun-border-w, 3px)) * 2) var(--ring-2, transparent),
            inset 0 0 0 calc(var(--sun-border-w-mobile, var(--sun-border-w, 3px)) * 3) var(--ring-3, transparent);
    }
    .sun-has-borders.sun-borders-outside .sun-tile-rings .sun-tile-inner::after {
        box-shadow: 0 0 0 var(--sun-border-w-mobile, var(--sun-border-w, 3px)) var(--ring-1, transparent);
    }
    .sun-has-borders.sun-borders-outside .sun-tile-rings-2 .sun-tile-inner::after {
        box-shadow:
            0 0 0 var(--sun-border-w-mobile, var(--sun-border-w, 3px)) var(--ring-1, transparent),
            0 0 0 calc(var(--sun-border-w-mobile, var(--sun-border-w, 3px)) * 2) var(--ring-2, transparent);
    }
    .sun-has-borders.sun-borders-outside .sun-tile-rings-3 .sun-tile-inner::after {
        box-shadow:
            0 0 0 var(--sun-border-w-mobile, var(--sun-border-w, 3px)) var(--ring-1, transparent),
            0 0 0 calc(var(--sun-border-w-mobile, var(--sun-border-w, 3px)) * 2) var(--ring-2, transparent),
            0 0 0 calc(var(--sun-border-w-mobile, var(--sun-border-w, 3px)) * 3) var(--ring-3, transparent);
    }

    /* Двойной тап: первый тап → плитка получает класс is-touched → overlay видим.
       Перебивает hover-стили: на тач-устройстве hover не работает,
       но JS вешает is-touched и стили совпадают с hover. */
    .sun-has-overlay .sun-tile.is-touched .sun-tile-overlay {
        opacity: 1;
        transform: translateY(0);
    }
    .sun-has-overlay .sun-tile.is-touched .sun-tile-overlay-title,
    .sun-has-overlay .sun-tile.is-touched .sun-tile-overlay-divider,
    .sun-has-overlay .sun-tile.is-touched .sun-tile-overlay-desc {
        transform: scaleX(1);
        opacity: 1;
    }

    /* На мобильнике hover не имеет смысла — снимаем scale. */
    .sun-tile:hover .sun-tile-inner img {
        transform: none;
    }

    /* На мобильниках оверлей описания постоянно виден лаконично (без hover). */
    .sun-has-overlay .sun-tile-overlay {
        opacity: 1;
        transform: translateY(0);
        padding: 10px 8px 6px;
        background: linear-gradient(to top,
            rgba(0,0,0,0.7) 0%,
            rgba(0,0,0,0) 100%);
    }

    .sun-tile-overlay {
        padding: 12px 8px 6px;
        background: linear-gradient(to top,
            rgba(0,0,0,0.72) 0%,
            rgba(0,0,0,0) 100%);
        gap: 4px;
    }

    .sun-tile-overlay-title {
        font-size: 11px;
        -webkit-line-clamp: 1;
        font-weight: 600;
    }

    .sun-tile-overlay-divider {
        max-width: 40px;
    }

    .sun-tile-overlay-desc {
        font-size: 10px;
        -webkit-line-clamp: 1;
    }

    /* На мобильных overlay по умолчанию виден (без hover). */
    .sun-has-overlay .sun-tile-overlay {
        opacity: 1;
        transform: translateY(0);
    }
    .sun-has-overlay .sun-tile-overlay-title,
    .sun-has-overlay .sun-tile-overlay-divider,
    .sun-has-overlay .sun-tile-overlay-desc {
        transform: scaleX(1);
        opacity: 1;
    }

    /* НО: если включён режим «двойной тап на мобильных» — overlay скрыт
       до первого тапа (показывается через .is-touched). */
    .sun-tap-overlay.sun-has-overlay .sun-tile:not(.is-touched) .sun-tile-overlay {
        opacity: 0;
        transform: translateY(30%);
    }
    .sun-tap-overlay.sun-has-overlay .sun-tile:not(.is-touched) .sun-tile-overlay-title,
    .sun-tap-overlay.sun-has-overlay .sun-tile:not(.is-touched) .sun-tile-overlay-divider,
    .sun-tap-overlay.sun-has-overlay .sun-tile:not(.is-touched) .sun-tile-overlay-desc {
        transform: scaleX(0);
        opacity: 0;
    }

    /* На мобильниках режим «только точки» — пилюля превращается в маленький круг. */
    .sun-pills-mobile-dots .sun-tile-pill {
        width: 12px;
        height: 12px;
        padding: 0;
        border-radius: 50%;
        overflow: hidden;
        border-color: rgba(255, 255, 255, 0.35);
    }

    .sun-pills-mobile-dots .sun-tile-pill-name {
        display: none;
    }
}

/* ====================================================
   Уменьшенные эффекты для пользователей с reduced motion.
   ==================================================== */
@media (prefers-reduced-motion: reduce) {
    .sun-tile {
        animation: none;
    }
    .sun-tile img,
    .sun-chip,
    .sun-play-icon {
        transition: none;
    }
}
