/* ==========================================================================
   1. 核心變數與全域設定 (Global Settings)
   ========================================================================== */
:root {
    --bg-dark: #0f0a1e;
    --bg-card: rgba(28, 20, 53, 0.9);
    --primary-purple: #6a4c93;
    --accent-purple: #be95c4;
    --gold: #e5c687;
    --text-light: #e5e5f7;
    --safe-bottom: env(safe-area-inset-bottom); /* iPhone 底部安全區域 */
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: 'Noto Serif TC', serif;
    line-height: 1.5;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px; /* 為底部導覽留空間 */
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==========================================================================
   2. 視覺特效：星空與動畫 (Visual Effects)
   ========================================================================== */
.stars-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; background: var(--bg-dark);
}

.stars {
    position: absolute; width: 200%; height: 200%;
    background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/123163/stars.png') repeat;
}

.twinkling {
    position: absolute; width: 100%; height: 100%;
    background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/123163/twinkling.png') repeat;
    animation: move-twinkling 200s linear infinite;
}

@keyframes move-twinkling {
    from { background-position: 0 0; }
    to { background-position: -10000px 5000px; }
}

/* ==========================================================================
   3. 導覽系統 (Navigation) - 頂部與手機底部
   ========================================================================== */
/* 頂部導覽列 */
.navbar {
    height: 60px;
    background: rgba(15, 10, 30, 0.9);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center;
}

.nav-content { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.desktop-only { display: none; } 

/* 手機底部導覽 (iPhone 優化) */
.mobile-bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: rgba(20, 15, 40, 0.95);
    backdrop-filter: blur(20px);
    display: flex; justify-content: space-around;
    padding-top: 10px;
    padding-bottom: calc(10px + var(--safe-bottom)); 
    border-top: 1px solid rgba(190, 149, 196, 0.2);
    z-index: 1000;
}

.nav-item { text-decoration: none; color: var(--text-light); text-align: center; }
.nav-item span { font-size: 1.3rem; display: block; }
.nav-item small { font-size: 0.7rem; color: var(--accent-purple); }

/* ==========================================================================
   4. 主視覺與通用區塊 (Hero & Sections)
   ========================================================================== */
.hero { padding: 40px 0; text-align: center; }
.hero h1 { font-size: 2rem; color: var(--gold); line-height: 1.3; }

.section { 
    padding: 30px 0; 
    scroll-margin-top: 70px; /* 避免標題被導覽列遮住 */
}

.section-title { text-align: center; margin-bottom: 20px; color: var(--accent-purple); }
.section-title small {
    font-size: 0.9rem;
    color: var(--accent-purple);
    font-weight: normal;
    letter-spacing: 2px;
}

.btn-primary {
    display: inline-block; 
    background: var(--gold); 
    color: #1a0b2e;
    padding: 10px 25px; 
    border-radius: 50px; 
    text-decoration: none;
    margin-top: 15px; 
    font-weight: bold;
}

.btn-header {
    display: inline-block; 
    background: var(--gold); 
    color: #1a0b2e;
    padding: 10px 25px; 
    border-radius: 50px; 
    text-decoration: none;
    margin-top: auto; 
    font-weight: bold;
}

/* ==========================================================================
   5. 塔羅百科區塊 (Tarot Wiki) - 滑動與卡片
   ========================================================================== */
/* 橫向滑動容器 */
.wiki-rel-container {
    position: relative;
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    /* 增加左右內距，為箭頭騰出空間 */
    padding: 0 50px;
}

.wiki-rel-container::before,
.wiki-rel-container::after {
    content: "";
    position: absolute;
    top: 0;
    width: 60px;
    height: 100%;
    z-index: 2;
    pointer-events: none; /* 確保不影響點擊 */
}

.wiki-rel-container::before {
    left: 50px;
    background: linear-gradient(to right, var(--bg-dark), transparent);
}

.wiki-rel-container::after {
    right: 50px;
    background: linear-gradient(to left, var(--bg-dark), transparent);
}

.wiki-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    scrollbar-width: none;
    scroll-behavior: smooth; /* 確保所有的滾動都有平滑動畫 */
}

.wiki-scroll-wrapper::-webkit-scrollbar { display: none; }
.wiki-scroll-wrapper.active { cursor: grabbing; transform: scale(0.99); }

.wiki-scroll-content {
    display: flex;
    flex-wrap: nowrap; /* 重要：強制卡片排成一列，不准換行 */
    gap: 20px;
    padding: 20px 5%;
    width: max-content; /* 重要：確保容器寬度隨卡片數量增加 */
    min-width: 100%;
}

