/* --- CSS Reset & Variables --- */
:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #38bdf8;
    --accent-secondary: #818cf8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-hover: rgba(255, 255, 255, 0.05);
    --cursor-size: 400px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
}

/* --- Dynamic Cursor Background Effect --- */
.cursor-glow {
    width: var(--cursor-size);
    height: var(--cursor-size);
    background: radial-gradient(circle, rgba(56, 189, 248, 0.15), transparent 70%);
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 0;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease-out;
}

/* --- Layout & Typography --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
}

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* --- Header (Glassmorphism) --- */
header {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1rem 0;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    transition: all 0.3s ease;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Fira Code', monospace;
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--accent-primary);
}

.nav-links {
    display: flex;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 2rem;
    font-size: 0.95rem;
    transition: color 0.3s;
    
    /* 防跳動：固定導覽連結寬度 */
    display: inline-block;
    min-width: 110px;
    text-align: center;
}

.nav-links a:hover {
    color: var(--accent-primary);
}

/* --- Language Switcher --- */
.lang-btn {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    margin-left: 2rem;
    border-radius: 99px;
    cursor: pointer;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    
    /* 防跳動：固定按鈕寬度 */
    min-width: 100px;
    justify-content: center;
}

.lang-btn:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.lang-opt {
    opacity: 0.5;
    transition: all 0.3s ease;
}

.separator {
    opacity: 0.3;
    margin: 0 2px;
}

.lang-opt.active {
    opacity: 1;
    font-weight: bold;
    color: var(--accent-primary);
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

.lang-btn:hover .lang-opt:not(.active) {
    opacity: 0.8;
    color: var(--text-primary);
}

/* --- Hero Section --- */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: 80px;
}

.hero-content h1 {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    
    /* 防跳動：預留兩行標題高度 */
    min-height: 2.2em;
    display: flex;
    align-items: center;
}

.hero-content p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 2.5rem;
    
    /* 防跳動：預留敘述高度 */
    min-height: 3.5em;
}

.cta-btn {
    display: inline-block;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--accent-secondary);
}

/* --- Sections General --- */
section {
    padding: 6rem 0;
}

/* --- Timeline / Progress Bar Section --- */
.timeline-wrapper {
    position: relative;
    padding: 2rem 0;
    max-width: 900px;
    margin: 0 auto;
}

.progress-line-bg {
    position: absolute;
    top: 50px;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%);
    z-index: 0;
}

.progress-line-fill {
    position: absolute;
    top: 50px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transform: translateY(-50%);
    box-shadow: 0 0 10px var(--accent-primary);
    z-index: 0;
}

.timeline-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.timeline-step {
    text-align: center;
    flex: 1;
    position: relative;
    cursor: default;
}

.step-marker {
    width: 20px;
    height: 20px;
    background: var(--bg-color);
    border: 3px solid var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto 1.5rem auto;
    box-shadow: 0 0 15px var(--accent-primary);
    transition: transform 0.3s ease;
    position: relative;
    top: 40px;
}

.step-marker-container {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-marker {
    top: 0;
    margin: 0;
}

.timeline-step:hover .step-marker {
    transform: scale(1.3);
    background: var(--accent-primary);
}

.step-content {
    margin-top: 1rem;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--glass-border);
    
    /* 增加底部內距給箭頭，並設定 relative 以便定位 */
    padding: 1.5rem 1.5rem 2.5rem 1.5rem;
    position: relative;
    
    border-radius: 8px;
    transition: all 0.3s;
    min-height: 80px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.timeline-step:hover .step-content {
    transform: translateY(-5px);
    border-color: var(--accent-secondary);
    justify-content: flex-start;
}

.step-title {
    color: var(--accent-primary);
    font-family: 'Fira Code', monospace;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: block;
    transition: all 0.3s;
}

/*  小箭頭  */
.timeline-step .step-content::after,
#projects .card::after {
    content: '';
    position: absolute; /* 絕對定位 */
    bottom: 1.5rem;     
    left: 50%;         
    
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-secondary); 
    border-bottom: 2px solid var(--text-secondary);
    
    /* 修正置中偏移 (-50%) 並旋轉 (45deg) */
    transform: translateX(-50%) rotate(45deg);
    
    opacity: 0.6; 
    transition: all 0.3s ease; 
}

/* 懸停時隱藏 */
.timeline-step:hover .step-content::after,
#projects .card:hover::after {
    opacity: 0;
    transform: translateX(-50%) rotate(45deg) translateY(5px);
}
/* ========================================= */

/* --- Job Description Reveal --- */
.step-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.5s ease-in-out;
    margin-top: 0;
}

.timeline-step:hover .step-desc {
    max-height: 150px;
    opacity: 1;
    margin-top: 0.5rem;
}

/* --- Grid & Cards General --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--glass-border);
    
    padding: 3rem 2rem; 
    position: relative;
    
    border-radius: 16px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    
 
    min-height: 350px; 
    z-index: 1;
}

.card:hover {
    transform: scale(1.05);
    z-index: 100;
    background: #0f172a;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.1);
    border-color: var(--accent-primary);
    padding-top: 4rem; 
}

.card h3 {
    margin-bottom: 2rem; 
    color: var(--text-primary);
    text-align: center;
    transition: all 0.3s;
    width: 100%;
    
    
    min-height: 3.5rem; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem; 
}

/* --- Tech Stack (Achievements) --- */
.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem; 
    justify-content: center;
    width: 100%;
    margin-bottom: 0;
    transition: all 0.3s;
    min-height: 120px;
    align-content: flex-start;
}

