/* --- 1. 變數設定 --- */
:root {
    /* 您的個人網站配色 */
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --accent-color: #f47c7c;
    --light-bg: #f8f9fa;
    --dark-bg: #343a40; /* Footer 背景色 */
    --text-color: #212529;
    --light-text: #f8f9fa;
    
    /* 文章排版專用 */
    --text-secondary: #6c757d; /* 灰色 */
    --border-color: #e1e4e8;
    --nav-height: 60px;
    --font-stack: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: var(--font-stack);
    line-height: 1.8;
    color: var(--text-color);
    background-color: white;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    padding-top: var(--nav-height);
}

/* --- 2. Global Header --- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
}

/* [修改] Logo 設定：深色背景色、移除手機點擊高亮 */
.site-logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--dark-bg); /* 改成跟 Footer 背景一樣的深色 */
    text-decoration: none;
    letter-spacing: 0.5px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

/* [修改] Logo 互動邏輯：電腦 Hover 變色無底線 */
@media (hover: hover) {
    .site-logo:hover {
        color: var(--primary-color);
        text-decoration: none;
    }
}
/* [修改] Logo 互動邏輯：手機 Active 變色 */
.site-logo:active {
    color: var(--primary-color);
}

/* --- 導覽列連結設定 --- */
.site-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

/* [修改] Nav 互動邏輯：電腦 Hover 變色無底線 */
@media (hover: hover) {
    .site-nav a:hover {
        color: var(--primary-color);
        text-decoration: none;
    }
}
/* [修改] Nav 互動邏輯：手機 Active 變色 */
.site-nav a:active {
    color: var(--primary-color);
    text-decoration: none;
}

/* --- 閱讀容器 --- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 4rem 1.5rem 2rem 1.5rem;
}

/* --- 文章標題樣式 --- */
h1 {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    color: var(--text-color);
}

/* 副標題 */
.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary); /* 灰色 */
    font-weight: 400;
    margin-top: 0;
    margin-bottom: 2rem;
}

/* --- 章節標題 --- */
h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.4;
    color: var(--secondary-color);
}

/* --- 內文樣式 --- */
p {
    margin-bottom: 1.6rem;
    font-size: 1.1rem;
    word-wrap: break-word;
}

/* --- 推薦碼樣式 --- */
code {
    font-family: inherit;
    font-weight: 700;
    color: var(--secondary-color);
    background-color: rgba(74, 111, 165, 0.1);
    padding: 0.1em 0.3em;
    border-radius: 4px;
    font-size: 0.95em;
}

/* --- 引用區塊 --- */
blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 2rem 0;
    padding: 0.5rem 0 0.5rem 1.5rem;
    color: #555;
    font-style: italic;
    background-color: var(--light-bg);
}

strong {
    font-weight: 700;
    color: black;
}

/* --- 連結樣式 --- */
a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.2s;
    word-break: break-all;
}

/* 全域連結 Hover (Header 以外維持底線) */
a:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

/* --- CTA 區塊樣式 --- */
.cta-box {
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 20px;
    padding: 1.5rem;
    margin: 2rem 0;
    font-size: 1rem;
}

.cta-title {
    font-weight: bold;
    margin-bottom: 0.8rem;
    display: block;
    font-size: 1.1rem;
    color: var(--secondary-color);
}

/* --- 圖片樣式 --- */
figure {
    margin: 3rem 0;
    text-align: center;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: block;
    margin: 0 auto;
}

figcaption {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

/* --- 列表樣式 --- */
ul, ol {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}
li {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

/* --- 分隔線 --- */
hr {
    border: 0;
    height: 3px;
    background-color: var(--accent-color);
    width: 70px;
    margin: 0 0;
    margin-left: 0;
}

/* --- Site Footer --- */
.site-footer {
    background-color: var(--dark-bg);
    color: var(--light-text);
    padding: 1.5rem 1.5rem;
    margin-top: 4rem;
    text-align: center;
    font-size: 0.9rem;
}

.site-footer p {
    color: var(--light-text);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.site-footer a {
    color: var(--light-text);
    margin: 0 0.5rem;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.site-footer a:hover {
    color: white;
    opacity: 1;
    text-decoration: none;
}

@media (max-width: 600px) {
    .container { padding: 2rem 1rem; }
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.4rem; margin-top: 2.5rem; }
    .site-header { padding: 0 1rem; }
}

/* --- 頁面載入動畫 --- */

/* 1. 定義動畫關鍵影格：由下往上淡入 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 2. 基礎動畫類別 */
.animate-in {
    opacity: 0; /* 預設隱藏，等待動畫開始 */
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* 3. 設定延遲時間 (讓元素依序出現，才不會死板) */
.delay-1 { animation-delay: 0.1s; } /* 標題區 */
.delay-2 { animation-delay: 0.3s; } /* 分隔線 */
.delay-3 { animation-delay: 0.5s; } /* 文章內容 */
.delay-4 { animation-delay: 0.6s; } /* Footer */

/* 讓 Header 也有一個很快的淡入，避免突然閃現 */
/* .site-header {
    animation: fadeInUp 0.5s ease-out forwards;
} */