/* ============================================================
   Payment System Styles — 付費方案頁面 + 服務條款簽約
   ============================================================ */

/* === 付費方案選擇器容器 === */
.payment-selector-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.90);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: auto;
    position: relative;
}

.payment-selector-container.visible {
    opacity: 1;
}

/* 標題區域 */
.payment-header {
    text-align: center;
    margin-bottom: 12px;
}

.payment-title {
    font-family: 'Cinzel', 'Noto Sans TC', serif;
    font-size: 2.8rem;
    color: #d4af37;
    margin: 0;
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
    letter-spacing: 8px;
}

.payment-subtitle {
    color: #aaa;
    font-size: 1.25rem;
    margin-top: 6px;
    font-family: 'Cinzel', 'Noto Sans TC', serif;
    letter-spacing: 1px;
}

/* 內容區域包裹器 — 讓徽章能對齊卡牌寬度 */
.payment-content-wrapper {
    position: relative;
    width: fit-content;
    margin-top: -100px;
}

/* 點數徽章 — 靠右對齊於最右邊卡牌邊界 */
.payment-credits-badge {
    position: absolute;
    top: 5px;
    right: 0;
    display: block;
    width: 127px;            /* 110px × 1.15 = 放大 15% */
    height: 71px;            /* 62px × 1.15 = 放大 15% */
    padding: 0;
    border: none;
    background: transparent;
    z-index: 4;  /* 低於卡牌列表 z-index:6，確保卡牌在最前方 */
}

.credits-icon {
    display: block;
    width: 100%;
    height: 71px;            /* 62px × 1.15 = 放大 15% */
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.8));
}

/* 圖片載入失敗時的 fallback 樣式 */
.credits-icon.img-error {
    display: none;
}
.credits-badge-fallback {
    display: none;
    width: 100%;
    height: 71px;
    line-height: 71px;
    text-align: center;
    font-size: 2.1rem;
    filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.8));
}
.credits-icon.img-error ~ .credits-badge-fallback {
    display: block;
}

