/* ==========================================================================
   CSS 設計系統 - MysticTarot (線上塔羅牌)
   採用奢華暗金星芒 (Tarot Celestial Gold) 視覺風格與 3D 翻牌特效
   ========================================================================== */

/* 變數定義 */
:root {
    --bg-primary: #050308;
    --bg-secondary: #0f0a1c;
    --bg-card: rgba(18, 12, 34, 0.8);
    --border-color: rgba(212, 175, 55, 0.2); /* 霧面金 */
    --border-focus: #f59e0b; /* 亮金色 */
    
    --text-primary: #f5f3ff;
    --text-secondary: #c084fc;
    --text-hint: #7c3aed;
    
    --color-accent: #d4af37; /* 古典金箔色 */
    --color-accent-light: #fcd34d;
    --color-primary: #8b5cf6; /* 神祕紫 */
    --color-gold-glow: rgba(212, 175, 55, 0.35);
    
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 40px rgba(0, 0, 0, 0.6);
    --shadow-neon-gold: 0 0 25px rgba(212, 175, 55, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 全域基礎 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Noto Sans TC', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.6;
    background-image: radial-gradient(circle at 50% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
                      radial-gradient(circle at 10% 90%, rgba(212, 175, 55, 0.03) 0%, transparent 50%);
}

.container {
    width: 100%;
    max-width: 950px;
    margin: 0 auto;
    padding: 0 24px;
}

/* 動畫定義 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shuffle-anim {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(0.9) rotate(5deg) translateY(-20px); filter: blur(1px); }
    100% { transform: scale(1) rotate(0deg); }
}

.animate-fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-100 { animation-delay: 0.1s; opacity: 0; }
.delay-200 { animation-delay: 0.2s; opacity: 0; }
.delay-300 { animation-delay: 0.3s; opacity: 0; }

/* 頁首 Header */
.app-header {
    position: relative;
    padding: 24px 0 12px;
    text-align: center;
    background: radial-gradient(circle at 50% 0%, rgba(139, 92, 246, 0.15) 0%, transparent 60%);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    background: rgba(212, 175, 55, 0.05);
    padding: 4px 12px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 1.2rem;
    color: var(--color-accent);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.logo-text {
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-primary);
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #ffffff 40%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    max-width: 550px;
    margin: 0 auto;
}

/* 主版面佈局 */
.main-content {
    flex: 1;
    padding-bottom: 60px;
}

/* 卡片基礎樣式 */
.card {
    background-color: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    box-shadow: var(--shadow-md);
    transition: var(--transition-smooth);
    margin-bottom: 12px;
}

.card:hover {
    border-color: rgba(212, 175, 55, 0.3);
    box-shadow: 0 12px 45px rgba(0, 0, 0, 0.6);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 占卜模式選擇 */
.mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-mode {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: var(--transition-smooth);
}

.btn-mode i {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-top: 4px;
    transition: var(--transition-smooth);
}

.btn-mode div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mode-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mode-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.btn-mode:hover,
.btn-mode.active {
    border-color: var(--color-accent);
    background: rgba(212, 175, 55, 0.03);
    box-shadow: var(--shadow-neon-gold);
}

.btn-mode.active i {
    color: var(--color-accent);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* 牌桌區 (Table Card) */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    padding-bottom: 8px;
}

.step-indicator {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-accent-light);
}

.tarot-table {
    display: flex;
    justify-content: center;
    padding: 15px 0;
    min-height: 200px;
}

.spread-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

/* ==========================================================================
   3D 卡牌特效與結構 (3D Card Flip)
   ========================================================================== */

.tarot-placeholder {
    width: 100px;
    height: 165px;
    perspective: 1000px; /* 3D 視距 */
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transform-style: preserve-3d; /* 保留 3D 子元素 */
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: var(--radius-sm);
}

/* 洗牌動畫觸發 */
.shuffling .card-inner {
    animation: shuffle-anim 0.8s ease-in-out infinite;
}

/* 翻牌觸發 */
.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-back,
.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* 隱藏背面 */
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-sm);
    border: 2px solid var(--color-accent);
}

/* 牌背設計 */
.card-back {
    background-color: #0c0919;
    background-image: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.25) 0%, transparent 70%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) inset;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back::before {
    content: "\f005"; /* 星星圖示 */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 1.3rem;
    color: var(--color-accent);
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
}

/* 牌面設計 */
.card-front {
    background-color: #0e0d16;
    transform: rotateY(180deg); /* 預設翻轉 180 度隱藏 */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 8px 6px;
    box-shadow: var(--shadow-neon-gold) inset;
}

/* 逆位翻轉 */
.tarot-placeholder.reversed .card-front {
    transform: rotateY(180deg) rotateZ(180deg); /* 額外旋轉 Z 軸 180 度 */
}

/* 牌面內部圖示 */
.card-illustration {
    font-size: 1.8rem;
    color: var(--color-accent);
    text-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
    margin-top: 10px;
}

.card-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding-top: 4px;
    width: 90%;
}

.card-orientation {
    display: none; /* 隱藏，由程式碼控制 */
}

.slot-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

/* 牌意解析報告 */
.interpretation-card {
    background: radial-gradient(circle at 50% 0%, rgba(212, 175, 55, 0.05) 0%, transparent 70%);
}

.reading-block {
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    padding: 12px 0;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 14px;
    align-items: flex-start;
}

.reading-block:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.reading-block:first-child {
    padding-top: 0;
}

.reading-card-info {
    text-align: center;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(212, 175, 55, 0.1);
    padding: 8px 6px;
    border-radius: var(--radius-sm);
}

.reading-card-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-accent-light);
    margin-bottom: 4px;
}

.reading-card-orient {
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 50px;
    display: inline-block;
}

.orient-upright {
    color: var(--color-accent);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.orient-reversed {
    color: var(--color-primary);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.reading-text h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.reading-text .desc-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-style: italic;
}

.reading-text p {
    font-size: 0.85rem;
    color: #e2e8f0;
    text-align: justify;
}

/* 按鈕與小組件 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-light) 100%);
    color: #000000;
    box-shadow: var(--shadow-neon-gold);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.3);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    width: auto;
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.faq-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.faq-question {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.faq-answer {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 頁尾 */
.app-footer {
    padding: 30px 0;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: #555160;
}

.app-footer p {
    margin-bottom: 4px;
}

.github-badge {
    color: var(--color-primary);
    font-weight: 500;
}

/* ==========================================================================
   響應式排版 (Responsive Layout)
   ========================================================================== */

@media (max-width: 768px) {
    .mode-buttons {
        grid-template-columns: 1fr;
    }
    
    .spread-container {
        gap: 20px;
        flex-wrap: wrap; /* 讓三張牌在小螢幕自動換行 */
    }
    
    .reading-block {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .reading-card-info {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
    }
    
    .reading-card-name {
        margin-bottom: 0;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 16px;
    }
    
    .app-header h1 {
        font-size: 1.85rem;
    }
    
    .tarot-placeholder {
        width: 100px;
        height: 164px; /* 小螢幕小卡牌比例 */
    }
    
    .card-illustration {
        font-size: 1.85rem;
        margin-top: 12px;
    }
    
    .card-name {
        font-size: 0.75rem;
        padding-top: 6px;
    }
}

/* Amazon Affiliate Card Hover Effects */
.amz-item-card {
    transition: var(--transition-smooth);
}
.amz-item-card:hover {
    background: rgba(212, 175, 55, 0.08) !important;
    border-color: var(--color-accent) !important;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(212, 175, 55, 0.15), 0 0 15px rgba(212, 175, 55, 0.1);
}