/**
 * =========================================================
 * SUNIVA Experience Engine
 * Gallery Styles v1.0.0
 *
 * 配置先
 * /html/assets/css/suniva/gallery.css
 * =========================================================
 */


/* =========================================================
   Gallery起動要素
   ========================================================= */

[data-suniva-gallery] {
    position: relative;
    display: block;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius:
        var(--suniva-radius-medium, 22px);
    background:
        var(--suniva-ivory, #faf7f1);
    box-shadow:
        var(
            --suniva-shadow-soft,
            0 12px 36px rgba(64, 48, 35, 0.08)
        );
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

[data-suniva-gallery] img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition:
        filter 600ms ease,
        transform 900ms
            cubic-bezier(0.22, 1, 0.36, 1);
}

[data-suniva-gallery]::before {
    position: absolute;
    z-index: 1;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
        linear-gradient(
            180deg,
            transparent 55%,
            rgba(18, 14, 11, 0.4)
        );
    opacity: 0;
    transition: opacity 350ms ease;
}

[data-suniva-gallery]::after {
    position: absolute;
    z-index: 2;
    right: 18px;
    bottom: 18px;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    content: "＋";
    border:
        1px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    color: #ffffff;
    background:
        rgba(22, 18, 15, 0.44);
    box-shadow:
        0 10px 26px rgba(0, 0, 0, 0.16);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    font-size: 23px;
    font-weight: 300;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition:
        opacity 350ms ease,
        transform 350ms ease,
        background-color 350ms ease;
}

[data-suniva-gallery]:hover::before,
[data-suniva-gallery]:hover::after,
[data-suniva-gallery]:focus-visible::before,
[data-suniva-gallery]:focus-visible::after {
    opacity: 1;
}

[data-suniva-gallery]:hover::after,
[data-suniva-gallery]:focus-visible::after {
    transform: translateY(0);
}

[data-suniva-gallery]:hover img {
    filter: saturate(1.04);
    transform: scale(1.035);
}

[data-suniva-gallery]:focus-visible {
    outline:
        3px solid rgba(199, 163, 106, 0.6);
    outline-offset: 4px;
}


/* =========================================================
   Viewer全体
   ========================================================= */

.suniva-gallery-viewer {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: grid;
    place-items: center;
    color: #ffffff;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 350ms ease,
        visibility 350ms ease;
    isolation: isolate;
}

.suniva-gallery-viewer[hidden] {
    display: none;
}

.suniva-gallery-viewer.is-open {
    opacity: 1;
    visibility: visible;
}

.suniva-gallery-backdrop {
    position: absolute;
    z-index: -1;
    inset: 0;
    background:
        radial-gradient(
            circle at 50% 35%,
            rgba(45, 38, 33, 0.97),
            rgba(10, 8, 7, 0.99) 72%
        );
    cursor: zoom-out;
}

.suniva-gallery-backdrop::after {
    position: absolute;
    inset: 0;
    content: "";
    pointer-events: none;
    background:
        radial-gradient(
            circle at center,
            transparent 30%,
            rgba(0, 0, 0, 0.22)
        );
}


/* =========================================================
   Stage
   ========================================================= */

.suniva-gallery-stage {
    position: relative;
    display: grid;
    width: min(92vw, 1500px);
    height: min(90vh, 980px);
    grid-template-rows:
        minmax(0, 1fr) auto auto;
    gap: 18px;
    padding:
        max(28px, env(safe-area-inset-top))
        clamp(22px, 4vw, 64px)
        max(24px, env(safe-area-inset-bottom));
    user-select: none;
    touch-action: pan-y;
}

.suniva-gallery-media {
    position: relative;
    display: grid;
    min-width: 0;
    min-height: 0;
    place-items: center;
    overflow: hidden;
    border-radius:
        var(--suniva-radius-medium, 22px);
}

.suniva-gallery-image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    border-radius:
        var(--suniva-radius-small, 12px);
    box-shadow:
        0 30px 100px rgba(0, 0, 0, 0.4);
    object-fit: contain;
    opacity: 0;
    transform: scale(0.985);
    transition:
        opacity 450ms ease,
        transform 650ms
            cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-user-drag: none;
    will-change: opacity, transform;
}

.suniva-gallery-image.is-loaded {
    opacity: 1;
    transform: scale(1);
}

.suniva-gallery-image.is-moving-next {
    transform: translateX(20px) scale(0.985);
}

.suniva-gallery-image.is-moving-prev {
    transform: translateX(-20px) scale(0.985);
}

.suniva-gallery-image.is-error {
    width: min(620px, 80vw);
    min-height: 320px;
    opacity: 0.35;
    background:
        linear-gradient(
            135deg,
            #302a26,
            #181513
        );
}