.credits-count {
    position: absolute;
    top: 50%;
    left: 40%;               /* 左邊界 = 圓形圖騰的右邊緣 */
    right: 0;                /* 右邊界 = 圖檔右邊緣 */
    transform: translateY(-50%);
    text-align: center;      /* 文字在左右邊界之間居中 */
    justify-content: center; /* 數字滾輪動畫用 inline-flex 時也居中 */
    font-family: 'Cinzel', serif;
    font-size: 2.875rem;     /* 2.5rem × 1.15 = 放大 15% */
    color: #3ec6ee !important;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}

/* 確保數字滾輪子元素也繼承顏色 */
.credits-count .digit-cell,
.credits-count .digit-strip,
.credits-count .digit-roller {
    color: #3ec6ee !important;
}

/* === 數字滾動動畫 (Number Roller Animation) === */

/* 單一位數的滾輪容器 — 裁切只顯示一個數字 */
.digit-roller {
    display: inline-block;
    height: 1em;
    line-height: 1;
    overflow: hidden;
    vertical-align: top;
}

/* 新位數入場展開（寬度從 0 展開） */
.digit-roller.digit-entering {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
}

/* 數字條帶 — 垂直排列 0-9 */
.digit-strip {
    display: flex;
    flex-direction: column;
}

.digit-strip > .digit-cell {
    display: block;
    height: 1em;
    line-height: 1;
    text-align: center;
}

/* 點數變化脈衝光效 */
.credits-count.credits-flash {
    animation: creditsFlash 1s ease-out;
}

@keyframes creditsFlash {
    0%   { filter: brightness(1); }
    25%  { filter: brightness(2.2) drop-shadow(0 0 20px rgba(0, 207, 255, 0.9)); }
    100% { filter: brightness(1); }
}

/* 增加/減少浮動指示器 (+5 / -1 之類) */
.credits-delta-indicator {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Cinzel', serif;
    font-weight: 700;
    pointer-events: none;
    white-space: nowrap;
    z-index: 20;
    animation: deltaFloat 1.8s ease-out forwards;
}

.credits-delta-indicator.increase {
    font-size: 2rem;
    color: #00ff88;
    text-shadow: 0 0 12px rgba(0, 255, 136, 0.6);
}

.credits-delta-indicator.decrease {
    font-size: 1.6rem;
    color: #ff4466;
    text-shadow: 0 0 12px rgba(255, 68, 102, 0.6);
}

@keyframes deltaFloat {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
    70%  { opacity: 0.8; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* === 點數徽章：永遠顯示（所有用戶） === */
/* .credits-hidden 類已停用，徽章永遠可見 */

/* === 卡牌列表 === */
.payment-card-list {
    display: flex;
    gap: 135px;
    perspective: 1000px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 30px;
    position: relative;
    z-index: 6;
}

/* 單卡模式：居中顯示（台灣：僅 tier1 單次購買 49 元） */
.payment-card-list.single-card {
    gap: 0;
    justify-content: center;
}

/* 單卡模式下 content-wrapper 也居中 */
.payment-content-wrapper.single-card-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 雙卡模式：台灣 — tier4 月訂閱 + tier1 單次購買 */
.payment-card-list.dual-card {
    gap: 100px;
    justify-content: center;
}

/* 雙卡模式下 content-wrapper 居中 */
.payment-content-wrapper.dual-card-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 單張付費卡牌 */
.payment-card {
    width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    background: transparent;
}

.payment-card .payment-card-img {
    width: 100%;
    height: 515px; /* 300 * 1.715 比例 */
    background-size: cover;
    background-position: center;
    opacity: 0.75;
    transition: opacity 0.3s, border-color 0.3s, box-shadow 0.3s;
    border: 2px solid #554400;
    border-radius: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.payment-card .payment-card-name {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
}

/* 徽章 (訂閱特惠) — 已停用，不再顯示 */
.payment-badge {
    display: none !important;
}

/* 價格標籤 — 深藍發光邊框風格 */
.payment-price {
    margin-top: 15px;
    display: inline-block;
    width: 100%;
    padding: 10px 25px;
    box-sizing: border-box;
    text-align: center;

    /* 漸層背景：從中間深藍向兩邊變暗 */
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.8) 0%,
        rgba(0, 26, 53, 1) 20%,
        rgba(0, 26, 53, 1) 80%,
        rgba(0, 0, 0, 0.8) 100%
    );

    /* 頂部與底部的發光藍色邊框 */
    border: none;
    border-top: 2px solid #3498db;
    border-bottom: 2px solid #3498db;
    border-radius: 0;

    /* 外發光效果：僅上下邊框發光，左右不發光 */
    box-shadow: 0 -4px 10px -4px rgba(52, 152, 219, 0.5),
                0  4px 10px -4px rgba(52, 152, 219, 0.5);
}

.payment-price .price-text {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    color: #fff;
    font-weight: 700;
}

.payment-price .price-action {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 1.05rem;
    color: #d4af37;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* 已訂閱特殊樣式 */
.payment-price.subscribed {
    border-top-color: rgba(212, 175, 55, 0.5);
    border-bottom-color: rgba(212, 175, 55, 0.5);
    border-top-style: dashed;
    border-bottom-style: dashed;
    box-shadow: 0 -4px 10px -4px rgba(212, 175, 55, 0.3),
                0  4px 10px -4px rgba(212, 175, 55, 0.3);
}

/* 已取消訂閱樣式 */
.payment-price.subscribed.cancelled {
    border-top-color: rgba(136, 136, 136, 0.5);
    border-bottom-color: rgba(136, 136, 136, 0.5);
    box-shadow: none;
}

.payment-price.subscribed.cancelled .price-action {
    color: #888;
    text-decoration: none;
}

.payment-sub-price {
    margin-top: 8px;
    font-size: 1rem;
    color: #888;
    text-align: center;
    font-family: 'Noto Sans TC', sans-serif;
}

/* 副標籤高亮（Best Value、Save 40% 等賣點文字） */
.payment-sub-price.payment-sub-highlight {
    color: #e3ad1b;
    font-weight: 600;
    font-style: italic;
}

/* 進度條 */
.payment-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: transparent;
}

.payment-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #d4af37, #ff00de);
    transition: width 0.1s linear;
    box-shadow: 0 0 10px #d4af37;
}

/* 懸停效果 */
.payment-card.hover,
.payment-card:hover {
    transform: scale(1.12) translateY(-15px);
    z-index: 10;
}

.payment-card.hover .payment-card-img,
.payment-card:hover .payment-card-img {
    opacity: 1;
    border-color: #fff;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.6),
                0 0 60px rgba(212, 175, 55, 0.2);
}

.payment-card.selected {
    transform: scale(1.15) translateY(-20px);
}

.payment-card.selected .payment-card-img {
    border-color: #ff00de;
    box-shadow: 0 0 50px #ff00de, 0 0 100px rgba(255, 0, 222, 0.3);
}

/* 說明文字 */
.payment-info-text {
    color: #d4af37;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 20px;
    font-family: 'Noto Sans TC', sans-serif;
}

/* 返回按鈕（與「再次占卜」按鈕樣式一致） */
.payment-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 15px 60px;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;

    /* 金屬金色漸層背景 */
    background: linear-gradient(110deg,
            #aa771c 0%,
            #bf953f 25%,
            #fcf6ba 50%,
            #bf953f 75%,
            #aa771c 100%);
    background-size: 200% auto;

    /* 深度 & 發光 */
    box-shadow:
        0 5px 15px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(212, 175, 55, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);

    /* 流光動畫 */
    animation: shine 4s linear infinite;
    transition: transform 0.2s, box-shadow 0.2s;
}

.payment-back-btn .back-icon {
    font-size: 1.5rem;
}

.payment-back-btn .back-text {
    font-family: 'Cinzel', 'Noto Sans TC', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    letter-spacing: 3px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    text-transform: uppercase;
}

/* 返回按鈕不需要手勢懸停效果，透過 OK 手勢觸發 */

.payment-back-btn:active {
    transform: scale(0.95);
}

.back-progress-bar {
    display: none;
}

.back-progress-fill {
    display: none;
}

.payment-back-hint {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    font-family: 'Noto Sans TC', sans-serif;
}


/* ============================================================
   服務條款簽約覆蓋層 (AgreementOverlay)
   ============================================================ */

.agreement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 8000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: auto;
}

