/* =========================================
   产品详情页图片查看器 (ShuQi Image Viewer)
   无依赖，供 PC / 移动端产品详情页共用
   ========================================= */

/* 点击型图片的手型提示 */
.product img {
    cursor: zoom-in;
}

/* 遮罩层 */
.sqiv-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
}

.sqiv-overlay[hidden] {
    display: none;
}

.sqiv-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 18, 26, .93);
    opacity: 0;
    transition: opacity .3s ease;
}

.sqiv-overlay.sqiv-open .sqiv-backdrop {
    opacity: 1;
}

/* 舞台：负责居中展示与手势区域 */
.sqiv-stage {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none; /* 手势全权接管，禁用浏览器默认缩放/滚动 */
}

/* 大图 */
.sqiv-img {
    max-width: none;
    opacity: 0;
    transform-origin: center center;
    transition: transform .35s cubic-bezier(.25, .8, .3, 1), opacity .25s ease;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
    cursor: zoom-in;
}

.sqiv-img.sqiv-loaded {
    opacity: 1;
}

.sqiv-img.sqiv-zoomed {
    cursor: move;
}

/* 拖拽/手势进行中：关闭过渡，保证跟手 */
.sqiv-img.sqiv-dragging {
    transition: none;
}

/* 加载中 spinner */
.sqiv-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sqiv-spin .8s linear infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.sqiv-overlay.sqiv-loading .sqiv-spinner {
    opacity: 1;
}

@keyframes sqiv-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 加载失败提示 */
.sqiv-error {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 14px;
    background: rgba(255, 255, 255, .12);
    padding: 12px 24px;
    border-radius: 6px;
    display: none;
    pointer-events: none;
    white-space: nowrap;
}

.sqiv-overlay.sqiv-error-show .sqiv-error {
    display: block;
}

/* 操作按钮 */
.sqiv-btn {
    position: absolute;
    z-index: 2;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 30px;
    line-height: 48px;
    font-family: Arial, sans-serif;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .3s ease, background .2s ease;
}

.sqiv-overlay.sqiv-open .sqiv-btn {
    opacity: 1;
}

.sqiv-btn:hover {
    background: rgba(255, 255, 255, .3);
}

.sqiv-btn[hidden] {
    display: none;
}

.sqiv-close {
    top: 20px;
    right: 20px;
}

.sqiv-prev {
    left: 16px;
    top: 50%;
    margin-top: -24px;
}

.sqiv-next {
    right: 16px;
    top: 50%;
    margin-top: -24px;
}

/* 序号与标题 */
.sqiv-counter {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, .85);
    font-size: 13px;
    letter-spacing: 1px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s ease;
}

.sqiv-overlay.sqiv-open .sqiv-counter {
    opacity: 1;
}

.sqiv-caption {
    position: absolute;
    left: 50%;
    bottom: 44px;
    transform: translateX(-50%);
    max-width: 70vw;
    color: #fff;
    font-size: 14px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s ease;
}

.sqiv-overlay.sqiv-open .sqiv-caption.sqiv-has-title {
    opacity: 1;
}

/* 锁定页面滚动 */
body.sqiv-no-scroll {
    overflow: hidden;
}

/* 移动端适配 */
@media (max-width: 640px) {
    .sqiv-btn {
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 24px;
    }

    .sqiv-close {
        top: calc(10px + env(safe-area-inset-top, 0px));
        right: 10px;
    }

    .sqiv-prev {
        left: 6px;
    }

    .sqiv-next {
        right: 6px;
    }

    .sqiv-counter {
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .sqiv-caption {
        bottom: calc(40px + env(safe-area-inset-bottom, 0px));
        max-width: 80vw;
        font-size: 13px;
    }
}
