/* =========================================
   1. 核心變數與重置 (Variables & Reset)
   ========================================= */
:root {
    /* 品牌色系 */
    --bg: #fdfdfd;
    --card-bg: #ffffff;
    --text-main: #222222;
    --text-muted: #666666;
    
    /* === [修改] 主色調：原本是深灰，現在改為藍色 #007bff === */
    --brand: #007bff; 
    /* 點綴色：保持藍色 */
    --accent: #007bff; 
    
    /* 系統設定 */
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --radius: 16px;
    --font-main: 'Inter', 'Noto Sans TC', system-ui, sans-serif;
    
    /* 動畫曲線 */
    --ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
}

/* 確保 padding 不會撐開寬度 */
*, *::before, *::after { box-sizing: border-box; }

/* 強制禁止水平捲動，解決手機版右側空白 */
html, body { 
    margin: 0; 
    padding: 0; 
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* 強制長單字或網址換行 */
p, li, h1, h2, h3, h4, h5, h6, span, a {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
/* 連結懸停改為深藍色 */
a:hover { color: #0056b3; }

.container {
    width: min(100%, 1200px);
    margin: auto;
    padding: 0 20px;
}

/* 隱藏輔助文字 */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }


/* =========================================
   導覽列 (Navbar)
   ========================================= */
.site-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

/* 品牌名稱 */
.brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    z-index: 1001; /* 確保在遮罩層之上 */
}

/* 電腦版選單連結 (預設狀態) */
.nav-links {
    display: flex;
    gap: 1.2rem;
    align-items: center;
}

.nav-links a {
    color: #555;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--accent); /* 使用統一的藍色 */
}

/* 漢堡按鈕 (預設隱藏) */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
    padding: 0.5rem;
    z-index: 1001; /* 確保按鈕按得到 */
}

/* =========================================
   手機版響應式設定 (關鍵修復部分)
   ========================================= */
/* 當螢幕小於 900px 時套用以下設定 */
@media (max-width: 900px) {
    
    /* 1. 顯示漢堡按鈕 */
    .nav-toggle {
        display: block;
    }

    /* 2. 將選單改為「側邊抽屜」樣式 */
    .nav-links {
        position: fixed;        /* 固定位置，不隨卷軸移動 */
        top: 0;
        right: 0;
        height: 100vh;         /* 高度佔滿全螢幕 */
        width: 260px;          /* 側邊欄寬度 */
        background: #ffffff;   /* 白色背景 */
        
        /* 排版改為垂直 */
        flex-direction: column;
        align-items: center;
        justify-content: flex-start; /* 從頂部開始排列 */
        padding-top: 80px;           /* 避開頂部漢堡按鈕 */
        gap: 1.5rem;
        
        /* 陰影與邊框 */
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
        border-left: 1px solid #eee;

        /* 動畫設定：預設藏在右邊 */
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
    }

    /* 當選單被打開時 (由 JS 加上 active class) */
    .nav-links.active {
        transform: translateX(0); /* 滑入畫面 */
    }

    /* 手機版連結樣式調整 */
    .nav-links a {
        font-size: 1.1rem;
        width: 100%;
        text-align: center;
        padding: 10px 0;
        border-bottom: 1px dashed #f0f0f0; /* 分隔線 */
    }

    /* 3. 遮罩層 (點擊背景關閉) */
    .nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
        backdrop-filter: blur(2px);
    }

    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}


/* =========================================
   3. 動畫效果 (Animations)
   ========================================= */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
    opacity: 0;
    animation: fadeInUp 0.8s var(--ease-out) forwards;
}

.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.delay-1 { animation-delay: 0.1s; transition-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; transition-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; transition-delay: 0.3s; }


/* =========================================
   4. 卡片與網格 (Cards & Grids)
   ========================================= */
.hero { padding: 60px 0; text-align: center; }
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 1rem; color: var(--text-main); }
.hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 600px; margin: 0 auto; }

/* Grid 最小寬度設為 280px */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0,0,0,0.12);
}

.card h3 { margin-top: 0; font-size: 1.25rem; }
.card h3 a { color: var(--text-main); }
.card h3 a:hover { color: var(--accent); }

.meta {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 1rem;
    font-family: monospace;
}

