@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lato:wght@300;400&display=swap');

/* =========================================
   1. 全域變數與基礎設定 (Variables & Reset)
   ========================================= */
:root {
    --color-gold: #fbbf24;       /* 亮琥珀色 */
    --color-bg-dark: #0f172a;    /* 深藍黑背景 */
    --color-input-bg: #1e293b;   /* 輸入框背景 */
    
    /* 卡片尺寸 (1.7 ratio) */
    --card-width: 120px;
    --card-height: 204px;
}

/* 手機版尺寸調整 */
@media (max-width: 768px) {
    :root {
        --card-width: 75px;
        --card-height: 128px;
    }
}

* { box-sizing: border-box; }

body {
    background-color: var(--color-bg-dark);
    background-image: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
    color: #e2e8f0;
    font-family: 'Lato', sans-serif;
    min-height: 100vh;
    margin: 0; padding: 0;
    overflow-x: hidden;
}

h1, h2, h3, .card-title { font-family: 'Cinzel', serif; }

/* =========================================
   2. 儀式感模組 (Overlays & Hints)
   ========================================= */

/* [NEW] 手機橫屏提示遮罩 */
#rotate-hint {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.98);
    z-index: 99999;
    flex-direction: column; justify-content: center; align-items: center;
    color: var(--color-gold); text-align: center;
}

/* 僅在「手機直向」且「Body 有 show-rotate-hint 類別」時顯示 */
@media (max-width: 768px) and (orientation: portrait) {
    body.show-rotate-hint #rotate-hint { display: flex; }
}

/* [NEW] 冥想引導層 */
#meditation-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    z-index: 5000;
    display: none;
    flex-direction: column; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.5s ease-in-out;
}

/* [移入 CSS] 廣告 Modal (原本在 HTML head) */
#ad-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 9999;
    display: none; flex-direction: column;
    justify-content: center; align-items: center; color: white;
}

/* =========================================
   3. 輸入元件優化 (High Contrast Inputs)
   ========================================= */
select, textarea, input {
    width: 100%;
    background-color: var(--color-input-bg) !important;
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: var(--color-gold) !important;
    padding: 1rem; border-radius: 8px;
    outline: none; font-size: 1rem;
    font-family: 'Lato', sans-serif;
    transition: all 0.3s ease;
    -webkit-appearance: none; appearance: none;
}

select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
    padding-right: 2.5rem;
}

option { background-color: var(--color-bg-dark); color: var(--color-gold); padding: 10px; }

select:focus, textarea:focus, input:focus {
    background-color: #020617 !important;
    border-color: var(--color-gold);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.2);
}

::placeholder { color: rgba(251, 191, 36, 0.4) !important; }

/* =========================================
   4. 扇形牌堆系統 (Arc Fan Deck)
   ========================================= */
.deck-container-fixed {
    position: relative;
    width: 100%; height: 320px;
    display: flex; justify-content: center; align-items: flex-end;
    perspective: 1000px;
    overflow: visible; /* 允許卡片 Hover 時超出邊界 */
}

.deck-card-fan {
    position: absolute;
    bottom: 0; left: 50%;
    margin-left: calc(var(--card-width) / -2); /* 修正中心點 */
    width: var(--card-width);
    height: var(--card-height);
    transform-origin: 50% 150%; /* 扇形圓心 */
    
    cursor: pointer;
    box-shadow: -2px 0 5px rgba(0,0,0,0.5);
    background-image: url('http://localhost:8000/images/Back.jpg');
    background-size: cover;
    border-radius: 6px;
    border: 1px solid rgba(251, 191, 36, 0.3);
    will-change: transform;
    transition: box-shadow 0.3s, border-color 0.3s; 
}

.deck-card-fan:hover {
    z-index: 1000 !important;
    border-color: var(--color-gold);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.8);
}