/* 分組標題 */
.wiki-group-header {
    margin: 30px 0 15px 5%;
    border-left: 3px solid var(--gold);
    padding-left: 15px;
}
.wiki-group-header h3 { color: var(--gold); font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.wiki-group-header p { font-size: 0.8rem; opacity: 0.6; margin-top: 5px; }

/* 導覽箭頭 */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(40, 30, 70, 0.6); /* 更透明的背景 */
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: none; 
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 將箭頭貼在容器最左右兩端，避開卡片 */
.nav-arrow.left { left: 0; }
.nav-arrow.right { right: 0; }

/* 懸停時的微互動：稍微放大並發光 */
.nav-arrow:hover {
    background: var(--gold);
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(229, 198, 135, 0.6);
    transform: translateY(-50%) scale(1.1);
}

/* 牌卡元件 */
/* 3D 容器設定 */
.tarot-card-item {
    flex: 0 0 150px; /* 重要：0 0 表示不放大、不壓縮，固定 150px */
    width: 150px;
    height: 280px;
    perspective: 1000px;
    opacity: 0.85;
    scroll-snap-align: start; /* 改為 start，載入時靠左 */
    transition: transform 0.6s, opacity 0.4s;
}

.card-inner-3d {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d; /* 開啟 3D 空間 */
    transform-origin: center center;
}

.card-inner-3d img {
    pointer-events: none; /* 確保滑鼠點擊能穿透圖片，由外層卡片接收 */
}

/* 翻開狀態：全亮並增加發光感 */
.tarot-card-item.flipped {
    opacity: 1;
    z-index: 10; /* 確保翻轉時在最上層 */
}

/* 翻轉觸發狀態 */
.tarot-card-item.flipped .card-inner-3d {
    transform: rotateY(180deg);
    box-shadow: 0 0 30px rgba(229, 198, 135, 0.3); /* 金色光暈 */
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* 翻到背面時隱藏正面 */
    border-radius: 12px;
    border: 1px solid var(--gold);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

/* 正面樣式 */
.card-front {
    background: var(--bg-card);
}

/* 背面樣式 */
.card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #2a1b4d, #1a0b2e);
    color: var(--gold);
    padding: 15px;
    display: flex; /* 開啟 Flex */
    flex-direction: column;
}

/* 內容區域 */
.back-content {
    display: flex;
    flex-direction: column;
    height: 100%; /* 撐滿背面高度 */
    width: 100%;
    text-align: center;
}

.back-content h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--gold);
}

.back-content ul {
    /* list-style: none;
    padding: 0;
    margin: 10px 0;
    font-size: 0.9rem; */
    list-style: none;
    padding: 0;
    margin: 0;
    
    /* 核心：讓 ul 佔據剩餘的所有空間 */
    flex-grow: 1; 
    
    /* 核心：開啟垂直 Flex 佈局並平均分配高度 */
    display: flex;
    flex-direction: column;
    justify-content: space-evenly; /* 平均分配各項之間的間距 */
    align-items: center;
}

.back-content li {
    font-size: 0.95rem;
    color: var(--text-light);
    width: 100%;
    padding: 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 底部提示文字：核心調整 */
.flip-hint {
    margin-top: auto; /* 重點：這會把元素推向容器的最底部 */
    font-size: 0.75rem;
    opacity: 0.6;
    padding-bottom: 5px; /* 與卡片邊框保持一點距離 */
    border-top: 1px solid rgba(229, 198, 135, 0.2); /* 加一條隱約的分隔線更有質感 */
    width: 100%;
    padding-top: 10px;
    text-align: center;
    animation: hintPulse 2s infinite;
}
@keyframes hintPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* 滑動狀態與懸停 */
.card-inner:hover {
    border-color: var(--gold);
    transform: translateY(-10px);
    box-shadow: 0 10px 25px rgba(106, 76, 147, 0.5);
}

.scroll-hint { text-align: center; font-size: 0.8rem; opacity: 0.5; margin-top: -10px; }

/* ==========================================================================
   6. 其他功能區塊 (Horo, Lock, Consultant)
   ========================================================================== */
/* 每日運勢網格 */
/* .horo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.horo-item { background: var(--bg-card); padding: 15px; border-radius: 10px; text-align: center; border: 1px solid var(--primary-purple); } */

/* 運勢展示區 */
.horo-card-stage {
    /* display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1500px;
    padding: 60px 0; */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 40px 0;
    
}

/* 專屬運勢底座視覺 */
.horo-card-stage::after {
    content: "";
    position: absolute;
    bottom: 40px;
    width: 150px;
    height: 20px;
    background: radial-gradient(ellipse at center, rgba(229, 198, 135, 0.3) 0%, transparent 70%);
    filter: blur(5px);
    z-index: -1;
}

/* 運勢主卡片：比百科卡片更大 */
.horo-main-card {
    /* flex: 0 0 400px;
    height: 420px;
    margin: 0 auto; */
    /* 1. 使用 width 並搭配 !important 確保不被 .tarot-card-item 覆蓋 */
    width: 300px !important; 
    height: 450px !important;
    
    /* 2. 取消 flex 限制 */
    flex: 0 0 auto !important; 
    
    cursor: pointer;
    perspective: 1500px;
}

/* 確保內部的 3D 容器也跟著變大 */
.horo-main-card .card-inner-3d,
.horo-main-card .card-front,
.horo-main-card .card-back {
    width: 100%;
    height: 100%;
}

/* 運勢卡片翻開後的背面內容 (讓字數多時也能垂直置中) */
.horo-main-card .back-content {
    justify-content: center; /* 運勢卡片文字通常較少，置中較好看 */
    gap: 20px;
    padding: 25px;   /* 增加內距，讓文字更有呼吸感 */
    text-align: left; /* 加寬後，文字靠左對齊會比居中更好讀 */
}

.horo-main-card .horo-title {
    font-size: 1.2rem;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--gold);
    padding-bottom: 10px;
    text-align: center; /* 標題維持置中 */
}

