/* --- CSS Variables & Reset --- */
:root {
    --bg-main: #0a0a0c;
    --bg-card: #161618;
    --bg-card-hover: #1e1e22;
    --text-main: #ededed;
    --text-muted: #8a8a93;
    --accent-blue: #4a90e2;
    --accent-glow: rgba(74, 144, 226, 0.4);
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Noto Sans TC', sans-serif;
    --font-code: 'Source Code Pro', monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    /* Noise texture overlay */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); font-weight: 700; }
a { color: inherit; text-decoration: none; }

.smooth-scroll-wrapper { width: 100%; min-height: 100vh; display: flex; flex-direction: column; }
main { flex-grow: 1; padding: 0 5%; max-width: 1200px; margin: 0 auto; width: 100%; }

/* --- Hero Section --- */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10%;
    position: relative;
    gap: 40px;
}
.hero-content { flex: 1; z-index: 2; }
.hero-title { font-size: clamp(3rem, 6vw, 5rem); line-height: 1.1; margin-bottom: 20px; font-weight: 800; letter-spacing: -1px; }
.accent-text { color: var(--accent-blue); text-shadow: 0 0 20px var(--accent-glow); }
.hero-subtitle { font-size: clamp(1rem, 1.5vw, 1.5rem); color: var(--text-muted); margin-bottom: 40px; font-weight: 300; }
.hero-cta { display: flex; gap: 20px; }

.btn {
    padding: 12px 28px;
    border-radius: 30px;
    font-family: var(--font-heading);
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-primary { background: var(--accent-blue); color: #fff; box-shadow: 0 4px 15px var(--accent-glow); border: 1px solid var(--accent-blue); }
.btn-primary:hover { background: #357abd; box-shadow: 0 6px 20px var(--accent-glow); transform: translateY(-2px); }
.btn-outline { background: transparent; border: 1px solid var(--text-muted); color: var(--text-main); }
.btn-outline:hover { border-color: var(--accent-blue); color: var(--accent-blue); transform: translateY(-2px); }

/* Hero Image Masking (CSS Art) */
.hero-image-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.hero-image-container::before {
    content: '';
    position: absolute;
    width: 300px; height: 300px;
    background: var(--accent-blue);
    filter: blur(120px);
    opacity: 0.3;
    z-index: 0;
    border-radius: 50%;
}
.hero-image-mask {
    position: relative;
    z-index: 1;
    width: 350px;
    height: 450px;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.1);
    transition: border-radius 8s ease-in-out infinite alternate;
}
@keyframes morph {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
    100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
}
.hero-image-mask { animation: morph 8s ease-in-out infinite alternate; }
.hero-image { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; filter: contrast(1.1) saturate(1.1); }

/* --- Bento Box (About Me) --- */
.section-heading { font-size: 3rem; margin-bottom: 50px; color: var(--text-main); letter-spacing: -0.5px; font-weight: 800; }
.bento-section { padding: 80px 0; }
.bento-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 嚴格對稱的兩列佈局 */
    grid-auto-rows: 1fr; /* 確保每一列高度一致 */
    gap: 20px;
}
.bento-card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 30px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: transform 0.3s ease, background 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%; /* 確保每張卡片填滿該列的高度，達成對稱 */
}
.bento-card:hover { transform: translateY(-5px); background: var(--bg-card-hover); border-color: rgba(74, 144, 226, 0.3); }
.bento-card h3 { color: var(--accent-blue); margin-bottom: 15px; font-size: 1.8rem; font-weight: 800; }
.bento-card p { margin-bottom: 8px; color: var(--text-muted); font-size: 1.1rem; }
.bento-card strong { color: var(--text-main); }
.status { display: inline-block; padding: 4px 12px; background: rgba(74,144,226,0.1); color: var(--accent-blue); border-radius: 12px; font-size: 0.9rem; margin-top: 10px; }

.tags { display: flex; flex-wrap: wrap; gap: 10px; }
.tag { background: rgba(255,255,255,0.05); padding: 8px 16px; border-radius: 20px; font-size: 0.9rem; border: 1px solid rgba(255,255,255,0.1); }

