/* ══════════════════════════════════════════════════════════════════
   产品图放大器
   配套 assets/js/gallery-zoom.js；PC 与移动端产品详情页共用。
   独立成文件而不是塞进 global.css：只有 products/show.html 需要，
   避免改动全站样式的缓存版本号。
   ══════════════════════════════════════════════════════════════════ */

/* ── 图区容器 ────────────────────────────────────────────────────── */

/* position: relative 是角标定位和放大基准的必要条件：
   JS 用 offsetLeft/offsetTop 反算鼠标落在图片上的百分比位置，
   这组值只有在容器当上 offsetParent 时才是相对容器的坐标。
   PC 模板本来就有 Tailwind 的 relative，移动端没有，统一在这里给。 */
.rl-zoom-stage {
    position: relative;
    touch-action: manipulation;
}

.rl-zoom-stage #main-preview {
    -webkit-user-drag: none;
    user-select: none;
}

/* 悬停相关样式只在真有指针设备时启用：
   触屏上 :hover 会「粘住」，滑过图片就卡在某个状态，反而碍事。 */
@media (hover: hover) and (pointer: fine) {
    .rl-zoom-stage {
        cursor: default;
    }

    .rl-zoom-stage #main-preview {
        transform-origin: 50% 50%;
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    }

    /* 放大后鼠标移动要跟手，.28s 缓动会让画面追着指针跑，手感发飘 */
    .rl-zoom-stage.is-zooming #main-preview {
        transition: transform .09s linear;
        will-change: transform;
    }

    /* 图标平时不出现，鼠标进图区才浮出来，不压产品 */
    .rl-zoom-stage:hover .rl-zoom-badge {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }
}

/* 右上角的放大按钮：点击才放大，不自动放大。
   放大状态下一律常显——此时鼠标可能已经移出图区，
   用户需要看得到「怎么退回去」。 */
.rl-zoom-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    color: #111418;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .16);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, background .18s ease, color .18s ease;
}

.rl-zoom-badge:hover {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .22);
}

.rl-zoom-badge:focus-visible {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    outline: 2px solid #111418;
    outline-offset: 2px;
}

.rl-zoom-badge .material-symbols-outlined {
    font-size: 19px;
    line-height: 1;
    pointer-events: none;
}

/* 放大中：图标转深色实底，变成「缩小」语义 */
.rl-zoom-stage.is-zooming .rl-zoom-badge {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    background: #111418;
    color: #fff;
}

.rl-zoom-stage.is-zooming .rl-zoom-badge:hover {
    background: #000;
}

/* 触屏没有 hover，图标常显 */
@media (hover: none) {
    .rl-zoom-badge {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }
}

/* ── 全屏灯箱 ────────────────────────────────────────────────────── */

html.rl-lb-open {
    overflow: hidden;
}

.rl-lb {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 20, 24, .94);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility 0s linear .2s;
}

.rl-lb.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity .2s ease, visibility 0s;
}

.rl-lb__stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 56px 72px;
}

.rl-lb__img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
    cursor: zoom-in;
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: 50% 50%;
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}

/* 放大态要关掉过渡，否则拖动时画面会「追」指针，明显滞后 */
.rl-lb.is-zoomed .rl-lb__img {
    cursor: grab;
    transition: none;
}

.rl-lb.is-zoomed .rl-lb__img:active {
    cursor: grabbing;
}

/* 翻页 / 关闭按钮 */

.rl-lb__close,
.rl-lb__nav {
    position: absolute;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
}

.rl-lb__close:hover,
.rl-lb__nav:hover {
    background: rgba(255, 255, 255, .26);
}

.rl-lb__close {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
}

.rl-lb__nav {
    top: 50%;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    font-size: 15px;
}

.rl-lb__nav--prev {
    left: 16px;
}

.rl-lb__nav--next {
    right: 16px;
}

/* 只有一张图时不显示左右箭头 */
.rl-lb.is-single .rl-lb__nav {
    display: none;
}

/* 底部计数与提示 */

.rl-lb__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 16px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, .62);
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: .02em;
    pointer-events: none;
}

.rl-lb__count {
    font-weight: 600;
    color: #fff;
}

/* ── 移动端 ──────────────────────────────────────────────────────── */

@media (max-width: 767px) {
    .rl-lb__stage {
        padding: 52px 10px;
    }

    .rl-lb__close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
        font-size: 22px;
    }

    .rl-lb__nav {
        width: 34px;
        height: 34px;
        margin-top: -17px;
        font-size: 13px;
        background: rgba(255, 255, 255, .16);
    }

    .rl-lb__nav--prev {
        left: 4px;
    }

    .rl-lb__nav--next {
        right: 4px;
    }

    .rl-lb__bar {
        bottom: 12px;
    }
}
