/* --- 全域變數與主題設定 --- */
:root {
    /* 預設為深色模式 (Dark Mode) */
    --primary-color: #4fd1c5;
    --primary-hover: #81e6d9;
    --background-color: #171923;
    --background-gradient: linear-gradient(135deg, #171923 0%, #1a202c 100%);
    --card-background: rgba(45, 55, 72, 0.6);
    --navbar-background: rgba(23, 25, 35, 0.85);
    --text-color: #f7fafc;
    --text-muted: #a0aec0;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --form-filter: invert(1) hue-rotate(180deg);
    
    --heading-font: 'Montserrat', sans-serif;
    --body-font: 'Noto Sans TC', sans-serif;
    --transition-speed: 0.3s;
}

/* 亮色模式 (Light Mode) */
[data-theme="light"] {
    --primary-color: #319795;
    --primary-hover: #2c7a7b;
    --background-color: #f7fafc;
    --background-gradient: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    --card-background: rgba(255, 255, 255, 0.8);
    --navbar-background: rgba(255, 255, 255, 0.9);
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-color: rgba(160, 174, 192, 0.3);
    --form-filter: none;
}

/* --- 基礎設定 (Footer 置底) --- */
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--body-font);
    color: var(--text-color);
    background: var(--background-gradient);
    background-attachment: fixed;
    line-height: 1.8;
    transition: background 0.5s ease, color 0.5s ease;
    min-height: 100vh;
    
    /* Footer 置底關鍵設定 */
    display: flex;
    flex-direction: column;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; position: relative; }

