/* =========================================================
   DuckWow 优惠中心 · Apple 极简风格
   =========================================================
   2026-10 整体重写：合并历史多层覆盖为单层实现
   - 夜间模式挂载点：html 上的 .io-black-mode（不是 body）
   - 主题色走 var(--theme-color)，未定义时回退 #00aa90
   - 布局：桌面 4 栏 / ≤1100px 两栏 / ≤600px 两栏
   ========================================================= */

#duckwow-offers {
    --dw-oc-brand: var(--theme-color, #00aa90);
    --dw-oc-line: rgba(128, 128, 128, .16);

    /* 分类色默认回退：未匹配 nth-child 时用品牌色 */
    --dw-cat: var(--dw-oc-brand);
    --dw-cat-text: var(--dw-oc-brand);
}


/* =========================
   布局：桌面四栏
   ========================= */

.dw-offers {
    width: 100%;
    margin: 38px 0;
    font-family: inherit;
}

.dw-offers *,
.dw-offers *::before,
.dw-offers *::after {
    box-sizing: border-box;
}

.dw-offers-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}


/* =========================
   分类卡片
   ========================= */

.dw-offer-category {
    position: relative;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;

    min-width: 0;

    padding: 13px 15px 14px;

    border: 0;
    border-radius: 16px;

    background: var(--main-bg-color, #fff);

    box-shadow:
        0 1px 2px rgba(0, 0, 0, .04),
        0 10px 28px rgba(0, 0, 0, .05);

    overflow: hidden;

    /* fill-mode 用 backwards：动画结束后交还样式控制权 */
    animation: dw-offer-in .45s cubic-bezier(.2, .7, .2, 1) backwards;

    transition: box-shadow .25s ease;
}

.dw-offer-category:hover {
    box-shadow:
        0 3px 8px rgba(0, 0, 0, .05),
        0 16px 36px rgba(0, 0, 0, .09);
}

/* 卡顶分类色极淡光泽（复用弹窗高光手法） */

.dw-offer-category::before {
    content: "";

    position: absolute;
    top: 0;
    left: 0;
    right: 0;

    height: 38%;

    pointer-events: none;

    background: linear-gradient(180deg, color-mix(in srgb, var(--dw-cat) 6%, transparent), transparent);

    opacity: .5;
}

/* 分类色：淡 tint 落在 icon / hover / pill，卡面保持中性；
   animation-delay 形成四列错峰入场 */

.dw-offers-grid > .dw-offer-category:nth-child(1) {
    --dw-cat: #f59e0b;
    --dw-cat-text: #b45309;
}

.dw-offers-grid > .dw-offer-category:nth-child(2) {
    --dw-cat: #f43f5e;
    --dw-cat-text: #be123c;
    animation-delay: .05s;
}

.dw-offers-grid > .dw-offer-category:nth-child(3) {
    --dw-cat: var(--dw-oc-brand);
    --dw-cat-text: #00705f;
    animation-delay: .1s;
}

.dw-offers-grid > .dw-offer-category:nth-child(4) {
    --dw-cat: #8b5cf6;
    --dw-cat-text: #6d28d9;
    animation-delay: .15s;
}

@keyframes dw-offer-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* 分类标题 */

.dw-category-header {
    display: flex;
    align-items: center;
    gap: 9px;

    flex: 0 0 auto;

    min-height: 36px;
    margin: 0 0 8px;
}

.dw-category-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;
    flex: 0 0 34px;

    border-radius: 10px;

    background: color-mix(in srgb, var(--dw-cat) 9%, transparent);

    font-size: 17px;
}

.dw-category-header h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.2;
    font-weight: 700;
}

.dw-category-header span {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.15;
    opacity: .48;
}


/* =========================
   平台行
   ========================= */

.dw-platform-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 0;
    padding: 0;
}

