/* ============================================================
   YY MALL — 商品图片预览（左右箭头 + 缩略图条 + 大图灯箱）
   依赖 style.css 中的 :root 设计令牌；仅商品详情页加载

   列宽策略：
     单图商品 → 沿用主题原本的 460px，主图尺寸与改动前完全一致
     多图商品 → 加宽到 540px，左右各留 40px 内边距放翻页箭头
   ============================================================ */

/* ---- 外层列：把视觉重心交给图库内部的舞台 ---- */
.yy-detail-image {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
}
.yy-detail-image.yy-has-multi { width: 540px; }

.yy-gallery {
    position: relative;
    width: 100%;
}

/* ---- 主图舞台 ---- */
.yy-gallery-stage {
    position: relative;
    padding: 0;
}

.yy-gallery-slide {
    display: none;
    margin: 0;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-soft);
    box-shadow: var(--shadow-sm);
    cursor: zoom-in;
}

.yy-gallery-slide.is-active { display: block; }

/* 用 contain：竖图（如 9:16 截图）和横图都完整可见，绝不裁掉商品细节 */
.yy-detail-image .yy-gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* 仅多图商品：两侧留出内边距，箭头落在这段留白里 */
.yy-detail-image.yy-has-multi .yy-gallery-stage,
.yy-detail-image.yy-has-multi .yy-gallery-thumbs {
    padding: 0 40px;
}

/* ---- 左右翻页箭头 ---- */
.yy-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--sage-dark);
    cursor: pointer;
    z-index: 3;
    transition: var(--transition);
}
.yy-gallery-prev { left: 0; }
.yy-gallery-next { right: 0; }
.yy-gallery-arrow svg { width: 18px; height: 18px; }
.yy-gallery-arrow:hover {
    background: var(--sage);
    border-color: var(--sage);
    color: #fff;
}
.yy-gallery-arrow:focus-visible {
    outline: 2px solid var(--sage-light);
    outline-offset: 2px;
}

/* ---- 角标计数 ---- */
.yy-gallery-counter {
    position: absolute;
    right: 12px;
    bottom: 14px;
    z-index: 3;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: rgba(61, 53, 48, 0.42);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
}
.yy-gallery-counter i {
    font-style: normal;
    opacity: 0.65;
    margin: 0 3px;
}
.yy-gallery-counter b { font-weight: 600; }

/* ---- 缩略图条 ---- */
.yy-gallery-thumbs {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    padding: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}
.yy-gallery-thumbs::-webkit-scrollbar { height: 5px; }
.yy-gallery-thumbs::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.yy-gallery-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    cursor: pointer;
    opacity: 0.62;
    transition: var(--transition);
}
.yy-detail-image .yy-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.yy-gallery-thumb:hover { opacity: 1; }
.yy-gallery-thumb.is-active {
    opacity: 1;
    border-color: var(--sage);
    box-shadow: 0 0 0 2px rgba(122, 158, 126, 0.16);
}

/* 单图商品不可点开大图 */
.yy-gallery.is-single .yy-gallery-slide { cursor: default; }

/* ============================================================
   大图灯箱（挂在 wp_footer，位于 body 直属层）
   不能放进 .yy-content-wrapper：该容器有 backdrop-filter，
   会成为 position:fixed 的包含块，灯箱就无法铺满视口
   ============================================================ */
html.yy-lightbox-lock { overflow: hidden; }

.yy-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 56px 76px;
    background: rgba(40, 34, 30, 0.9);
}
.yy-lightbox.is-open { display: flex; }

.yy-lightbox-figure {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}
.yy-lightbox-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 112px);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.42);
}

.yy-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 26px;
    line-height: 1;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
}
.yy-lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }

.yy-lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
}
.yy-lightbox-arrow svg { width: 24px; height: 24px; }
.yy-lightbox-arrow:hover { background: rgba(255, 255, 255, 0.28); }
.yy-lightbox-prev { left: 16px; }
.yy-lightbox-next { right: 16px; }

.yy-lightbox-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.86);
    font-size: 13px;
}
.yy-lightbox-counter i {
    font-style: normal;
    opacity: 0.6;
    margin: 0 3px;
}
.yy-lightbox-counter b { font-weight: 600; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    /* 保持多图商品的主图本体仍是原来的 400px */
    .yy-detail-image.yy-has-multi { width: 468px; }
    .yy-detail-image.yy-has-multi .yy-gallery-stage,
    .yy-detail-image.yy-has-multi .yy-gallery-thumbs {
        padding: 0 34px;
    }
    .yy-gallery-counter { right: 10px; }
}

@media (max-width: 768px) {
    /* 手机端空间紧张：箭头改为叠在图上，主图占满整宽 */
    .yy-detail-image.yy-has-multi {
        width: 100%;
        max-width: 440px;
        margin: 0 auto;
    }
    .yy-detail-image.yy-has-multi .yy-gallery-stage,
    .yy-detail-image.yy-has-multi .yy-gallery-thumbs {
        padding: 0;
    }
    .yy-gallery-arrow {
        width: 34px;
        height: 34px;
        background: rgba(255, 255, 255, 0.86);
        box-shadow: 0 2px 10px rgba(122, 110, 100, 0.14);
    }
    .yy-gallery-prev { left: 10px; }
    .yy-gallery-next { right: 10px; }
    .yy-gallery-arrow svg { width: 16px; height: 16px; }
    .yy-gallery-counter { right: 10px; bottom: 10px; }
    .yy-gallery-thumb { width: 54px; height: 54px; }

    .yy-lightbox { padding: 48px 12px 64px; }
    .yy-lightbox-img { max-height: calc(100vh - 140px); }
    .yy-lightbox-arrow { width: 40px; height: 40px; }
    .yy-lightbox-prev { left: 6px; }
    .yy-lightbox-next { right: 6px; }
}