.agreement-overlay.visible {
    opacity: 1;
}

.agreement-overlay.hiding {
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.agreement-container {
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    position: relative;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    border: 2px solid #d4af37;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(212, 175, 55, 0.3),
                0 0 100px rgba(212, 175, 55, 0.1);
}

/* 魔法陣背景 — 固定在容器中央，不跟隨滾動 */
.agreement-magic-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 500px;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 0;
    opacity: 0; /* 初始完全透明，隨比讚手勢增加 */
    transition: opacity 0.15s linear;
}

.magic-circle-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.5))
            drop-shadow(0 0 60px rgba(212, 175, 55, 0.2));
}

.agreement-magic-circle.confirmed {
    animation: magicCirclePulse 1s ease-in-out;
}

@keyframes magicCirclePulse {
    0% { filter: brightness(1); }
    50% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* 可滾動的條款內容 */
.agreement-scroll {
    flex: 1;
    min-height: 0; /* 修復 Flexbox 滾動：允許子元素縮小至小於內容高度 */
    overflow-y: auto;
    padding: 30px;
    position: relative;
    z-index: 1;
    /* 確保文字在魔法陣上方 */
}

.agreement-scroll::-webkit-scrollbar {
    width: 6px;
}

.agreement-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.agreement-scroll::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

.agreement-content {
    position: relative;
    z-index: 2;
}

.agreement-main-title {
    text-align: center;
    font-family: 'Cinzel', 'Noto Sans TC', serif;
    font-size: 2rem;
    color: #d4af37;
    margin: 0 0 30px 0;
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

.agreement-section {
    margin-bottom: 25px;
}

.agreement-section h3 {
    color: #d4af37;
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 1.1rem;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.agreement-section p {
    color: #ccc;
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.95rem;
    line-height: 1.8;
    margin: 0 0 10px 0;
}

.agreement-section strong {
    color: #fff;
}

.agreement-section ul {
    list-style: none;
    padding-left: 20px;
    margin: 10px 0;
}

.agreement-section ul li {
    color: #ccc;
    font-size: 0.95rem;
    line-height: 1.8;
    position: relative;
    padding-left: 15px;
}

.agreement-section ul li::before {
    content: '◆';
    position: absolute;
    left: 0;
    color: #d4af37;
    font-size: 0.6rem;
    top: 5px;
}

.agreement-note {
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 10px;
    padding: 15px;
}

.agreement-note p {
    color: #d4af37;
    font-style: italic;
    font-size: 0.9rem;
}

.agreement-spacer {
    height: 100px;
}

/* 簽約儀式提示 (底部固定) */
.agreement-ritual-hint {
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    text-align: center;
    z-index: 5;
    flex-shrink: 0;
}

.ritual-hint-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    animation: thumbBounce 2s ease-in-out infinite;
}

@keyframes thumbBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.ritual-main-hint {
    color: #d4af37;
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 5px 0;
}

.ritual-sub-hint {
    color: #888;
    font-size: 0.85rem;
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.ritual-progress-bar {
    width: 100%;
    max-width: 400px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 8px auto;
}

.ritual-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #d4af37, #ff00de, #d4af37);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
    transition: width 0.1s linear;
    border-radius: 3px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.ritual-progress-text {
    font-size: 0.9rem;
    color: #888;
    font-family: 'Noto Sans TC', sans-serif;
}

.ritual-progress-text.confirmed {
    color: #d4af37;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}


/* ============================================================
   響應式調整 (手機端)
   ============================================================ */

@media (max-width: 768px) {
    .payment-card-list {
        gap: 14px;
    }

    .payment-card {
        width: 175px;
    }

    .payment-card .payment-card-img {
        height: 300px; /* 175 * 1.715 */
    }

    .payment-title {
        font-size: 1.8rem;
        letter-spacing: 4px;
    }

    .payment-subtitle {
        font-size: 1rem;
    }

    .payment-credits-badge {
        top: 5px;
        right: 0;
    }

    .credits-icon {
        height: 50px;            /* 原 88px × 56% */
    }

    .credits-count {
        font-size: 1.34rem;      /* 原 2.4rem × 56% */
    }

    .payment-back-btn {
        padding: 12px 40px;
    }

    .payment-back-btn .back-text {
        font-size: 1.1rem;
        letter-spacing: 2px;
    }

    /* 協議頁面手機適配 */
    .agreement-container {
        max-height: 90vh;
        width: 95%;
    }

    .agreement-scroll {
        padding: 20px;
    }

    .agreement-main-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .payment-card-list {
        gap: 9px;
    }

    .payment-card {
        width: 85px;
    }

    .payment-card .payment-card-img {
        height: 146px; /* 85 * 1.715 */
    }

    .payment-card-name {
        font-size: 0.5rem !important;
    }

    .payment-price {
        padding: 4px 10px;
        box-shadow: 0 -3px 6px -3px rgba(52, 152, 219, 0.4),
                    0  3px 6px -3px rgba(52, 152, 219, 0.4);
    }

    .payment-price .price-text {
        font-size: 0.75rem;
    }

    .payment-badge {
        font-size: 0.55rem;
        margin-bottom: 6px;
        letter-spacing: 1px;
    }
}

/* ============================================================
   手勢確認對話框（替代 browser confirm()）
   ============================================================ */
.gesture-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: auto;
}

.gesture-confirm-overlay.visible {
    opacity: 1;
}

.gesture-confirm-box {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 16px;
    padding: 40px 50px;
    max-width: 560px;
    width: 90%;
    text-align: center;
    box-shadow:
        0 0 40px rgba(212, 175, 55, 0.15),
        0 20px 60px rgba(0, 0, 0, 0.6);
}

.gesture-confirm-msg {
    font-family: 'Cinzel', 'Noto Sans TC', serif;
    font-size: 1.3rem;
    color: #e8e0d0;
    line-height: 1.6;
    margin-bottom: 30px;
}

.gesture-confirm-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.gesture-confirm-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.5));
}

.gesture-confirm-hint-text {
    font-family: 'Cinzel', 'Noto Sans TC', serif;
    font-size: 1rem;
    color: #d4af37;
    letter-spacing: 1px;
}

.gesture-confirm-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.gesture-confirm-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #d4af37, #f0d060);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.gesture-confirm-status {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 0.95rem;
    color: #888;
    letter-spacing: 1px;
}
