/**
 * Cartoon2 商品详情：主图与详情区图片点击全屏预览（缩放、拖拽、下载）。
 * 与店铺主色（#0C84D1）呼应的冷色遮罩 + 底栏磨砂玻璃卡片。
 */
.acg-item-img-preview {
    --acg-preview-accent: #0c84d1;
    --acg-preview-accent-soft: rgba(12, 132, 209, 0.45);
    --acg-preview-glass: rgba(255, 255, 255, 0.09);
    --acg-preview-glass-border: rgba(255, 255, 255, 0.14);
    --acg-preview-text: rgba(255, 255, 255, 0.92);
    --acg-preview-muted: rgba(255, 255, 255, 0.52);
    /* 底栏距屏幕底边的空隙；UC/QQ 等自带底栏时 env(safe-area) 常为 0，窄屏用更大固定值抬高 */
    --acg-preview-footer-margin-base: 28px;

    position: fixed;
    inset: 0;
    z-index: 10950;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.acg-item-img-preview__backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    cursor: zoom-out;
    background:
        radial-gradient(ellipse 85% 65% at 50% 38%, rgba(12, 132, 209, 0.14), transparent 55%),
        radial-gradient(ellipse 100% 80% at 50% 100%, rgba(0, 40, 80, 0.35), transparent 45%),
        rgba(6, 10, 22, 0.9);
}

.acg-item-img-preview__close-top {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    z-index: 3;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--acg-preview-glass-border);
    border-radius: 50%;
    background: var(--acg-preview-glass);
    color: var(--acg-preview-text);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.acg-item-img-preview__close-top span {
    position: relative;
    top: -1px;
}

@supports (backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px)) {
    .acg-item-img-preview__close-top {
        -webkit-backdrop-filter: blur(16px) saturate(1.25);
        backdrop-filter: blur(16px) saturate(1.25);
    }
}

.acg-item-img-preview__close-top:hover,
.acg-item-img-preview__close-top:focus-visible {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.28);
    outline: none;
}

.acg-item-img-preview__close-top:active {
    transform: scale(0.96);
}

.acg-item-img-preview__viewport {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px 0;
    touch-action: none;
}

.acg-item-img-preview__img {
    max-width: min(94vw, 1400px);
    /* 158 + margin-base = 168 当 base=10；base 增大时同步为底栏让位 */
    max-height: calc(
        100vh - (158px + var(--acg-preview-footer-margin-base)) - env(safe-area-inset-bottom, 0px) -
            env(safe-area-inset-top, 0px)
    );
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    cursor: grab;
    will-change: transform;
    transform-origin: center center;
    border-radius: 4px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.12),
        0 24px 48px rgba(0, 0, 0, 0.45);
    transition: box-shadow 0.2s ease;
}

.acg-item-img-preview__img.is-dragging {
    cursor: grabbing;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 12px 28px rgba(0, 0, 0, 0.4);
}

.acg-item-img-preview__footer {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    margin: 0 14px calc(var(--acg-preview-footer-margin-base) + env(safe-area-inset-bottom, 0px));
    padding: 14px 16px 16px;
    border-radius: 18px;
    border: 1px solid var(--acg-preview-glass-border);
    background: var(--acg-preview-glass);
    box-shadow:
        0 -4px 32px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.08) inset;
}

@supports (backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px)) {
    .acg-item-img-preview__footer {
        -webkit-backdrop-filter: blur(20px) saturate(1.35);
        backdrop-filter: blur(20px) saturate(1.35);
    }
}

.acg-item-img-preview__hint {
    margin: 0 0 12px;
    padding: 0 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--acg-preview-muted);
    line-height: 1.45;
}

.acg-item-img-preview__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0;
    margin: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px;
    background: none;
}

.acg-item-img-preview__btn-group {
    display: inline-flex;
    align-items: stretch;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.acg-item-img-preview__btn-group .acg-item-img-preview__btn {
    min-width: 46px;
    border-radius: 0;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.acg-item-img-preview__btn-group .acg-item-img-preview__btn:last-child {
    border-right: 0;
}

.acg-item-img-preview__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 42px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--acg-preview-text);
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

.acg-item-img-preview__btn:hover,
.acg-item-img-preview__btn:focus-visible {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.26);
    outline: none;
}

.acg-item-img-preview__btn:active {
    transform: scale(0.98);
}

.acg-item-img-preview__btn--primary {
    border-color: var(--acg-preview-accent-soft);
    background: linear-gradient(165deg, rgba(12, 132, 209, 0.55), rgba(0, 110, 190, 0.42));
    box-shadow:
        0 2px 12px rgba(12, 132, 209, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.acg-item-img-preview__btn--primary:hover,
.acg-item-img-preview__btn--primary:focus-visible {
    background: linear-gradient(165deg, rgba(12, 132, 209, 0.72), rgba(0, 110, 190, 0.55));
    border-color: rgba(12, 132, 209, 0.75);
}

@media (prefers-reduced-motion: reduce) {
    .acg-item-img-preview__btn,
    .acg-item-img-preview__close-top,
    .acg-item-img-preview__img {
        transition: none;
    }

    .acg-item-img-preview__btn:active,
    .acg-item-img-preview__close-top:active {
        transform: none;
    }
}

@media (max-width: 991.98px) {
    .acg-item-img-preview {
        /* 第三方浏览器底栏约 48–56px，再留余量避免贴边仍被挡 */
        --acg-preview-footer-margin-base: 76px;
    }
}

@media (max-width: 380px) {
    .acg-item-img-preview__footer {
        margin-left: 10px;
        margin-right: 10px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .acg-item-img-preview__btn {
        min-width: 40px;
        height: 40px;
        padding: 0 10px;
        font-size: 14px;
    }
}

/* 可预览图：提示可点击（不改变布局） */
main[data-acg-item-desktop-layout] .acg-cover img.item-cover,
main[data-acg-item-desktop-layout] .item-detail .panel-body img {
    cursor: zoom-in;
}