/* Social Links styling in Bento */
.social-links-bento { display: flex; gap: 15px; flex-wrap: wrap; }
.social-links-bento a {
    width: 45px; height: 45px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    display: flex; justify-content: center; align-items: center;
    font-size: 1.5rem;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    z-index: 1;
}
.social-links-bento a::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
}
.social-links-bento a:hover { transform: scale(1.1); box-shadow: 0 4px 15px var(--accent-glow); color: #fff; }
.social-links-bento a:hover::before { opacity: 1; }

.social-links-bento .instagram::before { background: linear-gradient(45deg, #F58529, #DD2A7B, #8134AF, #515BD4); }
.social-links-bento .threads::before { background: #000000; }
.social-links-bento .line::before { background: #00C300; }
.social-links-bento .youtube::before { background: #c4302b; }
.social-links-bento .github::before { background: #24292e; }

/* --- Gallery Section --- */
.gallery-section { padding: 80px 0 120px 0; }
.gallery-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; }
.view-all-link { color: var(--accent-blue); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; transition: gap 0.3s; }
.view-all-link:hover { gap: 12px; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}
.gallery-item {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    aspect-ratio: 3/4;
    cursor: zoom-in;
}
.gallery-item img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.gallery-item::after {
    content: 'search';
    font-family: 'Material Symbols Outlined';
    font-size: 3rem;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}
.gallery-item:hover img { transform: scale(1.05); }
.gallery-item:hover::after { opacity: 1; }

/* --- Contact Section --- */
.contact-section { padding: 40px 0 100px 0; }
.contact-card {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(0,0,0,0));
    border: 1px solid rgba(74, 144, 226, 0.2);
    border-radius: 30px;
    padding: 60px 40px;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}
.contact-desc { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 30px; }
.contact-btn { gap: 10px; font-size: 1.2rem; padding: 15px 40px; }
.contact-btn .material-symbols-outlined { font-size: 1.4rem; }

/* --- Footer --- */
.site-footer {
    padding: 60px 20px;
    text-align: center;
    background: #050505;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.footer-contact {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    color: var(--accent-blue);
    margin-bottom: 20px;
    font-weight: 600;
    transition: transform 0.3s;
}
.footer-contact:hover { transform: translateY(-3px); }
.copyright, .version { color: var(--text-muted); font-size: 0.9rem; font-family: var(--font-code); margin-bottom: 5px; }

/* --- Bio & Timeline Section (About Me) --- */
.page-content-wrapper { padding: 80px 5%; max-width: 1000px; margin: 0 auto; width: 100%; flex-grow: 1; }
.bio-section { margin-bottom: 80px; text-align: center; }
.bio-content { font-size: 1.2rem; line-height: 1.8; color: var(--text-muted); padding: 40px; margin-top: 30px; }

.experience-section { margin-bottom: 100px; }
.timeline-container { position: relative; padding-left: 30px; border-left: 2px solid rgba(74, 144, 226, 0.3); margin-top: 40px; }
/* 覆寫 bento-card 的置中效果，確保始終靠左 */
.timeline-item { position: relative; margin-bottom: 40px; padding: 25px; text-align: left !important; align-items: flex-start !important; justify-content: flex-start !important; min-height: auto; height: auto; }
.timeline-item::before { content: ''; position: absolute; left: -42px; top: 30px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg-main); border: 4px solid var(--accent-blue); box-shadow: 0 0 10px var(--accent-glow); }
.timeline-year { font-family: var(--font-code); color: var(--accent-blue); font-size: 1.2rem; font-weight: 700; margin-bottom: 10px; }
.timeline-content { display: flex; flex-direction: column; gap: 15px; }
.timeline-text-content h3 { color: var(--text-main); font-size: 1.4rem; margin-bottom: 10px; }
.timeline-text-content p { color: var(--text-muted); }
.timeline-img-wrapper { margin-top: 15px; border-radius: 12px; overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.3); width: 100%; }
.timeline-img-wrapper img { width: 100%; max-height: 250px; object-fit: cover; display: block; transition: transform 0.4s; }
.timeline-img-wrapper:hover img { transform: scale(1.05); }

@media (min-width: 769px) {
    .timeline-content { flex-direction: row; justify-content: space-between; align-items: flex-start; }
    .timeline-text-content { flex: 1; }
    .timeline-img-wrapper { margin-top: 0; width: 120px; height: 120px; flex-shrink: 0; border-radius: 12px; }
    .timeline-img-wrapper img { height: 100%; }
}

/* --- Contact Page (Call Me) --- */
.contact-page-wrapper { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.contact-hero { width: 100%; max-width: 600px; }
.contact-glass-card { background: rgba(22, 22, 24, 0.6); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.05); border-radius: 30px; padding: 50px; text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,0.5); }
.contact-avatar-wrapper { width: 120px; height: 120px; margin: 0 auto 20px; border-radius: 50%; padding: 4px; background: linear-gradient(135deg, var(--accent-blue), transparent); }
.contact-avatar { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: 3px solid var(--bg-main); }
.contact-subtitle { color: var(--text-muted); margin-bottom: 30px; }
.contact-info-list { margin-bottom: 40px; }
.info-item { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.2rem; background: rgba(0,0,0,0.3); padding: 12px 20px; border-radius: 12px; }
.icon-blue { color: var(--accent-blue); }
.social-title { margin-bottom: 20px; font-size: 1.2rem; color: var(--text-main); }
.contact-social-bar { justify-content: center; margin-bottom: 40px; }
.send-email-btn { width: 100%; padding: 15px; font-size: 1.2rem; gap: 10px; }

/* --- Utility Classes --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.page-top-padding { padding-top: 80px; }
.page-title { font-size: 3rem; margin-bottom: 20px; }

/* --- Responsive --- */
@media (max-width: 900px) {
    .hero-section { flex-direction: column-reverse; justify-content: center; text-align: center; padding-top: 100px; gap: 20px; }
    .hero-cta { justify-content: center; }
    .hero-image-mask { width: 280px; height: 380px; }
    .hero-title { font-size: 2.8rem; }
}
@media (max-width: 768px) {
    .bento-grid { grid-template-columns: 1fr; } /* 手機版轉為單列 */
    .bento-card { min-height: 180px; }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr); /* 手機版畫廊強制 2 欄 */
    }
    
    .contact-glass-card {
        padding: 30px 20px; /* 手機版聯絡我卡片內距減少，以便放下更多圖示 */
    }
    .social-links-bento { gap: 10px; } /* 縮小圖示間距讓5個圖示排得下 */
    .social-links-bento a { width: 40px; height: 40px; font-size: 1.2rem; }
    .send-email-btn { font-size: 1rem; padding: 12px; } /* 按鈕縮小以避免溢出 */
}

