/**
 * 跨浏览器兼容层
 * Chrome / Firefox / Safari / Edge / iOS WebView / 国产双核浏览器
 */

/* ========== 文档基线 ========== */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

html,
body,
.auth-body {
    min-height: 100vh;
    min-height: calc(var(--shop-vh, 1vh) * 100);
    min-height: -webkit-fill-available;
}

@supports (min-height: 100dvh) {
    html,
    body,
    .auth-body {
        min-height: 100dvh;
    }
}

[hidden] {
    display: none !important;
}

img,
video {
    max-width: 100%;
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    -webkit-appearance: none;
    appearance: none;
}

/* ========== position: sticky ========== */
.sticky-top,
.auth-topbar,
.cart-summary-sticky,
.pd-info-panel,
.uc-sidebar,
.modern-header {
    position: -webkit-sticky;
    position: sticky;
}

/* ========== inset 简写回退 ========== */
.auth-grand-visual-bg,
.footer-grand-bg,
.footer-grand-glow,
.pd-page-bg,
.pd-lightbox-backdrop,
.home-carousel-img,
.home-carousel-overlay,
.home-carousel-visual-link {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

/* ========== :has() 回退（旧版 Firefox） ========== */
body.has-cs-widget .back-to-top {
    bottom: 92px;
}

@supports not selector(:has(*)) {
    body .back-to-top {
        bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }

    body.has-cs-widget .back-to-top {
        bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px) + 76px);
    }
}

@media (max-width: 767.98px) {
    body.has-cs-widget .back-to-top {
        bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px) + 76px);
    }
}

