/* ==========================================================================
   做工á人台語工作室 - 共用樣式表 (style.css)
   ========================================================================== */

/* === 1. 全域變數與基礎設定 (深色模式預設) === */
:root {
    --primary-color: #24BF89;
    --primary-hover: #1aab78;
    --bg-color: #0f172a;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --white: #1e293b;
    --border-color: #334155;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
}

/* 針對文章頁面的陰影微調 (背景色與主頁共用，不再獨立覆蓋) */
body.article-page {
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.35);
    --shadow-md: 0 10px 30px -10px rgba(0,0,0,0.5);
}

/* 淺色模式覆蓋 (由設定面板切換) */
html[data-theme="light"] {
    --bg-color: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}
html[data-theme="light"] body.article-page {
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 30px -10px rgba(0,0,0,0.08);
}
/* 首頁：淺色模式下深色硬編碼背景的覆蓋 */
html[data-theme="light"] {
    --about-quote-bg: linear-gradient(135deg, #ecfdf5, #f0fdf4);
    --placeholder-bg: linear-gradient(135deg, #d1fae5, #a7f3d0);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--text-main);
    background-color: var(--bg-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
a { text-decoration: none; color: inherit; }

/* === 2. 頂部導覽列 Navbar === */
.navbar { background-color: var(--white); box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 1000; display: flex; justify-content: space-between; align-items: center; padding: 0 5%; height: 70px; border-bottom: 1px solid var(--border-color); }
.nav-brand { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); display: flex; align-items: center; gap: 10px; }
.nav-brand img { height: 40px; width: auto; object-fit: contain; }

.nav-list { display: flex; list-style: none; height: 100%; margin: 0; }
.nav-item { position: relative; display: flex; align-items: center; height: 100%; padding: 0 15px; }
.nav-link { font-weight: 500; color: var(--text-main); transition: color 0.2s; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.nav-item:hover > .nav-link { color: var(--primary-color); }

/* 下拉選單 - 加上 overflow: visible !important 強制解決裁切與捲軸問題 */
.dropdown-menu { position: absolute; top: 100%; left: 0; background-color: var(--white); min-width: 240px; box-shadow: var(--shadow-md); border-radius: 0 0 8px 8px; border: 1px solid var(--border-color); border-top: none; display: none; flex-direction: column; list-style: none; padding: 10px 0; overflow: visible !important; }
.nav-item:hover > .dropdown-menu { display: flex; animation: fadeIn 0.2s ease; }
.dropdown-item { position: relative; }
.dropdown-link { display: block; padding: 10px 20px; font-size: 0.95rem; color: var(--text-main); transition: background 0.2s, color 0.2s; display: flex; justify-content: space-between; align-items: center; cursor: pointer; white-space: normal; word-break: break-word; }
.dropdown-item:hover > .dropdown-link { background-color: rgba(255,255,255,0.07); color: var(--primary-color); }

.sub-dropdown-menu { position: absolute; top: 0; left: 100%; background-color: var(--white); min-width: 280px; box-shadow: var(--shadow-md); border-radius: 8px; border: 1px solid var(--border-color); display: none; flex-direction: column; list-style: none; padding: 10px 0; overflow: visible !important; }
.dropdown-item.has-sub:hover > .sub-dropdown-menu { display: flex; animation: fadeIn 0.2s ease; }

/* 只有最後一層長列表才會套用這個滾動樣式 */
.scrollable-menu { max-height: 75vh; overflow-y: auto !important; overflow-x: hidden !important; }

.mobile-toggle { display: none; font-size: 1.5rem; cursor: pointer; color: var(--text-main); background: none; border: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* === 3. 頁尾與狀態 === */
.footer { background-color: #070d1a; color: #64748b; text-align: center; padding: 30px 20px; margin-top: auto; font-size: 0.9rem; }
body.article-page .footer { background-color: var(--white); color: var(--text-muted); border-top: 1px solid var(--border-color); }
.status-msg { text-align: center; padding: 40px; color: var(--text-muted); font-size: 1.1rem; }
.status-msg.error { color: #ef4444; }

/* ==========================================================================
   個別頁面專屬排版區
   ========================================================================== */

/* --- 首頁 (index.html) --- */
.hero { background: linear-gradient(135deg, #0a5c40 0%, #0f7a52 40%, #24BF89 100%); color: #fff; padding: 80px 20px; text-align: center; }
.hero h1 { font-size: 2.8rem; font-weight: 800; margin-bottom: 20px; letter-spacing: 1px; }
.hero p { font-size: 1.2rem; max-width: 600px; margin: 0 auto; opacity: 0.9; margin-bottom: 30px; }
.hero-btn { background: var(--white); color: var(--primary-color); padding: 12px 30px; border-radius: 30px; font-weight: 600; font-size: 1.1rem; transition: transform 0.2s, box-shadow 0.2s; display: inline-block; }
.hero-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.main-content { flex-grow: 1; padding: 60px 5%; max-width: 1200px; margin: 0 auto; width: 100%; }
.section-title { text-align: center; font-size: 2rem; margin-bottom: 40px; color: var(--text-main); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; }
.feature-card { background: var(--white); border: 1px solid var(--border-color); border-radius: 12px; padding: 30px; text-align: center; box-shadow: var(--shadow-sm); transition: transform 0.3s, box-shadow 0.3s; }
.feature-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.feature-icon { font-size: 3rem; margin-bottom: 20px; display: inline-block; }
.feature-card h3 { font-size: 1.3rem; margin-bottom: 15px; color: var(--primary-color); }
.feature-card p { color: var(--text-muted); font-size: 0.95rem; }

/* --- 分類頁 (category.html) --- */
.category-container { flex-grow: 1; max-width: 900px; margin: 40px auto; padding: 0 20px; width: 100%; }
.category-header { margin-bottom: 40px; border-bottom: 2px solid var(--border-color); padding-bottom: 15px; }
.category-header h1 { font-size: 2.2rem; color: var(--text-main); }
.post-list { display: flex; flex-direction: column; gap: 30px; }
.post-card { display: flex; background: var(--white); border-radius: 12px; border: 1px solid var(--border-color); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.2s, box-shadow 0.2s; }
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.post-image { flex: 0 0 300px; background-color: var(--border-color); overflow: hidden; }
.post-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.post-card:hover .post-image img { transform: scale(1.05); }
.post-content { padding: 25px; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.post-title { font-size: 1.5rem; margin-bottom: 10px; }
.post-title a { color: var(--primary-color); transition: color 0.2s; }
.post-title a:hover { color: var(--primary-hover); }
.post-meta { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 15px; display: flex; gap: 15px; align-items: center; }
.post-desc { color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }
.read-more { display: inline-block; align-self: flex-start; padding: 8px 20px; background-color: var(--primary-color); color: #fff !important; border-radius: 6px; font-weight: 500; font-size: 0.9rem; transition: background-color 0.2s; }
.read-more:hover { background-color: var(--primary-hover); }

/* --- 文章內頁與歸檔時間軸 (article.html) --- */
.article-wrapper { flex-grow: 1; width: 100%; max-width: 900px; margin: 40px auto 80px; padding: 0 20px; }
.back-btn { display: inline-flex; align-items: center; gap: 5px; color: var(--text-muted); font-weight: 500; margin-bottom: 15px; transition: color 0.2s; font-size: 0.95rem; }
.back-btn:hover { color: var(--primary-color); }
.article-card { background-color: var(--white); border-radius: 16px; padding: 50px 60px; box-shadow: var(--shadow-md); border: 1px solid rgba(255,255,255,0.06); }
.breadcrumb { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 30px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: rgba(255,255,255,0.04); padding: 10px 15px; border-radius: 8px; }
.breadcrumb a { color: var(--text-muted); transition: color 0.2s; font-weight: 500; }
.breadcrumb a:hover { color: var(--primary-color); }
.breadcrumb-separator { color: var(--border-color); }
.article-header { margin-bottom: 40px; padding-bottom: 20px; border-bottom: 2px solid var(--border-color); }
.article-title { font-size: 2.4rem; font-weight: 800; color: var(--text-main); margin-bottom: 15px; line-height: 1.3; }
.article-meta { color: var(--text-muted); font-size: 0.95rem; display: flex; gap: 15px; align-items: center; flex-wrap: wrap; }

.markdown-body { background: transparent; padding: 0; box-shadow: none; border: none; font-size: 1.1rem; color: var(--text-main); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { color: var(--text-main); margin-top: 2em; margin-bottom: 0.8em; line-height: 1.3; font-weight: 700; }
.markdown-body h2 { font-size: 1.7rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.4em; }
.markdown-body h3 { font-size: 1.4rem; color: var(--primary-color); }
.markdown-body p { margin-bottom: 1.6em; line-height: 1.9; }
.markdown-body a { color: var(--primary-color); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.2s; }
.markdown-body a:hover { border-color: var(--primary-color); }
.markdown-body a:has(i.fa), .markdown-body a:has(i.fab), .markdown-body a:has(i.fas) { border-bottom: none; display: inline-block; margin-right: 18px; margin-top: 10px; margin-bottom: 10px; }
.markdown-body a i { color: var(--primary-color); transition: transform 0.2s ease, color 0.2s ease; }
.markdown-body a:hover i { color: var(--primary-hover); transform: translateY(-3px) scale(1.1); }
.markdown-body img { max-width: 100%; height: auto; border-radius: 12px; margin: 2em 0; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.markdown-body blockquote { border-left: 5px solid var(--primary-color); margin: 2em 0; padding: 20px 25px; background-color: rgba(36,191,137,0.07); color: var(--primary-color); border-radius: 0 12px 12px 0; font-style: italic; }
.markdown-body blockquote p { margin-bottom: 0; }
.markdown-body ul, .markdown-body ol { margin-bottom: 1.6em; padding-left: 2rem; line-height: 1.9; }
.markdown-body li { margin-bottom: 0.5em; }
.markdown-body pre { background-color: #0a0f1e; color: #e2e8f0; padding: 20px; border-radius: 12px; overflow-x: auto; margin: 2em 0; box-shadow: inset 0 2px 4px rgba(0,0,0,0.4); border: 1px solid var(--border-color); }
.markdown-body code { font-family: Consolas, Monaco, "Courier New", monospace; background-color: rgba(255,255,255,0.08); color: #fb7185; padding: 3px 6px; border-radius: 4px; font-size: 0.9em; }
.markdown-body pre code { background-color: transparent; color: inherit; padding: 0; }
.markdown-body audio { width: 100%; margin: 20px 0; outline: none; border-radius: 8px; background-color: rgba(255,255,255,0.05); }

.post-navigation { display: flex; justify-content: space-between; margin-top: 60px; padding-top: 40px; border-top: 2px solid var(--border-color); gap: 20px; }
.nav-link-block { flex: 1; display: flex; flex-direction: column; text-decoration: none; padding: 20px 25px; border-radius: 12px; transition: all 0.2s; background-color: var(--white); border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); }
.nav-link-block:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary-color); }
.nav-link-block.next { text-align: right; }
.nav-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.nav-title { font-weight: 700; color: var(--primary-color); font-size: 1.1rem; line-height: 1.4; }

/* 歸檔頁 - 年份標題 */
.archive-year { font-size: 1.8rem; font-weight: 700; color: var(--primary-color); border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-top: 40px; margin-bottom: 20px; display: flex; align-items: baseline; gap: 12px; }
.archive-year:first-child { margin-top: 0; }
.archive-year-count { font-size: 0.95rem; font-weight: 400; color: var(--text-muted); }

/* 歸檔頁 - 卡片列表容器 */
.archive-card-list { display: flex; flex-direction: column; gap: 20px; margin-bottom: 10px; }

/* 歸檔頁 - 單一卡片 */
.archive-card { display: flex; background: var(--white); border-radius: 12px; border: 1px solid var(--border-color); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.2s, box-shadow 0.2s; }
.archive-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* 縮圖區塊 */
.archive-card-img { flex: 0 0 220px; overflow: hidden; background-color: var(--border-color); }
.archive-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.archive-card:hover .archive-card-img img { transform: scale(1.05); }

/* 內文區塊 */
.archive-card-body { padding: 20px 25px; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; gap: 8px; }

/* 標題 */
.archive-card-title { font-size: 1.2rem; font-weight: 700; line-height: 1.4; margin: 0; }
.archive-card-title a { color: var(--text-main); transition: color 0.2s; }
.archive-card-title a:hover { color: var(--primary-color); }

/* 日期 + 分類列 */
.archive-card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.88rem; }
.archive-card-date { color: var(--text-muted); }
.archive-card-cats { display: flex; flex-wrap: wrap; gap: 5px; }
.archive-cat-badge { background: rgba(36,191,137,0.12); color: var(--primary-color); border: 1px solid rgba(36,191,137,0.3); border-radius: 20px; padding: 2px 10px; font-size: 0.8rem; font-weight: 500; white-space: nowrap; }

/* 摘要 */
.archive-card-excerpt { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --- 7. 手機版排版調整 --- */
@media (max-width: 768px) {
    .mobile-toggle { display: block; }
    .nav-list { position: absolute; top: 70px; left: 0; width: 100%; background-color: var(--white); flex-direction: column; height: auto; box-shadow: var(--shadow-md); display: none; max-height: calc(100vh - 70px); overflow-y: auto; overflow-x: hidden; }
    .nav-list.active { display: flex; }
    .nav-item { height: auto; padding: 0; border-bottom: 1px solid var(--border-color); flex-direction: column; align-items: flex-start; }
    .nav-link { padding: 15px 20px; width: 100%; justify-content: space-between; font-size: 1.1rem; }
    .nav-item:hover > .dropdown-menu { display: none; }

    .dropdown-menu, .sub-dropdown-menu { position: static; width: 100%; box-shadow: none; border: none; border-radius: 0; display: none; padding: 0; max-height: none; overflow: visible !important; }
    .dropdown-menu { background-color: #162032; }
    .dropdown-menu .dropdown-link { padding-left: 40px; border-bottom: 1px solid var(--border-color); }
    .sub-dropdown-menu { background-color: #192840; }
    .sub-dropdown-menu .dropdown-link { padding-left: 60px; }
    .sub-dropdown-menu .sub-dropdown-menu { background-color: #1c3050; }
    .sub-dropdown-menu .sub-dropdown-menu .dropdown-link { padding-left: 80px; }

    .scrollable-menu { max-height: none !important; overflow: visible !important; }
    .mobile-open { display: flex !important; }

    .hero { padding: 60px 20px; }
    .hero h1 { font-size: 2.2rem; }
    .hero p { font-size: 1.05rem; margin-bottom: 25px; }
    .main-content { padding: 40px 5%; }
    .section-title { font-size: 1.6rem; margin-bottom: 30px; }

    .category-container { margin: 20px auto 40px; padding: 0 15px; }
    .post-card { flex-direction: column; }
    .post-image { flex: none; width: 100%; height: 200px; }

    .article-wrapper { margin: 20px auto 40px; padding: 0 15px; }
    .article-card { padding: 30px 20px; border-radius: 12px; }
    .article-title { font-size: 1.9rem; }
    .post-navigation { flex-direction: column; margin-top: 40px; padding-top: 30px; gap: 15px; }
    .nav-link-block.next { text-align: left; }

    .archive-year { font-size: 1.5rem; margin-top: 30px; }
    .archive-card { flex-direction: column; }
    .archive-card-img { flex: none; width: 100%; height: 180px; }
    .archive-card-body { padding: 15px; }
    .archive-card-title { font-size: 1.05rem; }
}