.dw-platform-card {
    position: relative;

    display: flex;
    align-items: center;

    width: 100%;
    min-height: 43px;

    padding: 4px 8px;
    margin: 0 -5px;

    border-radius: 12px;

    cursor: pointer;

    transition:
        background .2s ease,
        transform .2s ease;
}

.dw-platform-card:hover {
    background: color-mix(in srgb, var(--dw-cat) 7%, transparent);
    transform: translateX(2px);
}

.dw-platform-card:focus-visible {
    outline: 2px solid var(--dw-oc-brand);
    outline-offset: -2px;
}


/* Logo */

.dw-platform-logo {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 29px;
    height: 29px;
    flex: 0 0 29px;

    border-radius: 8px;
    overflow: hidden;

    background: color-mix(in srgb, var(--dw-cat) 9%, transparent);

    color: var(--dw-cat-text);
    font-size: 11px;
    font-weight: 700;
}

.dw-platform-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}


/* 纯文字 monogram（第四列：携 / 影 / VIP）逐平台配色，纯 CSS 实现 */

.dw-offer-category:nth-child(4) .dw-platform-card .dw-platform-logo {
    background: color-mix(in srgb, var(--dw-mono, var(--dw-cat)) 11%, transparent);
    color: var(--dw-mono-text, var(--dw-cat-text));
}

.dw-offer-category:nth-child(4) .dw-platform-card:nth-child(1) .dw-platform-logo {
    --dw-mono: #3478f6;
    --dw-mono-text: #1d5fd6;
}

.dw-offer-category:nth-child(4) .dw-platform-card:nth-child(2) .dw-platform-logo {
    --dw-mono: #9333ea;
    --dw-mono-text: #7e22ce;
}

.dw-offer-category:nth-child(4) .dw-platform-card:nth-child(3) .dw-platform-logo {
    --dw-mono: #eab308;
    --dw-mono-text: #a16207;
}


/* 文字：桌面标题居左、说明居右 */

.dw-platform-text {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;

    flex: 1 1 auto;
    min-width: 0;
    margin-left: 7px;
}

