/* 产品详情：主图 + SKU 规格（shop / wechat 共用） */
.pd-detail {
    --pd-accent: #ff5252;
    --pd-sticky-top: 0;
    --pd-gallery-bg: #fff;
    overflow-anchor: none;
}

.pd-detail--wechat {
    --pd-accent: #1aad19;
}

.pd-detail--shop {
    --pd-sticky-top: 50px;
}

/* 主图区：移动端随页面滚动（静态），桌面端吸顶（在两栏布局左列内有效） */
.pd-gallery-sticky {
    position: relative;
    background: var(--pd-gallery-bg);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
    /* 移动端限高：防止 1:1 在宽屏手机/平板上占满屏幕 */
    max-height: min(100vw, 60vh);
    overflow: hidden;
}

.pd-gallery {
    width: 100%;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.pd-gallery::before {
    content: "";
    display: block;
    padding-top: 100%; /* 经典 1:1 纵横比，完美兼容 iOS / 微信 WebView */
}

.pd-gallery-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0; /* 强行锚定左右，避免 Safari 按溢出子元素计算绝对定位容器的宽度 */
    display: flex;
    height: 100%;
    transition: transform 0.3s ease;
}

.pd-gallery-slide {
    min-width: 100%;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
    background: #f5f5f5;
    position: relative; /* 为绝对定位的子元素 img 提供基准 */
}

.pd-gallery-slide img {
    position: absolute; /* 绝对定位：脱离流，避免 iOS Safari 按图片原始宽高撑开 Flex 容器 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* 改为 contain，确保任何比例的原图都能完整显示不被裁剪，避免“显示不全” */
    object-position: center center;
    display: block;
}

.pd-gallery-empty {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    color: #ddd;
    font-size: 48px;
}

.pd-gallery-dots {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 10;
    pointer-events: none;
}

.pd-gallery-dots span {
    pointer-events: auto;
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    margin: 0 3px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.pd-gallery-dots span.is-active {
    background: var(--pd-accent);
    transform: scale(1.15);
}

.pd-gallery-counter {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 11;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    line-height: 1.6;
}

.pd-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.pd-gallery-nav--prev { left: 8px; }
.pd-gallery-nav--next { right: 8px; }

.pd-gallery-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

/* SKU 横向滚动条 */
.pd-sku-section {
    margin-bottom: 12px;
}

.pd-sku-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.pd-sku-count {
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

.pd-sku-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 2px 2px 6px;
    margin: 0 -2px;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
}

.pd-sku-scroll::-webkit-scrollbar {
    height: 3px;
}

.pd-sku-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.pd-sku-chip {
    flex: 0 0 auto;
    width: 76px;
    scroll-snap-align: start;
    border: 1.5px solid #e8e8e8;
    border-radius: 8px;
    padding: 6px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pd-sku-chip:active {
    transform: scale(0.98);
}

.pd-sku-chip.is-selected {
    border-color: var(--pd-accent);
    box-shadow: 0 0 0 1px var(--pd-accent);
}

.pd-detail--wechat .pd-sku-chip.is-selected {
    background: #f0f9ff;
}

.pd-detail--shop .pd-sku-chip.is-selected {
    background: #fff5f5;
}

.pd-sku-chip-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    margin: 0 auto 4px;
    background: #f5f5f5;
}

.pd-sku-chip-thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 20px;
}

.pd-sku-chip-name {
    font-size: 11px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
    color: #333;
}

.pd-sku-chip-price {
    font-size: 11px;
    color: var(--pd-accent);
    font-weight: bold;
    margin-top: 2px;
}

/* SKU 很多时：紧凑模式（仅缩略图+单行名） */
.pd-sku-scroll.is-compact .pd-sku-chip {
    width: 64px;
    padding: 5px;
}

.pd-sku-scroll.is-compact .pd-sku-chip-thumb {
    width: 48px;
    height: 48px;
}

.pd-sku-scroll.is-compact .pd-sku-chip-price {
    display: none;
}

.pd-selected-hint {
    font-size: 12px;
    color: #666;
    margin-top: 6px;
    min-height: 18px;
}

.pd-selected-hint strong {
    color: #333;
    font-weight: 500;
}

/* 大屏两栏布局：图片左侧吸顶，产品信息右侧滚动 */
@media (min-width: 768px) {
    .pd-detail {
        display: grid;
        grid-template-columns: 400px 1fr;
        column-gap: 24px;
        align-items: start;
        max-width: 1100px;
        margin: 0 auto;
        padding: 20px;
    }

    /* 图片区占左列，sticky 在左栏内有效，右栏内容独立滚动不存在遮挡问题 */
    .pd-gallery-sticky {
        grid-column: 1;
        grid-row: 1;
        position: sticky;
        top: var(--pd-sticky-top);
        max-height: 520px;
    }

    /* 其他所有直接子元素在右列自动堆叠 */
    .pd-detail > div:not(.pd-gallery-sticky) {
        grid-column: 2;
    }
}