.deck-card-fan.chosen {
    opacity: 0; pointer-events: none;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

@keyframes shuffle-spread {
    0% { transform: rotate(0deg) translateY(200px) scale(0.5); opacity: 0; }
    100% { opacity: 1; } 
}
.animate-shuffle {
    animation: shuffle-spread 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* =========================================
   5. 聖壇與卡片 (Altar & 3D Flip)
   ========================================= */
.altar-stage {
    perspective: 1200px; padding: 0;
    display: flex; justify-content: center; width: 100%;
}

.card {
    width: var(--card-width); height: var(--card-height);
    position: relative; perspective: 1000px; margin: 0 auto;
}

.card:not(.flipped) { cursor: pointer; }
.card:not(.flipped):hover .card-inner {
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.6);
    border-color: var(--color-gold);
    transform: translateY(-8px);
}

.card-inner {
    width: 100%; height: 100%;
    position: relative; text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    border-radius: 8px;
    border: 1px solid transparent;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
}

.card-front, .card-back {
    position: absolute; width: 100%; height: 100%;
    -webkit-backface-visibility: hidden; backface-visibility: hidden;
    border-radius: 8px; overflow: hidden;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.card-front { background-color: #1e293b; }
.card-back { background-color: var(--color-bg-dark); transform: rotateY(180deg); }
.card img { width: 100%; height: 100%; object-fit: cover; }
.is-reversed { transform: rotate(180deg); }

/* =========================================
   6. UI 組件與文字特效
   ========================================= */
.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px; padding: 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.ad-wall {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 12px; padding: 2rem;
    text-align: center; margin-top: 1.5rem;
    animation: fadeIn 1s ease-out;
    width: 100%; max-width: 600px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.btn-ritual {
    background: linear-gradient(45deg, #b45309, #fbbf24);
    color: #0f172a;
    font-family: 'Cinzel', serif; font-weight: bold;
    text-transform: uppercase; letter-spacing: 0.1em;
    padding: 0.8rem 2rem; border-radius: 50px;
    border: none; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(251, 191, 36, 0.3);
}
.btn-ritual:hover { transform: translateY(-2px); box-shadow: 0 0 20px rgba(251, 191, 36, 0.6); }

/* [重要] 文字光暈 */
.text-shadow-glow {
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.7), 0 0 20px rgba(251, 191, 36, 0.4);
}

/* =========================================
   7. 星辰啟示排版 (Markdown Typography)
   ========================================= */
.interpretation-text {
    font-family: 'Lato', sans-serif;
    color: #e2e8f0; line-height: 1.8; font-size: 1.05rem;
}
.interpretation-text h1, .interpretation-text h2, .interpretation-text h3 {
    font-family: 'Cinzel', serif; color: var(--color-gold);
    margin-top: 1.5rem; margin-bottom: 0.8rem;
    border-bottom: 1px solid rgba(251, 191, 36, 0.2);
    padding-bottom: 0.5rem; font-weight: 700;
}
.interpretation-text h3 { font-size: 1.4rem; }
.interpretation-text strong, .interpretation-text b {
    color: #fff; font-weight: 700;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}
.interpretation-text ul, .interpretation-text ol {
    margin-left: 1.5rem; margin-bottom: 1rem;
    list-style-type: disc; color: #cbd5e1;
}
.interpretation-text li { margin-bottom: 0.5rem; padding-left: 0.5rem; }
.interpretation-text p { margin-bottom: 1rem; text-align: justify; }

/* 逐段顯現動畫 */
.reveal-element {
    opacity: 0; transform: translateY(10px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.reveal-visible { opacity: 1; transform: translateY(0); }

/* =========================================
   8. 動畫 (Animations)
   ========================================= */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in-down { animation: fadeIn 1s ease-out; }

.fade-out { animation: fadeOut 0.8s forwards; pointer-events: none; }
@keyframes fadeOut { 0% { opacity: 1; } 100% { opacity: 0; transform: translateY(30px); } }

.loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(251, 191, 36, 0.3);
    border-radius: 50%; border-top-color: var(--color-gold);
    animation: spin 1s infinite linear; margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* [NEW] 補上缺漏的慢速旋轉動畫 (給手機提示用) */
.animate-spin-slow {
    animation: spin 3s linear infinite;
}