.dw-platform-text strong {
    display: block;
    min-width: 0;

    font-size: 14px;
    line-height: 1.2;
    font-weight: 700;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dw-platform-text small {
    display: block;
    justify-self: end;

    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 3px 8px;

    border-radius: 999px;

    background: color-mix(in srgb, var(--dw-cat) 9%, transparent);

    color: var(--dw-cat-text);
    font-size: 11px;
    line-height: 1.2;
    font-weight: 600;
    text-align: right;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* 箭头 */

.dw-platform-arrow {
    flex: 0 0 auto;
    margin-left: 8px;

    font-size: 20px;
    line-height: 1;

    opacity: .5;

    transition:
        color .2s ease,
        opacity .2s ease,
        transform .2s ease;
}

.dw-platform-card:hover .dw-platform-arrow {
    color: var(--dw-cat);
    opacity: 1;
    transform: translateX(2px);
}


/* =========================================================
   骨架屏（加载中占位）
   ========================================================= */

.dw-offers-skeleton {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 38px 0;
}

.dw-skel-card {
    padding: 13px 15px 14px;

    border: 0;
    border-radius: 16px;

    background: var(--main-bg-color, #fff);

    /* 与内容卡片同一柔影，避免骨架 → 内容跳动 */
    box-shadow:
        0 1px 2px rgba(0, 0, 0, .04),
        0 10px 28px rgba(0, 0, 0, .05);
}

.dw-skel-head {
    display: flex;
    align-items: center;
    gap: 9px;

    min-height: 36px;
    margin-bottom: 8px;
}

.dw-skel {
    display: block;

    background-color: rgba(128, 128, 128, .1);
    background-image: linear-gradient(90deg, transparent, rgba(128, 128, 128, .16), transparent);
    background-size: 200% 100%;
    background-position: 100% 0;

    animation: dw-skel-shimmer 1.4s ease infinite;
}

@keyframes dw-skel-shimmer {
    from { background-position: 100% 0; }
    to   { background-position: -100% 0; }
}

.dw-skel-dot {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;

    border-radius: 10px;
}

.dw-skel-line {
    height: 10px;
    border-radius: 5px;
}

.dw-skel-row {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 8px 3px;
}

.dw-skel-ico {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;

    border-radius: 8px;
}


/* =========================================================
   加载失败
   ========================================================= */

.dw-offers-error {
    margin: 38px 0;
    padding: 36px 20px;

    border: 1px dashed rgba(128, 128, 128, .3);
    border-radius: 16px;

    text-align: center;
}

.dw-offers-error p {
    margin: 0 0 14px;

    font-size: 13px;
    opacity: .55;
}

.dw-offers-error button {
    padding: 8px 24px;

    border: 1px solid var(--dw-oc-brand);
    border-radius: 999px;

    background: transparent;
    color: var(--dw-oc-brand);

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background .2s ease,
        color .2s ease;
}

.dw-offers-error button:hover {
    background: var(--dw-oc-brand);
    color: #fff;
}


/* =========================================================
   二维码弹窗
   ========================================================= */

.dw-offer-modal {
    position: fixed;
    inset: 0;

    z-index: 999999;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    opacity: 0;
    visibility: hidden;

    transition:
        opacity .22s ease,
        visibility 0s linear .22s;
}

.dw-offer-modal.is-open {
    opacity: 1;
    visibility: visible;

    transition: opacity .22s ease;
}


/* 遮罩：轻微压暗，聚焦弹窗 */

.dw-modal-backdrop {
    position: absolute;
    inset: 0;

    background: rgba(12, 18, 28, .38);
}


/* 弹窗主体：玻璃面板 */

.dw-modal-panel {
    position: relative;
    z-index: 2;

    width: min(390px, 100%);

    padding: 29px 25px 25px;

    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 16px;

    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);

    box-shadow:
        0 24px 70px rgba(0, 0, 0, .2),
        inset 0 1px 0 rgba(255, 255, 255, .7);

    overflow: hidden;

    text-align: center;

    transform: translateY(14px) scale(.97);

    transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}

.dw-offer-modal.is-open .dw-modal-panel {
    transform: none;
}


/* 顶部玻璃高光 */

.dw-modal-panel::before {
    content: "";

    position: absolute;
    top: 0;
    left: 0;
    right: 0;

    height: 45%;

    pointer-events: none;

    background: linear-gradient(180deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0));

    opacity: .8;
}


/* 关闭 */

.dw-modal-close {
    position: absolute;
    top: 13px;
    right: 13px;
    z-index: 3;

    width: 33px;
    height: 33px;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: rgba(128, 128, 128, .09);

    color: inherit;

    font-size: 23px;
    line-height: 30px;

    cursor: pointer;

    transition:
        background .2s ease,
        color .2s ease;
}

.dw-modal-close:hover {
    background: color-mix(in srgb, var(--dw-oc-brand) 12%, transparent);
    color: var(--dw-oc-brand);
}

.dw-modal-close:focus-visible {
    outline: 2px solid var(--dw-oc-brand);
    outline-offset: 2px;
}


/* 标题 */

.dw-modal-title {
    padding: 0 35px;

    font-size: 21px;
    font-weight: 700;
}

.dw-modal-desc {
    margin-top: 5px;

    font-size: 13px;
    opacity: .5;
}


/* Tab */

.dw-modal-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;

    gap: 7px;

    margin: 20px 0 17px;
}

.dw-modal-tab {
    padding: 7px 14px;

    border: 1px solid rgba(128, 128, 128, .18);
    border-radius: 999px;

    background: transparent;

    color: inherit;

    font-size: 12px;

    cursor: pointer;

    transition:
        background .2s ease,
        border-color .2s ease,
        color .2s ease;
}

