/* ==========================================================================
   CBON Trust Badges — 全站通用信任元素 snippet
   用法：在每個 shop 頁 </main> 前貼以下 HTML 即可（見 trust-badges.html 模板）

   設計原則：
   1. 不依賴 design-tokens.css（自帶 fallback 值，避免破壞未載入 tokens 的頁面）
   2. 響應式：>= 768px 5 列、>= 480px 2 列、< 480px 1 列
   3. a11y：role/aria-label 齊全，emoji 標 aria-hidden
   ========================================================================== */

:root {
    /* 內部 tokens（如果 :root 已定義同名 var，CSS 後載入者覆蓋；故放最前自隔離）*/
    --tb-radius-md: 12px;
    --tb-radius-lg: 16px;
    --tb-shadow: 0 4px 14px rgba(15, 17, 38, 0.06);
    --tb-border: #e3e6f0;
    --tb-bg: #ffffff;
    --tb-bg-soft: #f8f9ff;
    --tb-text: #0b1020;
    --tb-text-muted: #5b6478;
    --tb-accent: #ff6b35;
    --tb-primary: #4f46e5;
    --tb-success: #10b981;
    --tb-info: #3b82f6;
    --tb-font-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang HK",
                     "Microsoft JhengHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* === 主容器 === */
.cbon-trust-badges {
    margin: 32px auto 48px;
    padding: 24px 16px;
    max-width: 1100px;
    background: var(--tb-bg-soft);
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-lg);
    box-shadow: var(--tb-shadow);
    font-family: var(--tb-font-sans);
}

.cbon-trust-badges__title {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tb-text-muted);
    text-align: center;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* === Grid === */
.cbon-trust-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

/* === 單個 badge === */
.cbon-trust-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--tb-bg);
    border-radius: var(--tb-radius-md);
    border: 1px solid transparent;
    transition: border-color 200ms ease, transform 200ms ease;
}

.cbon-trust-item:hover {
    border-color: var(--tb-border);
    transform: translateY(-1px);
}

.cbon-trust-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: var(--tb-radius-md);
    background: var(--tb-bg-soft);
    line-height: 1;
}

/* QR 圖示變體：用真實 QR 圖取代 emoji icon，可點擊放大 */
.cbon-trust-icon--qr {
    padding: 3px;
    background: var(--tb-bg);
    border: 1px solid var(--tb-border);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 200ms ease, border-color 200ms ease;
}

.cbon-trust-icon--qr:hover {
    border-color: var(--tb-accent);
    transform: scale(1.05);
}

.cbon-trust-icon--qr img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.cbon-trust-item--store  .cbon-trust-icon { background: #fff7ed; }
.cbon-trust-item--pay    .cbon-trust-icon { background: #eff6ff; }
.cbon-trust-item--speed  .cbon-trust-icon { background: #fffbeb; }
.cbon-trust-item--wa     .cbon-trust-icon { background: #ecfdf5; }
.cbon-trust-item--count  .cbon-trust-icon { background: #fef3c7; }

.cbon-trust-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cbon-trust-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--tb-text);
    line-height: 1.3;
    word-break: break-word;
}

.cbon-trust-desc {
    font-size: 12px;
    color: var(--tb-text-muted);
    line-height: 1.4;
}

.cbon-trust-desc a {
    color: var(--tb-primary);
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
}

.cbon-trust-desc a:hover {
    color: var(--tb-accent);
}

/* === Loading / Error 狀態 === */
[data-cbon-customer-count].is-loading::after {
    content: "···";
    animation: cbon-trust-pulse 1.2s ease-in-out infinite;
}

@keyframes cbon-trust-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* === 響應式 === */
@media (max-width: 900px) {
    .cbon-trust-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .cbon-trust-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .cbon-trust-badges {
        margin: 24px 12px 32px;
        padding: 16px 12px;
    }
}

@media (max-width: 380px) {
    .cbon-trust-grid {
        grid-template-columns: 1fr;
    }
    .cbon-trust-item {
        padding: 10px;
    }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    .cbon-trust-item,
    [data-cbon-customer-count].is-loading::after {
        transition: none;
        animation: none;
    }
}

/* ==========================================================================
   QR 放大燈箱（點 .cbon-trust-icon--qr 觸發）
   用原生 <dialog> 元素 — ESC 鍵自動關閉、焦點陷阱、a11y 標籤齊全
   ========================================================================== */
.cbon-qr-lightbox {
    border: none;
    border-radius: var(--tb-radius-lg);
    padding: 0;
    background: transparent;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: none;
    overflow: visible;
    color: white;
    /* 進場動畫 */
    animation: cbon-qr-zoom-in 200ms var(--tb-ease, ease-out);
}

.cbon-qr-lightbox::backdrop {
    background: rgba(15, 17, 38, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: cbon-qr-fade-in 200ms ease-out;
}

.cbon-qr-lightbox__img {
    display: block;
    width: min(80vw, 480px);
    height: auto;
    background: var(--tb-bg, #ffffff);
    padding: 20px;
    border-radius: var(--tb-radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    margin: 0 auto;
}

.cbon-qr-lightbox__close {
    position: absolute;
    top: -44px;
    right: -8px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease, transform 200ms ease;
    padding: 0;
}

.cbon-qr-lightbox__close:hover,
.cbon-qr-lightbox__close:focus {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
    outline: none;
}

.cbon-qr-lightbox__caption {
    text-align: center;
    color: white;
    font-size: 14px;
    margin: 16px 0 0;
    padding: 0 12px;
    opacity: 0.92;
    line-height: 1.4;
}

@keyframes cbon-qr-zoom-in {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

@keyframes cbon-qr-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (max-width: 640px) {
    .cbon-qr-lightbox__img {
        width: min(85vw, 360px);
        padding: 14px;
    }
    .cbon-qr-lightbox__close {
        top: -40px;
        right: 0;
    }
}