*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* ── Spathodea Flame Tree Palette ── */
    --ember: #FF4500;
    /* deep orange-red */
    --flame: #FF6B35;
    /* vivid orange */
    --amber: #FFB347;
    /* warm amber */
    --gold: #FFCE5C;
    /* golden yellow */
    --cream: #FFF3E0;
    /* warm cream */
    --char: #1A0800;
    /* near-black with red tint */
    --dim: rgba(255, 107, 53, 0.18);
}

html {
    scroll-behavior: smooth;
}

body {
    background: #100500;
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
    color: var(--cream);
}

/* ───── CANVAS ───── */
#bg-3d {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ───── PAGE BASE ───── */
.page {
    position: relative;
    z-index: 10;
    min-height: 100vh;
}

/* ───── HERO SECTION ───── */
#hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    text-align: center;
    padding: 0 24px;
}

/* Main title */
.hero-title {
    display: flex;
    gap: 0;
    font-weight: 900;
    font-size: clamp(3.5rem, 12vw, 9rem);
    line-height: 1;
    letter-spacing: -0.01em;
    user-select: none;
}

/* Each character: starts above (-90px) and drops down */
.hero-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(-90px) scale(0.8);
    background: linear-gradient(165deg,
            var(--cream) 0%,
            var(--gold) 30%,
            var(--flame) 60%,
            var(--ember) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 36px rgba(255, 107, 53, 0.65));
}

/* Subtitle */
.hero-sub {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: 300;
    letter-spacing: 0.06em;
    color: rgba(255, 243, 224, 0.65);
    opacity: 0;
    transform: translateY(20px);
    max-width: 480px;
}

/* Scroll hint */
.scroll-hint {
    position: absolute;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    color: rgba(255, 179, 71, 0.55);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    /* 可點擊 */
    cursor: pointer;
    user-select: none;
    transition: color 0.25s, opacity 0.25s;
}

.scroll-hint:hover {
    color: rgba(255, 179, 71, 0.9);
}

.scroll-hint .arrow {
    width: 20px;
    height: 20px;
    border-right: 2px solid rgba(255, 179, 71, 0.55);
    border-bottom: 2px solid rgba(255, 179, 71, 0.55);
    transform: rotate(45deg);
    animation: bounce 1.6s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: rotate(45deg) translateY(0);
    }

    50% {
        transform: rotate(45deg) translateY(6px);
    }
}

/* ───── NAV-GRID SECTION (Page 2) ───── */
#nav-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px 60px;
    text-align: center;
}

.section-label {
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--amber);
    margin-bottom: 12px;
    opacity: 0;
}

.section-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--cream) 0%, var(--amber) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0;
    opacity: 0;
}

.glow-line {
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--flame), transparent);
    border-radius: 9999px;
    margin: 20px auto 48px;
    opacity: 0;
}

/* ── 2×2 Quad Grid ── */
.quad-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 860px;
}

.quad-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 28px 28px 28px;
    border-radius: 20px;
    /* 固定卡片高度，不讓内容擐開 */
    height: 280px;
    min-height: unset;
    text-decoration: none;
    color: var(--cream);
    overflow: hidden;
    border: 1px solid rgba(255, 107, 53, 0.15);
    backdrop-filter: blur(16px);
    background: rgba(255, 69, 0, 0.04);
    opacity: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
}

/* Per-card accent glow overlay
   ⚠ 不使用 color-mix()：LINE WebView / 舊版 Chromium 不支援
     改用各卡片預設 RGBA 硬編碼 fallback                        */
.quad-bg {
    position: absolute;
    inset: 0;
    /* fallback: 橙紅色，各卡會被 inline style 的 --accent 覆蓋 */
    background: radial-gradient(ellipse at 80% 20%,
            rgba(255, 69, 0, 0.25),
            transparent 65%);
    border-radius: inherit;
    transition: opacity 0.35s ease;
    z-index: 0;
}