.dw-modal-tab:hover {
    border-color: var(--dw-oc-brand);
}

.dw-modal-tab.active {
    border-color: var(--dw-oc-brand);

    background: var(--dw-oc-brand);

    color: #fff;
}


/* 二维码 */

.dw-modal-qr {
    position: relative;

    width: 235px;
    height: 235px;

    margin: 0 auto;

    padding: 9px;

    border-radius: 16px;

    background: #fff;

    box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
}

.dw-modal-qr img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: contain;

    transition: opacity .2s ease;
}


/* 二维码加载中 */

.dw-modal-qr.is-loading img {
    opacity: 0;
}

.dw-modal-qr.is-loading::after {
    content: "";

    position: absolute;
    top: 50%;
    left: 50%;

    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;

    border: 3px solid rgba(128, 128, 128, .18);
    border-top-color: var(--dw-oc-brand);
    border-radius: 50%;

    animation: dw-qr-spin .8s linear infinite;
}

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


/* 二维码加载失败（含未替换的占位链接） */

.dw-modal-qr.is-error img {
    display: none;
}

.dw-modal-qr.is-error::after {
    content: "二维码加载失败";

    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 13px;
    color: #999;
}


/* 提示 */

.dw-modal-tip {
    margin-top: 13px;

    font-size: 12px;
    opacity: .48;
}


/* 其他优惠链接 */

.dw-modal-link {
    display: none;

    margin-top: 13px;

    color: var(--dw-oc-brand) !important;

    font-size: 13px;
    font-weight: 700;

    text-decoration: none !important;
}

.dw-modal-link:hover {
    opacity: .7;
}


/* =========================================================
   打开弹窗锁定页面滚动
   ========================================================= */

html {
    scrollbar-gutter: stable;
}

html.dw-offer-modal-lock {
    overflow-y: scroll !important;
}

body.dw-offer-modal-lock {
    overflow: hidden !important;
}


/* =========================================================
   夜间模式（html.io-black-mode）
   ========================================================= */

html.io-black-mode #duckwow-offers {
    --dw-oc-line: rgba(255, 255, 255, .1);
}

/* 分类文字色：暗态提亮 */

