/* 引入 Google Fonts - Noto Serif TC (思源宋體) 和 Open Sans (用於標題) */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;700&family=Open+Sans:wght@400;700&display=swap');

/* 定義本地託管的 Iansui 字型 */
@font-face {
    font-family: 'Iansui';
    src: url('/fonts/Iansui.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* CSS 變數定義：日間模式 */
:root {
    --bg-color: #fcf8f3; /* 淺米色背景，溫暖不刺眼 */
    --text-color: #333; /* 深灰色文字 */
    --link-color: #a0522d; /* 溫暖的土棕色連結 */
    --link-hover-color: #8b4513; /* 更深的棕色 */
    --heading-color: #4a2c1a; /* 深棕色標題 */
    --border-color: #e0d8cf; /* 淺邊框色 */
    --header-bg: #f5eddf; /* 淺黃色系頁頭背景 */
    --footer-bg: #f5eddf; /* 淺黃色系頁腳背景 */
    --card-bg: #ffffff; /* 卡片背景 */
}

/* CSS 變數定義：夜間模式 */
[data-theme='dark'] {
    --bg-color: #282c34; /* 深藍灰色背景 */
    --text-color: #d8dee9; /* 淺藍灰色文字 */
    --link-color: #81a1c1; /* 柔和的藍色連結 */
    --link-hover-color: #5e81ac; /* 更深的藍色 */
    --heading-color: #eacb8d; /* 柔和的橘黃色標題 */
    --border-color: #3b4252; /* 深邊框色 */
    --header-bg: #3b4252; /* 深灰色頁頭背景 */
    --footer-bg: #3b4252; /* 深灰色頁腳背景 */
    --card-bg: #363b46; /* 卡片背景 */
}

/* 基本樣式 */
body {
    font-family: 'Iansui', 'Noto Serif TC', serif; /* 將 Iansui 設為主要字體 */
    font-size: 1.1em; /* 調整基礎字體大小 */
    line-height: 1.7;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 20px;
}

/* 連結樣式 */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* 標題樣式 */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Noto Serif TC', serif; /* 標題用思源宋體 */
    color: var(--heading-color);
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
}

h1 { font-size: 2.2em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.5em; }

/* 頁頭樣式 */
.site-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.site-header .header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.1em;
    margin-left: 20px;
}

.site-nav a:hover {
    color: var(--link-hover-color);
}


.site-title {
    font-family: 'Noto Serif TC', serif; /* 網站標題也用思源宋體 */
    font-size: 1.8em;
    font-weight: 700;
    color: var(--heading-color);
    text-decoration: none;
}

.site-title:hover {
    color: var(--link-hover-color);
    text-decoration: none;
}

/* RSS 連結樣式 */
.rss-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.rss-link:hover {
    color: var(--link-hover-color);
}

.rss-link .icon-rss {
    width: 24px;
    height: 24px;
    /* stroke: currentColor; */
    display: block;
}

/* 日夜模式切換按鈕 */
.theme-toggle {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    color: var(--text-color); /* 按鈕顏色隨主題變化 */
    transition: color 0.3s ease;
}