/* 兼容其他頁面 (如 highlight.html, callme.html) 確保舊有 class 可以運作 */
.content-wrapper { flex-grow: 1; padding: 20px; }
.page-header h1 { font-size: 28px; background-color: var(--bg-card); padding: 10px 20px; border-radius: 15px; display: inline-block; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5); }
.page-header { text-align: center; padding-top: 20px; margin-bottom: 20px; }
.page-content, .page-content-index { max-width: 1000px; margin: 40px auto; padding: 30px; background-color: var(--bg-card); border-radius: 20px; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6); }
.page-title { text-align: center; margin-bottom: 30px; font-size: 26px; }
.contact-form { max-width: 600px; margin: 0 auto; }
.form-group { margin-bottom: 20px; }
.contact-form input, .contact-form textarea { width: 100%; padding: 12px; border: 1px solid #555; background-color: var(--bg-main); color: #fff; border-radius: 8px; font-size: 16px; }
.contact-form button { width: 100%; padding: 15px; border: none; border-radius: 8px; background-color: var(--accent-blue); color: #fff; font-size: 18px; cursor: pointer; transition: background-color 0.3s; }
.contact-form button:hover { background-color: #357abd; }


/* ==========================================================================
   導覽列 (Navbar) 連結底線與過渡動畫 (新增)
   ========================================================================== */

/* 1. 設定導覽列連結的基本樣式（此處排除下拉選單內部的子連結，若需全部套用可移除 :not ） */
#main-nav a {
    position: relative;
    text-decoration: none;
    transition: color 0.3s ease;
    padding-bottom: 6px; /* 留出空間給底線，視覺上更舒適 */
}

/* 2. 使用 ::after 偽元素打造動畫底線 */
#main-nav a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px; /* 底線粗細 */
    
    /* 使用你原有的全域變數 --accent-blue */
    background-color: var(--accent-blue); 
    
    /* 核心動畫：預設水平縮放至 0 (不顯示) */
    transform: scaleX(0);
    
    /* transform-origin 決定動畫發出的起點：
       center: 從中間向兩側展開 (Apple 風格)
       left: 從左邊向右邊延伸
    */
    transform-origin: center; 
    
    /* 運用硬體加速的高效能過渡動畫 */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3. 當滑鼠懸停 (Hover) 或 JavaScript 判斷為當前頁面 (.is-current) 時，底線伸展為 100% */
#main-nav a:hover::after,
#main-nav a.is-current::after {
    transform: scaleX(0);
}

/* 4. 當前頁面的文字加上微光與些許加粗，呼應你的 Hero Section 風格 */
#main-nav a.is-current {
    color: var(--accent-blue) !important;
    text-shadow: 0 0 12px var(--accent-glow);
    font-weight: 600;
}