/* ========== backdrop-filter 前缀 + 不支持时降级 ========== */
.hero-banner .btn-dark,
.auth-topbar,
.mobile-bottom-bar,
.auth-grand-features li,
.alert-modern,
.modern-header.scrolled,
.shop-header-bar,
.footer-grand-bar,
.footer-grand-glow,
.pd-lightbox-backdrop,
.pd-gallery-zoom,
.pd-info-trust,
.home-carousel-caption,
.home-marketing-hub,
.news-hero,
.checkout-summary-card,
.uc-sidebar {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.auth-topbar {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.auth-grand-features li {
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.no-backdrop-filter .auth-topbar,
.no-backdrop-filter .mobile-bottom-bar,
.no-backdrop-filter .modern-header.scrolled,
.no-backdrop-filter .shop-header-bar {
    background: rgba(255, 255, 255, 0.98);
}

.no-backdrop-filter .auth-grand-features li {
    background: rgba(255, 255, 255, 0.16);
}

.no-backdrop-filter .hero-banner .btn-dark {
    background: rgba(255, 255, 255, 0.28);
}

.no-backdrop-filter .alert-modern {
    background: #fff;
}

.no-backdrop-filter .footer-grand-bar {
    background: rgba(15, 23, 42, 0.96);
}

.no-backdrop-filter .news-hero,
.no-backdrop-filter .home-marketing-hub {
    background: rgba(30, 64, 175, 0.06);
}

/* ========== aspect-ratio 回退 ========== */
.no-aspect-ratio .product-card-img-wrap,
.no-aspect-ratio .product-card-img-wrap-modern,
.no-aspect-ratio .mkt-promo-img,
.no-aspect-ratio .pd-gallery .pd-gallery-stage,
.no-aspect-ratio .home-carousel .carousel-item {
    height: 0;
    min-height: 0;
    padding-bottom: 38.1%;
}

.no-aspect-ratio .product-card-img-wrap img,
.no-aspect-ratio .product-card-img-wrap-modern img,
.no-aspect-ratio .mkt-promo-img img,
.no-aspect-ratio .mkt-group-img img,
.no-aspect-ratio .pd-gallery .pd-gallery-stage > img,
.no-aspect-ratio .pd-gallery .pd-gallery-stage > picture,
.no-aspect-ratio .home-carousel-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========== flex gap 回退（Safari < 14.1） ========== */
.no-flex-gap .auth-grand-tabs > * + * {
    margin-left: 0.5rem;
}

.no-flex-gap .auth-grand-form-head {
    margin-left: 0;
}
.no-flex-gap .auth-grand-form-head > * + * {
    margin-left: 1rem;
}

.no-flex-gap .auth-grand-sms > * + * {
    margin-left: 0.625rem;
}

.no-flex-gap .auth-grand-field-row > * + * {
    margin-left: 0.875rem;
}

.no-flex-gap .auth-grand-form-footer > * + * {
    margin-left: 0.375rem;
}

.no-flex-gap .auth-grand-submit > * + * {
    margin-left: 0.5rem;
}

.no-flex-gap .auth-topbar-inner > * + * {
    margin-left: 1rem;
}

.no-flex-gap .mobile-bottom-bar {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
}

.no-flex-gap .header-actions-modern > * + *,
.no-flex-gap .uc-mobile-user-inner > * + *,
.no-flex-gap .news-card-meta > * + * {
    margin-left: 0.5rem;
}

@media (max-width: 575.98px) {
    .no-flex-gap .auth-grand-sms > * + * {
        margin-left: 0;
        margin-top: 0.625rem;
    }

    .no-flex-gap .auth-grand-field-row > * + * {
        margin-left: 0;
        margin-top: 0.875rem;
    }
}

/* ========== clamp() 回退 ========== */
.auth-grand-visual-title {
    font-size: 2rem;
}

@supports (font-size: clamp(1rem, 2vw, 2rem)) {
    .auth-grand-visual-title {
        font-size: clamp(2rem, 4vw, 2.75rem);
    }
}

/* ========== Grid 回退 ========== */
@supports not (display: grid) {
    .auth-grand-page {
        display: block;
    }

    .auth-grand-features {
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
    }

    .auth-grand-features li {
        width: 48%;
        margin: 0 1% 0.875rem;
    }

    .auth-grand-field-row {
        display: block;
    }

    .auth-grand-field-row .auth-grand-field + .auth-grand-field {
        margin-top: 0.875rem;
    }
}

/* ========== 焦点样式（:focus-visible 回退） ========== */
:focus {
    outline: none;
}

:focus-visible,
.js :focus:not(:focus-visible) {
    outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #1E40AF;
    outline-offset: 2px;
}

/* ========== iOS 输入框防缩放 ========== */
@media (max-width: 767.98px) {
    .shop-page input.form-control,
    .shop-page select.form-select,
    .shop-page textarea.form-control,
    .auth-grand-page input.form-control,
    .auth-grand-page select.form-select,
    .auth-grand-page textarea.form-control {
        font-size: 16px;
    }
}

/* ========== 安全区域（刘海屏 / 底部横条） ========== */
.mobile-bottom-bar {
    padding-bottom: calc(0.35rem + constant(safe-area-inset-bottom));
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom));
}

.shop-page {
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
}

@supports (padding: max(0px)) {
    .mobile-bottom-bar {
        padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
    }
}

/* ========== 多行文本截断 ========== */
.product-card-title,
.product-card-title-modern,
.mkt-promo-body h3,
.news-card-title,
.news-featured-excerpt,
.news-sidebar-title,
.pd-related-name {
    line-clamp: 2;
}

.news-featured-excerpt {
    line-clamp: 4;
}

/* ========== 滚动与触摸 ========== */
.shop-main,
.auth-grand-panel-inner,
.uc-main,
.admin-table-wrapper,
.pd-lightbox-body {
    -webkit-overflow-scrolling: touch;
}

/* ========== 渐变与动画 GPU 提示 ========== */
.auth-grand-visual-bg,
.home-carousel-item,
.product-card,
.btn-primary,
.auth-grand-submit {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* ========== 100vh 视口修正 ========== */
.auth-grand,
.auth-grand-page {
    min-height: calc(var(--shop-vh, 1vh) * 100 - 4rem);
}

.shop-main {
    min-height: calc(var(--shop-vh, 1vh) * 100 - 120px);
}

/* ========== 国产双核 / 旧版 Edge ========== */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

select.form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ========== 打印 ========== */
@media print {
    .shop-header,
    .mobile-bottom-bar,
    .back-to-top,
    .auth-topbar,
    .customer-service-widget {
        display: none !important;
    }

    .shop-main,
    .auth-grand-panel {
        min-height: auto;
    }
}