.horo-main-card .horo-details li {
    font-size: 0.95rem;
    margin-bottom: 12px;
    line-height: 1.6;
    list-style: none;
    position: relative;
    padding-left: 20px;
}

/* 加上一個漂亮的小裝飾點 */
.horo-main-card .horo-details li::before {
    content: "◈";
    position: absolute;
    left: 0;
    color: var(--gold);
    font-size: 0.8rem;
}

/* 增加神祕的紫色光暈 */
.horo-main-card .card-inner-3d {
    box-shadow: 0 0 50px rgba(106, 76, 147, 0.4);
}

/* 當卡片翻開時，增加金色邊框閃爍感 */
.horo-main-card.flipped .card-inner-3d {
    box-shadow: 0 0 60px rgba(229, 198, 135, 0.5);
    border: 2px solid var(--gold);
}

.horo-instruction {
    text-align: center;
    color: var(--gold);
    letter-spacing: 3px;
    animation: fadeInOut 2s infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* 針對行動端進行寬度適應 */
@media (max-width: 480px) {
    .horo-main-card {
        flex: 0 0 85vw; /* 在小螢幕手機上佔據 85% 寬度 */
        height: 450px;
    }
}

/* 行動端適應：如果螢幕太小，縮小至螢幕寬度的 80% */
@media (max-width: 400px) {
    .horo-main-card {
        width: 80vw !important;
        height: 120vw !important; /* 維持比例 */
    }
}


/* 會員鎖定區 */
.feature-split { display: flex; flex-direction: column; gap: 15px; }
.lock-card { background: var(--bg-card); padding: 20px; border-radius: 15px; border: 1px solid var(--accent-purple); text-align: center; }
.lock-overlay { background: rgba(0,0,0,0.3); padding: 20px; border-radius: 10px; margin-top: 10px; }

/* 占卜師卡片 */
.consultant-card { background: var(--bg-card); padding: 25px; border-radius: 20px; border: 1px solid var(--gold); text-align: center; }
.avatar-placeholder 
{ 
    width: 150px; 
    height: 150px; 
    background: var(--primary-purple); 
    border-radius: 50%; 
    margin: 0 auto 10px; 
    border: 2px solid var(--gold); 
}
.tags span { font-size: 0.7rem; background: var(--primary-purple); padding: 2px 8px; border-radius: 10px; margin: 0 3px; }

/* ==========================================================================
   7. 媒體查詢 (Media Queries) - 自適應優化
   ========================================================================== */
@media (min-width: 768px) {
    .desktop-only { display: flex; list-style: none; gap: 20px; }
    .mobile-bottom-nav { display: none; }
    body { padding-bottom: 0; }
    .hero h1 { font-size: 3rem; }
    .horo-grid { grid-template-columns: repeat(4, 1fr); }
    .feature-split { flex-direction: row; }
    .lock-card { flex: 1; }
    .section { padding: 60px 0; }
}

@media (min-width: 1024px) {
    .wiki-rel-container:hover .nav-arrow { display: flex; } /* 僅電腦端 Hover 顯示箭頭 */
    .tarot-card-item { flex: 0 0 160px; } /* 電腦版卡片加大 */
}