.theme-toggle:hover {
    color: var(--link-hover-color);
    opacity: 1;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

/* 根據主題顯示對應圖標 */
html[data-theme='light'] .theme-toggle .icon-sun {
    display: inline;
}
html[data-theme='dark'] .theme-toggle .icon-moon {
    display: inline;
}

/* 頁腳樣式 */
.site-footer {
    text-align: center;
    padding: 30px 0;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    background-color: var(--footer-bg);
    font-size: 0.9em;
    color: var(--text-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* 文章列表樣式 */
.post-list {
    margin-top: 40px;
}

.post-item {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 25px 30px;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.post-item:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.post-item .post-title {
    margin-top: 0;
    font-size: 1.7em;
    margin-bottom: 10px;
}

.post-item .post-title a {
    color: var(--heading-color);
    text-decoration: none;
}

.post-item .post-title a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

.post-meta {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 15px;
}

.post-cat {
    margin-left: 15px;
}

.post-cat a {
    color: var(--link-color);
    background-color: var(--border-color);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.post-cat a:hover {
    background-color: var(--link-color);
    color: white;
}

.post-summary {
    margin-bottom: 20px;
    color: var(--text-color);
}

.read-more {
    display: inline-block;
    padding: 8px 15px;
    background-color: var(--link-color);
    color: white;
    border-radius: 5px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.2s ease;
}

.read-more:hover {
    background-color: var(--link-hover-color);
    text-decoration: none;
}

/* 單篇文章樣式 */
.post-single {
    margin-top: 40px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.post-single .post-header {
    text-align: center;
    margin-bottom: 30px;
}

.post-single .post-title {
    font-size: 2.5em;
    margin-top: 0;
    margin-bottom: 10px;
}

.post-single .post-meta {
    font-size: 1em;
    color: #888;
}

.post-single .post-content img {
    width: 100%; /* 將 max-width 改為 width，強制圖片填滿容器 */
    height: auto;
    display: block;
    margin: 0 auto; /* 現在由 figure 控制上下邊距 */
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.post-content figure {
    margin: 30px auto;
    padding: 0;
    width: 100%;
}

.post-content figcaption {
    text-align: center;
    font-size: 0.9em;
    font-style: italic;
    color: #888;
    margin-top: 10px;
    padding: 0 10px;
}

.post-content p {
    margin-bottom: 1.2em;
    text-align: justify;
}

.post-content strong {
    color: var(--heading-color);
}

.post-content em {
    font-style: italic;
}

.post-content blockquote {
    border-left: 4px solid var(--link-color);
    padding-left: 20px;
    margin-left: 0;
    font-style: italic;
    color: #777;
}

.post-content ul, .post-content ol {
    margin-left: 20px;
    margin-bottom: 1.2em;
}

.post-content pre {
    background-color: var(--border-color);
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Open Sans', monospace;
    font-size: 0.9em;
    color: var(--text-color);
}

.post-content code {
    font-family: 'Open Sans', monospace;
    background-color: var(--border-color);
    padding: 2px 4px;
    border-radius: 3px;
    color: var(--heading-color);
}

/* 分頁樣式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 20px;
    gap: 15px;
}

.pagination-item {
    padding: 10px 18px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--link-color);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.pagination-item:hover {
    background-color: var(--link-color);
    color: white;
    border-color: var(--link-color);
}

.pagination-item.disabled {
    color: #aaa;
    pointer-events: none;
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

.pagination-item.page-info {
    border: none;
    background: none;
    color: var(--text-color);
    font-weight: bold;
    padding: 0;
}

/* 分類術語列表頁樣式 (terms.html) */
.terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 40px;
    padding: 0;
    list-style: none;
}

.term-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 15px 25px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease-in-out;
    flex-grow: 1;
    min-width: 250px;
}

.term-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: var(--link-color);
}

.term-name {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--heading-color);
}

.term-count {
    font-size: 1em;
    padding: 5px 12px;
    border-radius: 20px;
    background-color: var(--link-color);
    color: white;
    margin-left: 20px;
}


/* RWD 調整 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    .site-title {
        font-size: 1.5em;
    }
    h1 {
        font-size: 1.8em;
    }
    h2 {
        font-size: 1.5em;
    }
    .post-item {
        padding: 20px;
    }
    .post-single {
        padding: 25px;
    }
}

@media (max-width: 480px) {
    .site-header .header-container {
        flex-direction: column;
        gap: 10px;
    }
    .site-header .container {
        flex-direction: column;
        gap: 10px;
    }
    .site-nav {
        display: flex;
        align-items: center;
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .site-nav a {
        margin-left: 0;
    }
    .theme-toggle {
        margin-left: 0;
    }
    .post-single .post-title {
        font-size: 2em;
    }
    .pagination {
        flex-wrap: wrap;
        gap: 10px;
    }
    .pagination-item {
        flex-grow: 1;
        text-align: center;
    }
    .pagination-item.page-info {
        flex-basis: 100%;
        text-align: center;
    }
}