.card:hover .tech-stack {
    margin-bottom: 1.5rem;
}

.tech-tag {
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem; 
    color: var(--accent-primary);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.6rem 1.2rem; 
    border-radius: 999px;
    border: 1px solid transparent;
    transition: border-color 0.3s;
    text-align: center;
}

.card:hover .tech-tag {
    border-color: rgba(56, 189, 248, 0.3);
    background: rgba(56, 189, 248, 0.15);
}

.card-desc {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.5s ease-in-out;
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
    width: 100%;
    line-height: 1.6;
}

.card:hover .card-desc {
    max-height: 300px;
    opacity: 1;
    margin-top: 0.5rem;
}

/* --- Optimized Skill List Styles (Areas of Expertise) --- */
.skill-list {
    list-style: none;
    padding: 0;
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;

    gap: 1.5rem; 
    justify-content: center;
    width: 100%;
    
    min-height: 200px; 
    align-content: center; 
}

.skill-list li {
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.2);
    color: var(--accent-primary);
    

    padding: 1rem 2rem; 
    min-width: 160px; 
    text-align: center;
    
    border-radius: 12px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem; 
    letter-spacing: 1.1px; 
    
    transition: all 0.3s ease;
    cursor: default;
    margin: 0;
    flex-grow: 0;
}

.skill-list li:hover {
    background: rgba(56, 189, 248, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
    color: #fff;
    border-color: var(--accent-primary);
}

/* --- Scroll Buttons --- */
.scroll-down-btn, 
.scroll-up-btn {
    position: fixed;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--accent-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    text-decoration: none;
    backdrop-filter: blur(12px);
}

.scroll-down-btn {
    bottom: 2rem;
}

.scroll-up-btn {
    bottom: 6rem; /* Positioned above the down button */
}

.scroll-down-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    transform: translateY(5px);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.scroll-up-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    transform: translateY(-5px);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

/* --- Scroll Animation Classes --- */
.fade-in-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, visibility;
}

.fade-in-section.is-visible {
    opacity: 1;
    transform: none;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 4rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--glass-border);
}

/* --- Responsive Timeline --- */
@media (max-width: 768px) {
    .hero-content h1 { font-size: 2.5rem; }
    .nav-links a { display: none; }
    .nav-links .lang-btn { display: flex; margin-left: auto; }

    .timeline-wrapper { padding-left: 20px; }
    .progress-line-bg, .progress-line-fill {
        width: 2px;
        height: 100%;
        left: 31px;
        top: 0;
        transform: none;
    }
    .timeline-steps {
        flex-direction: column;
        gap: 2rem;
    }
    .timeline-step {
        display: flex;
        align-items: flex-start;
        text-align: left;
        gap: 1.5rem;
    }
    .step-marker-container {
        height: auto;
        width: 24px;
        flex-shrink: 0;
        padding-top: 2rem;
    }
    .step-marker {
        margin: 0;
    }
    .step-content {
        width: 100%;
        margin-top: 0;
    }
    .card:hover {
        transform: scale(1.02);
    }
}
.hero-character {
    position: absolute;
    right: 5%;        
    top: 80%;         
    transform: translateY(-50%); 
    width: 200px;     
    height: 200px;
    z-index: 10;      
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 臉 (容器) */
.char-face {
    width: 100%;
    height: 100%;
    background-image: url('me.png'); 
    background-size: cover;
    background-position: center;
    background-color: #fdfdfd;
    
    border-radius: 50%;
    border: 4px solid #0f172a; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 眼睛區域 (容器) - 定位眼睛在臉上的位置 */
.char-eye-container {
    display: flex;
    position: relative;
    z-index: 2;
    
    
    gap: 12.8px;          /* 眼距 */
    /* [上下] */
    margin-top: 65.5px;  
    
    /* 左右 */
    margin-left: 1px;
}

/* 眼白 */
.char-eye {
    width: 14px;       /* 寬 */
    height: 14px;      /* 高 */
    background: #fff;
    border-radius: 50%;
    border: 1px solid #0f172a; 
    position: relative;
    overflow: hidden;
}

/* 眼珠 - 縮小 */
.char-pupil {
    width: 6px;        /* 眼珠縮小 */
    height: 6px;
    background: #0f172a;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    /* 初始置中，JS負責移動 */
    transform: translate(-50%, -50%);
}

/* 手機版調整：避免擋住文字，將其隱藏或縮小移位 */
@media (max-width: 768px) {
    .hero-character {
        display: none; /* 手機版版面較窄，建議隱藏 */
    }
}
body {
    -webkit-user-select: none; 
    -moz-user-select: none;    
    -ms-user-select: none;     
    user-select: none;         
}

img {
    -webkit-user-drag: none;   
    user-drag: none;
    pointer-events: none;      
}