/* =========================================
   1. CSS 變數定義 (配色方案)
   ========================================= */
:root {
    --bg-color: #f3f0e9;       /* 背景色：米白 */
    --primary-text: #4a3b32;   /* 主要文字：深咖 */
    --accent-gold: #d4af37;    /* 點綴色：金 */
    --accent-green: #6e8b74;   /* 點綴色：綠 */
    --card-bg: rgba(255, 255, 255, 0.85); /* 玻璃卡片底色 */
    --nav-height: 70px;
    --line-color: #06c755;     /* LINE 綠 */
    --ig-color: #E1306C;       /* IG 紅 */
}

/* =========================================
   2. 基礎重置與佈局
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Serif TC', serif; /* 請確保 HTML 有引入字體 */
    background-color: var(--bg-color);
    color: var(--primary-text);
    min-height: 100vh;
    padding-top: var(--nav-height);
    padding-bottom: 80px; /* 預留底部 Footer 空間 */
    overflow-x: hidden;
    line-height: 1.8;
    display: flex;
    flex-direction: column;
}

/* 背景圖層特效 */
.bg-decoration {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; opacity: 0.3;
    background-image: url('images/main-bg.png'); /* 請確認圖片路徑 */
    background-size: cover; background-position: center;
    filter: blur(15px);
}

/* =========================================
   3. 導覽列 (Navbar)
   ========================================= */
