/* =========================================
   1. 變數與全域設定 - 午夜極光主題
   ========================================= */
:root {
    --bg-color: #050505;
    --card-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    
    /* 漸層主色調 */
    --gradient-1: #00f2ff; /* 青色 */
    --gradient-2: #bd00ff; /* 紫色 */
    
    --font-heading: 'Outfit', sans-serif; /* 更現代的字體 */
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
}

/* 背景流光動畫容器 */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: #050505;
}

/* 流光球體 */
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite ease-in-out;
}

.orb-1 {
    width: 40vw;
    height: 40vw;
    background: var(--gradient-1);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 35vw;
    height: 35vw;
    background: var(--gradient-2);
    bottom: -5%;
    right: -5%;
    animation-delay: -5s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, 50px) scale(1.1); }
}

/* =========================================
   2. 懸浮導航列 (Floating Pill)
   ========================================= */
.navbar {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px; /* 膠囊型 */
    padding: 0.8rem 2rem;
    background: rgba(10, 10, 10, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

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

.highlight {
    background: linear-gradient(45deg, var(--gradient-1), var(--gradient-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s;
    position: relative;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--text-primary);
}

/* 連結下方的光點 */
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 4px;
    height: 4px;
    background: var(--gradient-1);
    border-radius: 50%;
    transition: transform 0.3s;
}

.nav-links a:hover::after {
    transform: translateX(-50%) scale(1);
}

.burger { display: none; } /* 電腦版隱藏 */

/* =========================================
   3. Hero Section (極簡大氣)
   ========================================= */
#hero {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0 2rem;
}

.hero-content h1 {
    font-family: var(--font-heading);
    font-size: 5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    animation: fadeInUp 1s ease forwards 0.5s;
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto 3rem;
    opacity: 0;
    animation: fadeInUp 1s ease forwards 0.8s;
}

.cta-button {
    display: inline-block;
    padding: 1rem 2.5rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 50px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: fadeInUp 1s ease forwards 1.1s;
}

/* 按鈕懸停時的光暈流動 */
.cta-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.cta-button:hover {
    border-color: var(--gradient-1);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

.cta-button:hover::before {
    transform: translateX(100%);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   4. 關於我 (卡片式佈局)
   ========================================= */
section {
    padding: 8rem 2rem;
    overflow: visible; /* 改成 visible，讓內容可以超出邊界而不被切斷 */
    position: relative;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 3rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 4rem;
    align-items: center;
}

.profile-img {
    width: 100%;
    border-radius: 20px;
    /* 取消原本的邊框，改用陰影 */
    box-shadow: 20px 20px 60px rgba(0,0,0,0.5);
    transition: transform 0.5s;
}

.profile-img:hover {
    transform: scale(1.02) rotate(-2deg);
}

.section-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 2rem;
    display: inline-block;
}

.section-title span { color: var(--gradient-1); }

/* =========================================
   5. 作品集 (Bento Grid 風格)
   ========================================= */
.filter-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 4rem;
}

.main-filters {
    background: rgba(255,255,255,0.05);
    padding: 0.5rem;
    border-radius: 50px;
    display: inline-flex;
    margin-bottom: 1.5rem;
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.8rem 2rem;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.filter-btn.active, .filter-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* 子分類動畫 */
.sub-filters-container {
    height: 0;
    overflow: hidden;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
/* 1. 預設狀態：完全隱藏，不佔空間，不可點擊 */
.sub-filter-group {
    display: none; 
    opacity: 0;
    transform: translateY(-10px);
}
/* 2. 啟動狀態：顯示並執行進場動畫 */
.sub-filter-group.active {
    display: flex; /* 只有 active 時才變成 flex，其他時候是 none */
    
    /* 這裡保留我們上次加大的內距，保護陰影 */
    padding: 20px 10px; 
    
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible;
    
    /* 加入進場動畫，讓它出現時還是有滑順感 */
    animation: fadeSlideIn 0.4s ease forwards;
}
/* 定義進場動畫關鍵影格 */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.sub-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.5rem 1.2rem;
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.3s;
}
.sub-btn:hover, .sub-btn.active {
    border-color: var(--gradient-2);
    color: var(--gradient-2);
    background: rgba(189, 0, 255, 0.05);
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.portfolio-item {
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 1 / 1; /* 正方形便當格 */
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 移除原本的 Glitch 效果，改為高級縮放 */
.portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s;
}

/* 懸停覆蓋層 */
.item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    opacity: 0;
    transition: 0.4s;
    display: flex;
    align-items: flex-end;
    padding: 1.5rem;
}

.portfolio-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    z-index: 2;
}

.portfolio-item:hover img {
    transform: scale(1.1);
}

.portfolio-item:hover .item-overlay {
    opacity: 1;
}

.portfolio-item.d-none { display: none; }
.portfolio-item.hide { opacity: 0; transform: scale(0.9); pointer-events: none; }

/* =========================================
   6. 聯絡表格 (玻璃輸入框)
   ========================================= */
.contact-form {
    max-width: 600px;
    margin: 0 auto;
}

.input-group {
    position: relative;
    margin-bottom: 2rem;
}

.input-group input,
.input-group textarea {
    width: 100%;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 1.2rem;
    color: #fff;
    font-size: 1rem;
    font-family: var(--font-body);
    transition: 0.3s;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--gradient-1);
    background: rgba(255,255,255,0.05);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.1);
}