/* 各卡片 accent 背景（LINE/舊版瀏覽器安全寫法） */
#qcard0 .quad-bg { background: radial-gradient(ellipse at 80% 20%, rgba(255, 69,  0,  0.28), transparent 65%); }
#qcard1 .quad-bg { background: radial-gradient(ellipse at 80% 20%, rgba(255,140, 66,  0.28), transparent 65%); }
#qcard2 .quad-bg { background: radial-gradient(ellipse at 80% 20%, rgba(255,179, 71,  0.28), transparent 65%); }
#qcard3 .quad-bg { background: radial-gradient(ellipse at 80% 20%, rgba(255,206, 92,  0.28), transparent 65%); }

/* Hover 通用 */
.quad-card:hover {
    transform: translateY(-6px) scale(1.02);
    /* fallback 邊框色（橙色，不用 color-mix） */
    border-color: rgba(255, 107, 53, 0.6);
    box-shadow:
        0 0 44px rgba(255, 107, 53, 0.35),
        inset 0 0 24px rgba(255, 107, 53, 0.12);
}

/* 各卡 Hover 邊框 + 陰影（LINE 安全） */
#qcard0:hover { border-color: rgba(255, 69,  0,  0.65); box-shadow: 0 0 44px rgba(255, 69,  0,  0.35), inset 0 0 24px rgba(255, 69,  0,  0.12); }
#qcard1:hover { border-color: rgba(255,140, 66,  0.65); box-shadow: 0 0 44px rgba(255,140, 66,  0.35), inset 0 0 24px rgba(255,140, 66,  0.12); }
#qcard2:hover { border-color: rgba(255,179, 71,  0.65); box-shadow: 0 0 44px rgba(255,179, 71,  0.35), inset 0 0 24px rgba(255,179, 71,  0.12); }
#qcard3:hover { border-color: rgba(255,206, 92,  0.65); box-shadow: 0 0 44px rgba(255,206, 92,  0.35), inset 0 0 24px rgba(255,206, 92,  0.12); }

.quad-card:hover .quad-bg {
    opacity: 1.5;
}

/* 圖示外框 */
.quad-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    font-size: 2.4rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 16px var(--accent, #FF6B35));
}

/* PNG 圖示大小限制 */
.quad-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 10px;
}

/* 卡片底部文字區 */
.quad-meta {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    /* 确保對齊卡片底部 */
    margin-top: auto;
}

/* ── 預覽圖：鋪滿整張卡片當背景，預設模糊 ── */
.quad-preview {
    position: absolute;
    inset: 0;                   /* 完整覆蓋卡片 */
    overflow: hidden;
    border-radius: inherit;
    z-index: 1;
}

/* 底部文字遮罩：讓圖示/標題在圖片上仍清晰可讀 */
.quad-preview::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(16, 5, 0, 0.10) 0%,
        rgba(16, 5, 0, 0.55) 55%,
        rgba(16, 5, 0, 0.85) 100%
    );
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

.quad-preview-img {
    width: 100%;
    height: 100%;
    /* 顯示完整圖片，不裁切 */
    object-fit: contain;
    object-position: center center;
    background: #0d0300;        /* contain 留白時補深色底 */
    /* 預設模糊 + 微縮 */
    filter: blur(7px) brightness(0.55);
    transform: scale(1.04);
    transition:
        filter  0.5s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

/* Hover：清晰 + 小彈出 */
.quad-card:hover .quad-preview-img {
    filter: blur(0px) brightness(0.85);
    transform: scale(1.08);
}

.quad-card h3 {
    position: relative;
    z-index: 1;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--cream);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.quad-card p {
    position: relative;
    z-index: 1;
    font-size: 0.85rem;
    font-weight: 300;
    line-height: 1.6;
    color: rgba(255, 243, 224, 0.50);
}

.quad-arrow {
    position: absolute;
    top: 24px;
    right: 28px;
    z-index: 1;
    font-size: 1.3rem;
    color: rgba(255, 207, 100, 0.3);
    transition: color 0.3s, transform 0.3s;
}

.quad-card:hover .quad-arrow {
    color: var(--gold);
    transform: translateX(5px);
}

/* ───── LOADING OVERLAY ───── */
#loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #100500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 107, 53, 0.18);
    border-top-color: #FF6B35;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ───── RESPONSIVE ───── */
@media (max-width: 600px) {
    .quad-grid {
        grid-template-columns: 1fr;
    }

    .quad-card {
        height: 240px;
    }

    .quad-preview {
        height: 50%;
    }
}