/* === [修改] 按鈕樣式 === */
.btn {
    display: inline-block;
    background: var(--brand); /* 現在這會是藍色 #007bff */
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    text-align: center;
}
.btn:hover {
    background: #0056b3; /* [修改] 懸停時變為深藍色 (原為黑色) */
    transform: translateY(-2px);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,123,255,0.4); /* [修改] 陰影也帶一點藍色光暈 */
}
.btn.disabled { opacity: 0.5; pointer-events: none; }


/* =========================================
   5. 文章與內容 (Typography)
   ========================================= */
.prose {
    max-width: 800px;
    margin: 3rem auto;
    background: var(--card-bg);
    padding: 3rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.prose h1 { font-size: 2rem; margin-top: 0; line-height: 1.3; }
.prose p { font-size: 1.05rem; line-height: 1.8; color: #333; margin-bottom: 1.5rem; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; margin: 1.5rem 0; }
.prose ul, .prose ol { margin-bottom: 1.5rem; padding-left: 1.5rem; }
.prose li { margin-bottom: 0.5rem; }


/* =========================================
   6. 履歷與關於 (Resume & About)
   ========================================= */
.profile-header { text-align: center; margin-bottom: 3rem; }
.avatar { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: var(--shadow-md); margin-bottom: 1rem; }
.profile-bio { background: #f8f9fa; padding: 1.5rem; border-radius: 12px; margin-top: 1rem; text-align: left; }

.timeline { position: relative; padding-left: 1.5rem; border-left: 2px solid #e9ecef; margin: 1.5rem 0; }
.timeline-item { position: relative; margin-bottom: 2rem; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-marker { position: absolute; left: -1.95rem; top: 0.25rem; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.timeline-date { font-size: 0.85rem; color: #888; font-family: monospace; }
.timeline-title { font-weight: 700; color: var(--text-main); font-size: 1.1rem; }

.skill-tag {
    display: inline-block;
    background: #f1f3f5;
    color: #495057;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0 6px 6px 0;
    transition: all 0.2s;
}
.skill-tag:hover { background: #e9ecef; color: var(--accent); }

.detail-list { list-style: none; padding: 0; margin: 0; }
.detail-list li {
    padding: 0.8rem 0;
    border-bottom: 1px dashed #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
}
.detail-list li::before { content: '•'; color: var(--accent); font-weight: bold; margin-right: 0.5rem; }


/* =========================================
   7. 底部與電子報 (Footer & Newsletter)
   ========================================= */
.site-footer {
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    padding: 2rem 0;
    background: #fff;
    font-size: 0.9rem;
    color: #666;
}

.newsletter-section {
    padding: 4rem 0;
    background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.02));
}

.newsletter-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    max-width: 600px;
    margin: 0 auto;
}

.subscribe-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
    margin-top: 1.5rem;
}

.subscribe-form input[type="email"] {
    width: 100%;
    max-width: 360px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}


/* =========================================
   8. 輔助與響應式 (Utilities & RWD)
   ========================================= */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 1rem; font-size: 0.95rem; }
.alert.success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.alert.error { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert.warning { background: #fff3cd; color: #664d03; border: 1px solid #ffecb5; }

/* 分頁 */
.pagination { display: flex; justify-content: center; gap: 10px; margin: 2rem 0; }
.pageinfo { font-size: 0.9rem; color: #888; font-weight: 500; }

@media (max-width: 768px) {
    .hero h1 { font-size: 1.8rem; }
    .grid { grid-template-columns: 1fr; }
    .prose { padding: 1.5rem; }
    
    .editor-grid, .resume-grid { grid-template-columns: 1fr; }
    .detail-list li { flex-direction: column; }
    .detail-list a { margin-left: 0; margin-top: 0.5rem; white-space: normal; }
}


/* =========================================
   9. 列印樣式 (Print)
   ========================================= */
@media print {
    .site-header, .site-footer, .nav-toggle, .btn, .newsletter-section { display: none !important; }
    
    body, .container, .card, .prose { 
        width: 100% !important; margin: 0 !important; padding: 0 !important; 
        background: #fff !important; color: #000 !important; box-shadow: none !important; border: none !important;
        overflow: visible !important;
    }
    
    a { text-decoration: none !important; color: #000 !important; }
    .resume-grid { display: block !important; }
}