.navbar {
    position: fixed; top: 0; left: 0; width: 100%; height: var(--nav-height);
    background: rgba(243, 240, 233, 0.95); backdrop-filter: blur(5px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.nav-links { display: flex; gap: 30px; list-style: none; }
.nav-item {
    cursor: pointer; font-size: 1.1rem; font-weight: 600; color: var(--primary-text);
    padding: 8px 12px; border-bottom: 2px solid transparent; transition: 0.3s;
}
.nav-item:hover, .nav-item.active { color: var(--accent-green); border-bottom-color: var(--accent-green); }

/* =========================================
   4. 通用容器與元件
   ========================================= */
.container { width: 100%; max-width: 1000px; margin: 0 auto; padding: 40px 20px; flex: 1; }

/* 頁面切換動畫與隱藏工具 */
.page-section { display: none; animation: fadeIn 0.6s ease; }
.page-section.active { display: block; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* 玻璃擬態卡片容器 */
.glass-card {
    background: var(--card-bg); backdrop-filter: blur(10px);
    border-radius: 20px; padding: 40px;
    box-shadow: 0 10px 30px rgba(74, 59, 50, 0.08);
    margin-bottom: 30px; border: 1px solid rgba(255,255,255,0.6);
    position: relative;
}
.center-text { text-align: center; }

h2.section-title {
    text-align: center; margin-bottom: 30px; font-size: 2rem;
    color: var(--accent-green); border-bottom: 1px solid rgba(0,0,0,0.1); padding-bottom: 15px;
}
h3.content-title { font-size: 1.4rem; color: var(--accent-gold); margin: 30px 0 15px 0; font-weight: 900; }
p { margin-bottom: 15px; text-align: justify; }

/* 廣告橫幅 */
.ad-banner {
    background: #fffdf5; border: 1px solid var(--accent-gold); color: var(--primary-text);
    padding: 15px; border-radius: 10px; margin-bottom: 25px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.3s; text-decoration: none;
}
.ad-banner:hover { transform: scale(1.02); box-shadow: 0 5px 15px rgba(212, 175, 55, 0.2); }
.ad-badge { background: var(--accent-gold); color: #fff; font-size: 0.8rem; padding: 2px 8px; border-radius: 4px; margin-right: 10px; font-weight: bold; }

.hero-image { width: 100%; max-width: 400px; display: block; margin: 0 auto 30px auto; filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1)); }

/* 按鈕群組 */
.button-group { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.oracle-btn {
    background: transparent; border: 2px solid var(--accent-green); color: var(--accent-green);
    padding: 15px 25px; font-size: 1.1rem; border-radius: 50px; cursor: pointer;
    font-family: inherit; font-weight: 600; transition: 0.3s; min-width: 120px;
}
.oracle-btn:hover { background: var(--accent-green); color: white; }
.btn-career { border-color: #8b5e3c; color: #8b5e3c; } .btn-career:hover { background: #8b5e3c; }
.btn-job { border-color: #a0845a; color: #a0845a; } .btn-job:hover { background: #a0845a; }
.btn-love { border-color: #b56576; color: #b56576; } .btn-love:hover { background: #b56576; }

/* ==========================================================================
   5. ★ 核心修改：一字排開的捲動卡片區域
   ========================================================================== */

/* 牌桌區域 */
.card-area {
    position: relative;
    width: 100%;
    height: 350px; /* 高度足夠容納卡片懸停動畫 */
    margin-top: 20px;
    
    /* Flexbox 讓卡片橫向排列 */
    display: flex;
    align-items: center; 
    justify-content: flex-start; /* 從左側開始排 */
    
    /* 允許水平捲動 */
    overflow-x: auto;
    overflow-y: hidden;
    padding: 20px 40px; /* 左右內距，讓第一張和最後一張好點選 */
    
    /* 捲軸美化 (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold) transparent;
}
/* 捲軸美化 (Chrome/Safari) */
.card-area::-webkit-scrollbar { height: 8px; }
.card-area::-webkit-scrollbar-track { background: transparent; }
.card-area::-webkit-scrollbar-thumb { background-color: rgba(212, 175, 55, 0.5); border-radius: 20px; }

/* 單張卡片 */
.card {
    position: relative; 
    flex: 0 0 auto;     /* 關鍵：防止卡片被壓縮 */
    
    width: 120px;
    height: 200px;
    
    /* ★ 這裡設定卡片的重疊密度 */
    margin-right: -90px; 
    
    transform-style: preserve-3d;
    cursor: pointer;
    transition: transform 0.3s ease, margin-right 0.3s ease;
    border-radius: 10px;
    box-shadow: -5px 0 10px rgba(0,0,0,0.1);
}

/* 卡片懸停效果 (像抽牌一樣彈起來) */
.card:hover {
    transform: translateY(-40px); /* 往上浮 */
    margin-right: -20px;          /* 稍微推開旁邊的牌 */
    z-index: 1000;                /* 浮在最上層 */
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}

.card.unselectable { pointer-events: none; opacity: 0.5; filter: grayscale(1); }
.card.is-triggered { transform: scale(0.9); }

/* 卡片正反面 */
.card-face {
    width: 100%; height: 100%; position: absolute;
    backface-visibility: hidden; border-radius: 10px;
    background-size: cover; background-position: center;
    border: 1px solid #ddd;
}
.card-back {
    /* 這裡可以放您的牌背圖片 */
    background-image: url('images/new-back.jpg'); 
    background-color: #4a3b32; /* 圖片載入前的備用色 */
}
.card-front { transform: rotateY(180deg); background-color: #fff; }

/* --- 抽出的鬼牌 (Ghost Card) 動畫 --- */
.ghost-card {
    width: 120px; height: 200px;
    position: fixed; z-index: 9999;
    transform-style: preserve-3d;
    transition: all 1s ease-in-out;
    pointer-events: none; border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}
.ghost-card .card-face { width: 100%; height: 100%; position: absolute; backface-visibility: hidden; }
.ghost-card .card-back { background-image: url('images/new-back.jpg'); background-color: #4a3b32; }
.ghost-card .card-front { transform: rotateY(180deg); background-color: #fff; background-size: cover; }

/* 翻轉動畫終點 */
.ghost-card.is-flipped {
    top: 50% !important; left: 50% !important;
    transform: perspective(1000px) translate(-50%, -50%) rotateY(180deg) scale(1.5) !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

/* =========================================
   6. 結果頁與其他內容
   ========================================= */
.result-card-item { text-align: center; margin-bottom: 20px; }
.responsive-image {
    max-width: 100%; height: auto; border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); margin-bottom: 15px;
    max-height: 350px; object-fit: contain;
}
.instruction-card-item {
    background: #fff; padding: 20px; border-radius: 10px;
    border-left: 4px solid var(--accent-gold); margin-bottom: 40px; text-align: left;
}
.parenet-result-item { border-bottom: 1px dashed #ccc; padding-bottom: 20px; margin-bottom: 20px; }
.parenet-result-item:last-child { border-bottom: none; }

/* 緣起與文章頁 */
.step-box { background: rgba(255,255,255,0.5); padding: 20px; border-left: 4px solid var(--accent-gold); margin-bottom: 15px; border-radius: 0 10px 10px 0; }
.step-title { font-weight: bold; color: var(--primary-text); margin-bottom: 5px; display: block;}
.highlight-box { background: #fffdf5; border: 1px solid var(--accent-gold); padding: 30px; border-radius: 10px; text-align: center; margin-top: 30px; }
.quote { font-style: italic; font-size: 1.2rem; color: var(--accent-gold); margin: 20px 0; font-weight: bold; }

.article-card { background: #fff; border-radius: 15px; padding: 25px; margin-bottom: 20px; border: 1px solid #eee; cursor: pointer; transition: 0.3s; }
.article-card:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
.article-header { display: flex; justify-content: space-between; align-items: center; }
.article-title-text { font-size: 1.3rem; font-weight: bold; color: var(--primary-text); }
.expand-icon { font-size: 1.5rem; color: var(--accent-green); transition: 0.3s; }
.article-content { max-height: 0; overflow: hidden; transition: max-height 0.5s ease-out; opacity: 0; }
.article-card.open .article-content { max-height: 3000px; opacity: 1; margin-top: 20px; border-top: 1px dashed #ddd; padding-top: 20px; }
.article-card.open .expand-icon { transform: rotate(180deg); }

/* Footer & FAB */
.site-footer { text-align: center; padding: 30px 20px; background: rgba(74, 59, 50, 0.05); margin-top: auto; }
.social-links { margin-bottom: 15px; display: flex; justify-content: center; gap: 20px; }
.social-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 20px; border-radius: 30px; text-decoration: none; font-weight: bold; font-size: 0.9rem; transition: 0.3s; border: 1px solid rgba(0,0,0,0.1); }
.social-btn.line { background-color: #fff; color: var(--line-color); border-color: var(--line-color); }
.social-btn.line:hover { background-color: var(--line-color); color: #fff; }
.social-btn.ig { background-color: #fff; color: var(--ig-color); border-color: var(--ig-color); }
.social-btn.ig:hover { background-color: var(--ig-color); color: #fff; }
.fab-line { position: fixed; bottom: 30px; right: 30px; width: 60px; height: 60px; background-color: var(--line-color); color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 4px 15px rgba(6, 199, 85, 0.4); cursor: pointer; z-index: 9999; text-decoration: none; font-weight: 900; font-size: 1.2rem; transition: transform 0.3s; }
.fab-line:hover { transform: scale(1.1) rotate(10deg); }
.fab-text { font-family: sans-serif; letter-spacing: -1px;}

/* =========================================
   7. RWD 手機版適配 (最佳化抽牌體驗)
   ========================================= */
@media (max-width: 768px) {
    /* 1. 調整容器內距，讓左右滑動更順暢 */
    .card-area {
        height: 260px;       /* 高度適中 */
        padding: 20px 20px;  /* 上下左右留白 */
        
        /* 讓捲軸在 iOS 上滑動更有慣性 */
        -webkit-overflow-scrolling: touch; 
        
        /* 確保內容靠左對齊，不會因為 justify-content: center 而被切掉 */
        justify-content: flex-start; 
    }

    /* 2. 卡片本體設定 */
    .card { 
        width: 100px;        /* 稍微加大一點點寬度，比較好點 */
        height: 160px; 
        
        /* ★ 關鍵修改：手機版不要疊太密！ */
        /* 改成 -20px (輕微重疊) 或 10px (完全分開) */
        /* 這裡建議 -25px，保留一點層次感但又好點 */
        margin-right: -25px; 
        
        /* 確保卡片不會被擠壓變形 */
        flex-shrink: 0; 
    } 

    /* 3. 手機版的互動優化 */
    .card:hover { 
        /* 手機上移除「推開鄰居」的效果，因為手指沒有懸停 */
        margin-right: -25px; 
        
        /* 點擊瞬間稍微上浮即可 */
        transform: translateY(-15px); 
    }
    
    /* 修正最後一張牌的右邊距，確保滑到底看得到 */
    .card:last-child {
        margin-right: 20px !important;
    }

    /* 鬼牌大小也要同步 */
    .ghost-card { width: 100px; height: 160px; }
    
    /* 調整按鈕大小，避免手指不好點 */
    .oracle-btn {
        width: 100%;
        margin-bottom: 10px;
        padding: 12px;
    }
    
    /* 隱藏裝飾背景，提升手機效能 */
    .hero-image {
        max-width: 80%;
    }
}
/* 點擊瞬間的高亮效果 */
.card.is-triggered {
    transform: scale(0.95);
    filter: brightness(1.2); /* 變亮 */
    box-shadow: 0 0 15px var(--accent-gold); /* 發出金光 */
}