.input-group label {
    position: absolute;
    left: 1.2rem;
    top: 1.2rem;
    color: #666;
    pointer-events: none;
    transition: 0.3s;
}

/* Label 上浮動畫 */
.input-group input:focus ~ label,
.input-group input:not(:placeholder-shown) ~ label,
.input-group textarea:focus ~ label,
.input-group textarea:not(:placeholder-shown) ~ label {
    top: -0.8rem;
    left: 0.5rem;
    font-size: 0.8rem;
    color: var(--gradient-1);
    background: var(--bg-color);
    padding: 0 0.5rem;
}

.submit-button {
    width: 100%;
    padding: 1.2rem;
    background: linear-gradient(90deg, var(--gradient-1), var(--gradient-2));
    border: none;
    border-radius: 15px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    font-size: 1rem;
}

.submit-button:hover {
    filter: brightness(1.2);
    transform: scale(0.98);
}

/* =========================================
   7. Lightbox (極簡全黑)
   ========================================= */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(20px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.lightbox-content {
    max-height: 85vh;
    max-width: 90vw;
    border-radius: 10px;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    animation: zoomIn 0.3s ease;
}

.lightbox-nav {
    background: rgba(255,255,255,0.1);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    transition: 0.3s;
    position: absolute;
}
.lightbox-nav:hover { background: var(--gradient-1); color: #000; }
.lightbox-nav.prev { left: 2rem; }
.lightbox-nav.next { right: 2rem; }
.lightbox-close { 
    position: absolute; 
    top: 2rem; 
    right: 2rem; 
    font-size: 3rem; 
    cursor: pointer; 
    color: #fff;
    transition: 0.3s;
}
.lightbox-close:hover { color: var(--gradient-2); transform: rotate(90deg); }

/* =========================================
   8. RWD 響應式
   ========================================= */
@media screen and (max-width: 768px) {
    .navbar {
        width: 100%;
        max-width: 100%;
        top: 0;
        left: 0;
        transform: none;
        border-radius: 0;
        border-top: none;
        border-left: none;
        border-right: none;
        padding: 1rem;
    }

    .hero-content h1 { font-size: 3rem; }

    .about-grid { grid-template-columns: 1fr; }
    
    .portfolio-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

    /* 手機版漢堡選單 */
    .burger { display: block; cursor: pointer; z-index: 1002; }
    .burger div {
        width: 25px; height: 2px; background: #fff; margin: 6px; transition: 0.3s;
    }
    .burger.toggle .line1 { transform: rotate(-45deg) translate(-5px, 6px); }
    .burger.toggle .line2 { opacity: 0; }
    .burger.toggle .line3 { transform: rotate(45deg) translate(-5px, -6px); }

    .nav-links {
        position: fixed;
        top: 0; right: 0;
        height: 100vh;
        width: 70%;
        background: #050505;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transform: translateX(100%);
        transition: 0.4s ease;
        border-left: 1px solid var(--glass-border);
    }
    .nav-links.nav-active { transform: translateX(0); }
}

@keyframes zoomIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* =========================================
   99. 互動式待機模式 Screensaver
   ========================================= */
.screensaver {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999; /* 蓋過所有內容 */
    opacity: 0;
    pointer-events: none; /* 隱藏時不阻擋點擊 */
    transition: opacity 0.8s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screensaver.active {
    opacity: 1;
    pointer-events: all;
}

#saver-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* 詢問框樣式 */
.saver-prompt {
    position: relative;
    background: rgba(20, 20, 20, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2.5rem;
    border-radius: 20px;
    text-align: center;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10001;
    box-shadow: 0 0 50px rgba(0, 242, 255, 0.1);
}

/* 當滑鼠移動時，透過 JS 加上 show class */
.saver-prompt.show {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.saver-prompt h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.saver-prompt p {
    color: #888;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.saver-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.saver-btn {
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.saver-btn.wake {
    background: var(--gradient-1);
    color: #000;
}
.saver-btn.wake:hover {
    box-shadow: 0 0 15px var(--gradient-1);
}

.saver-btn.dream {
    background: transparent;
    border: 1px solid #555;
    color: #fff;
}
.saver-btn.dream:hover {
    border-color: var(--gradient-2);
    color: var(--gradient-2);
}

/* === 漢堡選單強力修復補丁 === */
@media screen and (max-width: 768px) {
    .burger {
        display: block !important;
        position: relative; /* 確保 z-index 生效 */
        z-index: 10005 !important; /* 比待機畫面(10000)還高，確保點得到 */
        width: 40px; /* 給它明確的點擊範圍 */
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        /* 測試用：如果這行加下去看到紅色方塊，代表按鈕位置是對的 */
        /* background: rgba(255,0,0,0.2); */ 
    }
    
    /* 確保選單展開時也夠高 */
    .nav-links {
        z-index: 10004 !important;
    }
}