/* --- 導覽列 --- */
.navbar {
    background-color: var(--navbar-background);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-speed);
}
.navbar .container { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.logo { 
    font-family: var(--heading-font); 
    font-size: 1.5rem; 
    color: var(--text-color); 
    text-decoration: none; 
    font-weight: 700; 
    letter-spacing: -0.5px; 
}

.navbar nav { display: flex; align-items: center; }
.navbar nav ul { 
    list-style: none; margin: 0; padding: 0; 
    display: flex; gap: 2rem; align-items: center; margin-right: 3rem; 
}
.navbar nav ul li a { 
    color: var(--text-muted); font-weight: 600; text-decoration: none; 
    position: relative; padding: 0.5rem 0; transition: color var(--transition-speed); font-size: 0.95rem;
}
.navbar nav ul li a:hover, .navbar nav ul li a.active { color: var(--text-color); }
.navbar nav ul li a::after {
    content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 2px;
    background-color: var(--primary-color); transition: width var(--transition-speed) ease;
}
.navbar nav ul li a:hover::after, .navbar nav ul li a.active::after { width: 100%; }

.theme-toggle {
    background: none; border: none; cursor: pointer; color: var(--text-color);
    font-size: 1.2rem; padding: 0.5rem; transition: transform 0.3s ease, color 0.3s ease;
    display: flex; align-items: center; justify-content: center;
    position: absolute; right: 1.5rem; top: 50%; transform: translateY(-50%);
}
.theme-toggle:hover { color: var(--primary-color); transform: translateY(-50%) rotate(15deg); }

/* --- 頁面轉場 (淡入+淡出+Footer置底) --- */
.page-transition {
    opacity: 1; transform: translateY(0);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    
    /* 讓內容撐開高度 */
    flex: 1; display: flex; flex-direction: column; 
}
.page-transition main { flex: 1; display: flex; flex-direction: column; }
.page-transition main .page-section { flex: 1; display: flex; flex-direction: column; justify-content: center; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
body.fade-out .page-transition { opacity: 0; transform: translateY(-10px); }

/* --- Hero Section --- */
.hero-section {
    min-height: calc(100vh - 76px);
    display: flex; align-items: center; justify-content: center; text-align: center;
    background: linear-gradient(rgba(23, 25, 35, 0.7), rgba(23, 25, 35, 0.7)), url('../images/hero-background.jpg') center center / cover no-repeat;
    position: relative; width: 100%;
}
[data-theme="light"] .hero-section {
    background: linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.85)), url('../images/hero-background.jpg') center center / cover no-repeat;
}
.hero-content h1 {
    font-family: var(--heading-font); font-size: clamp(2.5rem, 6vw, 4.5rem);
    color: var(--text-color); margin: 0 0 1rem; text-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.hero-content p { font-size: 1.25rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 2.5rem; }

/* --- 按鈕樣式 --- */
.cta-button {
    display: inline-block; background-color: var(--primary-color); color: #fff;
    padding: 0.8rem 2.5rem; border-radius: 50px; font-size: 1rem; font-weight: 700;
    text-decoration: none; border: none; cursor: pointer;
    box-shadow: 0 4px 15px rgba(79, 209, 197, 0.3); transition: all 0.3s ease;
}
.cta-button:hover { background-color: var(--primary-hover); transform: translateY(-3px); box-shadow: 0 8px 25px rgba(79, 209, 197, 0.5); }

/* --- 通用卡片與區塊 --- */
.page-section { padding: 6rem 0; width: 100%; }
.page-section h2 { 
    text-align: center; font-size: 2.5rem; color: var(--text-color); 
    margin-bottom: 3.5rem; position: relative; font-weight: 800;
}
.page-section h2::after {
    content: ''; display: block; width: 60px; height: 5px;
    background: var(--primary-color); margin: 1rem auto 0; border-radius: 3px;
}

.project-card, .project-info-box, .about-content, .skills-list span, #contact-form input, #contact-form textarea, .embed-wrapper {
    background: var(--card-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 var(--shadow-color);
}

/* --- 內嵌內容 (Google Form / Web App) 美化 - 修正版 --- */
.embed-wrapper {
    position: relative;
    /* 修改這裡：放寬最大寬度 */
    max-width: 100%; 
    margin: 0 auto;
    border-radius: 12px; overflow: hidden;
}
.embed-wrapper iframe {
    border: none; display: block;
    filter: var(--form-filter); 
    transition: filter 0.5s ease;
}

/* --- 關於我 --- */
.about-content {
    display: grid; grid-template-columns: 250px 1fr; gap: 4rem; align-items: center;
    padding: 3rem; border-radius: 20px; margin-bottom: 4rem;
}
.about-avatar {
    width: 250px; height: 250px; border-radius: 20px; overflow: hidden;
    border: 4px solid var(--primary-color); box-shadow: 0 0 20px rgba(79, 209, 197, 0.3);
}
.about-avatar img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.about-avatar:hover img { transform: scale(1.05); }

.skills-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.skills-list span {
    padding: 0.6rem 1.2rem; border-radius: 12px; font-weight: 600;
    color: var(--text-color); transition: transform 0.2s;
}
.skills-list span:hover { transform: translateY(-3px); border-color: var(--primary-color); }

/* --- 聯絡我 --- */
.contact-container { text-align: center; }
.contact-info { font-size: 1.2rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 2.5rem; }
.contact-buttons { margin-top: 2.5rem; display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; }
.contact-buttons a {
    display: inline-block; background-color: var(--primary-color); color: #fff;
    padding: 0.8rem 2rem; border-radius: 50px; font-size: 1.1rem; font-weight: 700;
    text-decoration: none !important; border-bottom: none !important;
    transition: background-color 0.3s ease, transform 0.3s ease; box-shadow: 0 4px 15px rgba(79, 209, 197, 0.3);
}
.contact-buttons a:hover {
    background-color: var(--primary-hover); transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(79, 209, 197, 0.5); text-decoration: none !important;
}

/* --- 專案列表 --- */
.project-cards-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2.5rem; }
.project-card { border-radius: 16px; overflow: hidden; transition: transform 0.3s ease; display: flex; flex-direction: column; }
.project-card:hover { transform: translateY(-10px); }
.project-image { height: 220px; background-size: cover; background-position: center; position: relative; }
.project-image::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.6), transparent); }
.project-card-content { padding: 2rem; flex-grow: 1; display: flex; flex-direction: column; }
.project-card-content h3 { margin: 0 0 1rem; color: var(--text-color); font-size: 1.5rem; }
.project-card-content p { color: var(--text-muted); margin-bottom: 2rem; flex-grow: 1; }
.project-link { 
    color: var(--primary-color); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 0.9rem;
    align-self: flex-start; text-decoration: none;
}
.project-link:hover { text-decoration: underline; }

/* --- 頁尾 --- */
.footer {
    background-color: var(--navbar-background); padding: 3rem 1rem; text-align: center; color: var(--text-muted);
    border-top: 1px solid var(--border-color); backdrop-filter: blur(10px);
}
.footer .social-links a {
    margin: 0 12px; color: var(--text-muted); font-size: 1.5rem; transition: all 0.3s ease; display: inline-flex;
    width: 45px; height: 45px; align-items: center; justify-content: center;
    border-radius: 50%; background: rgba(255,255,255,0.05); text-decoration: none !important;
}
.footer .social-links a:hover { color: #fff; background: var(--primary-color); transform: translateY(-3px); }

/* --- RWD --- */
@media (max-width: 768px) {
    .navbar .container { flex-direction: column; gap: 1rem; }
    .about-content { grid-template-columns: 1fr; text-align: center; padding: 2rem; }
    .about-avatar { margin: 0 auto; }
    .navbar nav ul { gap: 1rem; font-size: 0.9rem; margin-right: 0; flex-wrap: wrap; justify-content: center; }
    .theme-toggle { position: static; transform: none; margin-top: 0.5rem; }
    .theme-toggle:hover { transform: rotate(15deg); }
}
