/* ============================================================
   Supreme 图片灯箱（lightbox）
   风格：参照子比（Zibll）主题灯箱 —— 顶部玻璃工具栏（计数 / 下载图片 /
         查看更多图片 / 切换图片缩放 / 切换全屏 / 播放图片 / 关闭）
         + 左右圆形切换 + 底部图注；支持缩放、全屏、自动轮播、移动端手势。
   零依赖、纯原生实现；须于 style.css 之后加载以复用 --theme 等变量。
   ============================================================ */

.supreme-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
    /* 移动端：禁用浏览器默认手势（下拉刷新 / 双指缩放 / 滑动返回） */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.supreme-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

/* 深色模糊遮罩 */
.supreme-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, .92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* ====== 顶部玻璃工具栏 ====== */
.supreme-lightbox__topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(17, 24, 39, .35);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

/* 计数（第几张 / 共几张）— 主题色强调 */
.supreme-lightbox__counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    flex-shrink: 0;
}

.supreme-lightbox__counter .sep {
    opacity: .5;
    font-weight: 400;
}

.supreme-lightbox__counter .total {
    color: var(--theme, #3b82f6);
}

/* 右侧操作按钮组（支持横向滚动以适配移动端多按钮） */
.supreme-lightbox__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
    max-width: 72vw;
    /* 允许按钮组自身横向滚动（root 已 touch-action:none） */
    touch-action: pan-x;
}

.supreme-lightbox__actions::-webkit-scrollbar {
    display: none;
}

.supreme-lightbox__action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: rgba(255, 255, 255, .1);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background .2s ease, transform .15s ease;
    flex-shrink: 0;
}

.supreme-lightbox__action:hover {
    background: rgba(255, 255, 255, .22);
}

.supreme-lightbox__action:active {
    transform: scale(.92);
}

.supreme-lightbox__action:focus-visible {
    outline: 2px solid var(--theme, #3b82f6);
    outline-offset: 2px;
}

.supreme-lightbox__action.is-active {
    background: var(--theme, #3b82f6);
    color: #fff;
}

.supreme-lightbox__action svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
    /* 实心图标略小一档保持视觉平衡 */
    transform: scale(.95);
}

/* ====== 图片舞台 ====== */
.supreme-lightbox__stage {
    position: relative;
    z-index: 2;
    max-width: 92vw;
    max-height: 88vh;
    margin-top: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}

.supreme-lightbox__img {
    max-width: 92vw;
    max-height: calc(88vh - 56px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
    background: rgba(255, 255, 255, .04);
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    opacity: 0;
    transition: opacity .25s ease, transform .3s ease;
    transform-origin: center center;
    touch-action: none;
}

/* ====== 左右圆形切换按钮（玻璃质感，悬浮） ====== */
.supreme-lightbox__nav {
    position: absolute;
    z-index: 3;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: rgba(255, 255, 255, .12);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background .2s ease, transform .15s ease;
    touch-action: manipulation;
}

.supreme-lightbox__nav:hover {
    background: rgba(255, 255, 255, .26);
}

.supreme-lightbox__nav:active {
    transform: translateY(-50%) scale(.92);
}

.supreme-lightbox__nav:focus-visible {
    outline: 2px solid var(--theme, #3b82f6);
    outline-offset: 2px;
}

.supreme-lightbox__nav svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
    /* 实心图标视觉占位略大，缩小一档保持平衡 */
    transform: scale(.9);
}

.supreme-lightbox__prev {
    left: 18px;
}

.supreme-lightbox__next {
    right: 18px;
}

/* ====== 底部图注 ====== */
.supreme-lightbox__caption {
    position: absolute;
    z-index: 3;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 88vw;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(17, 24, 39, .7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}

/* ====== 缩略图网格抽屉 ====== */
.supreme-lightbox__grid {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    padding: 16px;
    background: rgba(17, 24, 39, .95);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, .08);
    transform: translateY(100%);
    transition: transform .3s ease;
    max-height: 32vh;
    overflow-y: auto;
    touch-action: pan-y;
}

.supreme-lightbox__grid.is-open {
    transform: translateY(0);
}

.supreme-lightbox__grid-title {
    color: rgba(255, 255, 255, .6);
    font-size: 12px;
    font-weight: 500;
    margin: 0 0 10px;
    text-align: center;
    letter-spacing: .05em;
}

.supreme-lightbox__grid-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.supreme-lightbox__grid-item {
    width: 84px;
    height: 84px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: .55;
    background: rgba(255, 255, 255, .04);
    transition: opacity .2s ease, border-color .2s ease, transform .2s ease;
    touch-action: manipulation;
}

.supreme-lightbox__grid-item:hover {
    opacity: 1;
    transform: translateY(-2px);
}

.supreme-lightbox__grid-item.is-active {
    border-color: var(--theme, #3b82f6);
    opacity: 1;
}

.supreme-lightbox__grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 打开时锁定页面滚动（移动端一并禁用橡皮筋） */
body.lb-open {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

/* ====== 全屏模式：图片撑满视口 ====== */
.supreme-lightbox.is-fullscreen .supreme-lightbox__stage {
    max-width: 100vw;
    max-height: 100vh;
    margin-top: 0;
}

.supreme-lightbox.is-fullscreen .supreme-lightbox__img {
    max-width: 96vw;
    max-height: 92vh;
}

/* ====== 移动端适配 ====== */
@media (max-width: 640px) {
    .supreme-lightbox__topbar {
        padding: 10px 10px;
        gap: 6px;
    }

    .supreme-lightbox__counter {
        padding: 4px 10px;
        font-size: 12px;
        gap: 4px;
    }

    /* 移动端按钮加大到 44px 触控友好尺寸 */
    .supreme-lightbox__action {
        width: 44px;
        height: 44px;
    }

    .supreme-lightbox__action svg {
        width: 22px;
        height: 22px;
    }

    .supreme-lightbox__actions {
        max-width: none;
        gap: 6px;
    }

    .supreme-lightbox__stage {
        max-width: 96vw;
        max-height: 82vh;
        margin-top: 60px;
    }

    .supreme-lightbox__img {
        max-width: 96vw;
        max-height: calc(82vh - 60px);
    }

    /* 移动端切换钮更贴近边缘、更大 */
    .supreme-lightbox__nav {
        width: 48px;
        height: 48px;
    }

    .supreme-lightbox__nav svg {
        width: 24px;
        height: 24px;
    }

    .supreme-lightbox__prev {
        left: 8px;
    }

    .supreme-lightbox__next {
        right: 8px;
    }

    .supreme-lightbox__caption {
        bottom: 14px;
        font-size: 13px;
        padding: 7px 14px;
        max-width: 92vw;
    }

    .supreme-lightbox__grid {
        max-height: 42vh;
        padding: 12px;
    }

    .supreme-lightbox__grid-item {
        width: 72px;
        height: 72px;
    }
}

/* ====== 尊重「减少动态效果」系统偏好 ====== */
@media (prefers-reduced-motion: reduce) {
    .supreme-lightbox,
    .supreme-lightbox__img,
    .supreme-lightbox__action,
    .supreme-lightbox__nav,
    .supreme-lightbox__grid {
        transition: none;
    }
}