/* =========================================================
   Loading
   ========================================================= */

.suniva-gallery-loading {
    position: absolute;
    z-index: 3;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
}

.suniva-gallery-loading[hidden] {
    display: none;
}

.suniva-gallery-loading span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background:
        var(--suniva-gold-light, #e6d3ad);
    animation:
        sunivaGalleryLoading 1.2s
        ease-in-out infinite;
}

.suniva-gallery-loading
    span:nth-child(2) {
    animation-delay: 120ms;
}

.suniva-gallery-loading
    span:nth-child(3) {
    animation-delay: 240ms;
}

@keyframes sunivaGalleryLoading {
    0%,
    60%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-7px);
    }
}


/* =========================================================
   タイトル・キャプション
   ========================================================= */

.suniva-gallery-information {
    width: min(100%, 900px);
    margin-inline: auto;
    text-align: center;
}

.suniva-gallery-title {
    margin: 0;
    color: #ffffff;
    font-size:
        clamp(18px, 2.5vw, 30px);
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.suniva-gallery-caption {
    margin: 8px auto 0;
    color:
        rgba(255, 255, 255, 0.72);
    font-size:
        clamp(12px, 1.4vw, 15px);
    line-height: 1.8;
}

.suniva-gallery-counter {
    margin-top: 10px;
    color:
        rgba(255, 255, 255, 0.55);
    font-size: 11px;
    font-variant-numeric:
        tabular-nums;
    letter-spacing: 0.16em;
}


/* =========================================================
   閉じるボタン
   ========================================================= */

.suniva-gallery-close {
    position: fixed;
    z-index: 4;
    top:
        max(18px, env(safe-area-inset-top));
    right:
        max(18px, env(safe-area-inset-right));
    display: grid;
    width: 48px;
    height: 48px;
    padding: 0;
    place-items: center;
    border:
        1px solid rgba(255, 255, 255, 0.26);
    border-radius: 50%;
    color: #ffffff;
    background:
        rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    cursor: pointer;
    font-size: 31px;
    font-weight: 200;
    line-height: 1;
    transition:
        background-color 250ms ease,
        border-color 250ms ease,
        transform 250ms ease;
}

.suniva-gallery-close:hover {
    border-color:
        rgba(255, 255, 255, 0.55);
    background:
        rgba(255, 255, 255, 0.16);
    transform: rotate(6deg);
}

.suniva-gallery-close:focus-visible {
    outline:
        3px solid rgba(230, 211, 173, 0.55);
    outline-offset: 4px;
}


/* =========================================================
   前後ナビゲーション
   ========================================================= */

.suniva-gallery-nav {
    position: fixed;
    z-index: 4;
    top: 50%;
    display: grid;
    width: 58px;
    height: 58px;
    padding: 0;
    place-items: center;
    border:
        1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #ffffff;
    background:
        rgba(255, 255, 255, 0.07);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    cursor: pointer;
    font-size: 42px;
    font-weight: 200;
    line-height: 1;
    transform: translateY(-50%);
    transition:
        opacity 250ms ease,
        background-color 250ms ease,
        border-color 250ms ease,
        transform 250ms ease;
}

.suniva-gallery-prev {
    left:
        max(18px, env(safe-area-inset-left));
}

.suniva-gallery-next {
    right:
        max(18px, env(safe-area-inset-right));
}

.suniva-gallery-nav:hover {
    border-color:
        rgba(255, 255, 255, 0.5);
    background:
        rgba(255, 255, 255, 0.15);
}

.suniva-gallery-prev:hover {
    transform:
        translateY(-50%)
        translateX(-3px);
}

.suniva-gallery-next:hover {
    transform:
        translateY(-50%)
        translateX(3px);
}

.suniva-gallery-nav:disabled {
    pointer-events: none;
    opacity: 0.18;
}

.suniva-gallery-nav[hidden] {
    display: none;
}


/* =========================================================
   サムネイル
   ========================================================= */

.suniva-gallery-thumbnails {
    display: flex;
    width: min(100%, 780px);
    min-height: 58px;
    align-items: center;
    gap: 9px;
    margin-inline: auto;
    padding: 4px;
    overflow-x: auto;
    overscroll-behavior-inline:
        contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
}

.suniva-gallery-thumbnails::-webkit-scrollbar {
    display: none;
}

.suniva-gallery-thumbnails[hidden] {
    display: none;
}

.suniva-gallery-thumbnail {
    position: relative;
    flex: 0 0 58px;
    width: 58px;
    height: 44px;
    padding: 0;
    overflow: hidden;
    border:
        1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: #181513;
    cursor: pointer;
    opacity: 0.42;
    scroll-snap-align: center;
    transition:
        opacity 250ms ease,
        border-color 250ms ease,
        transform 250ms ease;
}

.suniva-gallery-thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.suniva-gallery-thumbnail:hover {
    opacity: 0.78;
    transform: translateY(-2px);
}

.suniva-gallery-thumbnail.is-active {
    border-color:
        var(--suniva-gold-light, #e6d3ad);
    opacity: 1;
    transform: translateY(-2px);
}

.suniva-gallery-thumbnail:focus-visible {
    outline:
        2px solid
        var(--suniva-gold-light, #e6d3ad);
    outline-offset: 2px;
}


/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 1024px) {
    .suniva-gallery-stage {
        width: 100vw;
        height: 100svh;
        padding:
            max(70px, env(safe-area-inset-top))
            74px
            max(18px, env(safe-area-inset-bottom));
    }

    .suniva-gallery-nav {
        width: 48px;
        height: 48px;
        font-size: 34px;
    }

    .suniva-gallery-prev {
        left: 12px;
    }

    .suniva-gallery-next {
        right: 12px;
    }
}


/* =========================================================
   Smartphone
   ========================================================= */

@media (max-width: 767px) {
    [data-suniva-gallery]::before,
    [data-suniva-gallery]::after {
        opacity: 1;
    }

    [data-suniva-gallery]::after {
        right: 12px;
        bottom: 12px;
        width: 38px;
        height: 38px;
        font-size: 20px;
        transform: none;
    }

    .suniva-gallery-stage {
        width: 100vw;
        height: 100svh;
        grid-template-rows:
            minmax(0, 1fr) auto auto;
        gap: 11px;
        padding:
            max(
                66px,
                env(safe-area-inset-top)
            )
            14px
            max(
                12px,
                env(safe-area-inset-bottom)
            );
    }

    .suniva-gallery-media {
        border-radius: 10px;
    }

    .suniva-gallery-image {
        max-width: 100%;
        max-height: 100%;
        border-radius: 7px;
    }

    .suniva-gallery-information {
        padding-inline: 8px;
    }

    .suniva-gallery-title {
        font-size: 17px;
    }

    .suniva-gallery-caption {
        display: -webkit-box;
        margin-top: 5px;
        overflow: hidden;
        font-size: 12px;
        line-height: 1.6;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .suniva-gallery-counter {
        margin-top: 5px;
        font-size: 10px;
    }

    .suniva-gallery-close {
        top:
            max(
                10px,
                env(safe-area-inset-top)
            );
        right:
            max(
                10px,
                env(safe-area-inset-right)
            );
        width: 44px;
        height: 44px;
        font-size: 27px;
    }

    .suniva-gallery-nav {
        top: auto;
        bottom:
            max(
                74px,
                calc(
                    env(safe-area-inset-bottom)
                    + 64px
                )
            );
        width: 42px;
        height: 42px;
        font-size: 30px;
        transform: none;
    }

    .suniva-gallery-prev {
        left: 14px;
    }

    .suniva-gallery-next {
        right: 14px;
    }

    .suniva-gallery-prev:hover,
    .suniva-gallery-next:hover {
        transform: none;
    }

    .suniva-gallery-thumbnails {
        min-height: 48px;
        gap: 7px;
    }

    .suniva-gallery-thumbnail {
        flex-basis: 48px;
        width: 48px;
        height: 36px;
        border-radius: 6px;
    }
}


/* =========================================================
   横向きスマートフォン
   ========================================================= */

@media (
    max-height: 520px
) and (
    orientation: landscape
) {
    .suniva-gallery-stage {
        grid-template-columns:
            minmax(0, 1fr) 180px;
        grid-template-rows:
            minmax(0, 1fr) auto;
        gap: 12px;
        padding:
            14px 76px 14px 18px;
    }

    .suniva-gallery-media {
        grid-row: 1 / 3;
    }

    .suniva-gallery-information {
        align-self: end;
        text-align: left;
    }

    .suniva-gallery-thumbnails {
        width: 180px;
        align-self: start;
        flex-wrap: wrap;
        justify-content: flex-start;
        overflow-y: auto;
    }

    .suniva-gallery-close {
        top: 10px;
        right: 10px;
    }

    .suniva-gallery-nav {
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }
}


/* =========================================================
   Reduced Motion
   ========================================================= */

@media (
    prefers-reduced-motion: reduce
) {
    [data-suniva-gallery] img,
    .suniva-gallery-viewer,
    .suniva-gallery-image,
    .suniva-gallery-nav,
    .suniva-gallery-close,
    .suniva-gallery-thumbnail {
        transition-duration: 0.01ms;
    }

    .suniva-gallery-loading span {
        animation: none;
    }
}