html.io-black-mode .dw-offers-grid > .dw-offer-category:nth-child(1) { --dw-cat-text: #fbbf24; }
html.io-black-mode .dw-offers-grid > .dw-offer-category:nth-child(2) { --dw-cat-text: #fb7185; }
html.io-black-mode .dw-offers-grid > .dw-offer-category:nth-child(3) { --dw-cat-text: #2dd4bf; }
html.io-black-mode .dw-offers-grid > .dw-offer-category:nth-child(4) { --dw-cat-text: #c4b5fd; }

html.io-black-mode .dw-offer-category {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, .3),
        0 10px 28px rgba(0, 0, 0, .28);
}

html.io-black-mode .dw-offer-category:hover {
    box-shadow:
        0 3px 8px rgba(0, 0, 0, .34),
        0 16px 36px rgba(0, 0, 0, .42);
}

html.io-black-mode .dw-offer-category::before {
    opacity: .35;
}

html.io-black-mode .dw-platform-card:hover {
    background: color-mix(in srgb, var(--dw-cat) 14%, transparent);
}

/* 暗态下 pill 底色稍强、monogram 文字提亮 */

html.io-black-mode .dw-platform-text small {
    background: color-mix(in srgb, var(--dw-cat) 16%, transparent);
}

html.io-black-mode .dw-offer-category:nth-child(4) .dw-platform-card .dw-platform-logo {
    background: color-mix(in srgb, var(--dw-mono, var(--dw-cat)) 22%, transparent);
}

html.io-black-mode .dw-offer-category:nth-child(4) .dw-platform-card:nth-child(1) .dw-platform-logo { --dw-mono-text: #7aa7ff; }
html.io-black-mode .dw-offer-category:nth-child(4) .dw-platform-card:nth-child(2) .dw-platform-logo { --dw-mono-text: #d8b4fe; }
html.io-black-mode .dw-offer-category:nth-child(4) .dw-platform-card:nth-child(3) .dw-platform-logo { --dw-mono-text: #fde047; }

html.io-black-mode .dw-skel {
    background-color: rgba(255, 255, 255, .08);
    background-image: linear-gradient(90deg, transparent, rgba(255, 255, 255, .1), transparent);
}

html.io-black-mode .dw-offers-error {
    border-color: rgba(255, 255, 255, .18);
}

/* 弹窗：黑色玻璃 */

html.io-black-mode .dw-modal-panel {
    background: rgba(28, 30, 34, .88);
    border-color: rgba(255, 255, 255, .12);

    box-shadow:
        0 25px 80px rgba(0, 0, 0, .55),
        inset 0 1px 0 rgba(255, 255, 255, .08);

    color: #fff;
}

html.io-black-mode .dw-modal-panel::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0));
    opacity: 1;
}

html.io-black-mode .dw-modal-close {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

html.io-black-mode .dw-modal-tab {
    border-color: rgba(255, 255, 255, .18);
}

html.io-black-mode .dw-modal-tab.active {
    border-color: var(--dw-oc-brand);
    background: var(--dw-oc-brand);
    color: #fff;
}

/* 二维码保持白底，保证长按识别 */
html.io-black-mode .dw-modal-qr {
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}

html.io-black-mode .dw-modal-qr.is-error::after {
    color: #888;
}


/* =========================================================
   响应式
   ========================================================= */

@media (max-width: 1100px) {

    .dw-offers-grid,
    .dw-offers-skeleton {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}

@media (max-width: 600px) {

    .dw-offers {
        margin: 25px 0;
    }

    .dw-offers-grid,
    .dw-offers-skeleton {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .dw-offers-skeleton {
        margin: 25px 0;
    }

    .dw-offers-error {
        margin: 25px 0;
    }

    /* 分类卡片 */

    .dw-offer-category {
        padding: 12px;
        border-radius: 16px;
    }

    /* 分类标题 */

    .dw-category-header {
        gap: 8px;
        margin-bottom: 7px;
    }

    .dw-category-icon {
        width: 34px;
        height: 34px;
        font-size: 17px;
    }

    .dw-category-header h3 {
        font-size: 15px;
    }

    .dw-category-header span {
        font-size: 10px;
    }

    /* 平台行 */

    .dw-platform-card {
        min-height: 42px;
        padding: 3px 6px;
        margin: 0 -3px;
    }

    .dw-platform-logo {
        width: 28px;
        height: 28px;
        flex: 0 0 28px;
    }

    /* 手机：说明换行到标题下方 */

    .dw-platform-text {
        grid-template-columns: minmax(0, 1fr);
        gap: 1px;
        margin-left: 6px;
    }

    .dw-platform-text strong {
        font-size: 13px;
    }

    .dw-platform-text small {
        justify-self: start;

        padding: 2px 7px;

        font-size: 10px;
        text-align: left;
    }

    .dw-platform-arrow {
        margin-left: 3px;
        font-size: 18px;
    }

    /* 弹窗 */

    .dw-offer-modal {
        padding: 16px;
    }

    .dw-modal-panel {
        padding: 27px 17px 23px;
        border-radius: 16px;
    }

    .dw-modal-qr {
        width: 220px;
        height: 220px;
    }

}


/* 减少动态效果偏好 */

@media (prefers-reduced-motion: reduce) {

    .dw-skel {
        animation: none;
    }

    .dw-offer-category {
        animation: none;
    }

    .dw-offer-modal,
    .dw-modal-panel,
    .dw-platform-card,
    .dw-offer-category,
    .dw-modal-qr img {
        transition: none;
    }

    .dw-modal-qr.is-loading::after {
        animation-duration: 1.6s;
    }

}


