/* ===== 變數定義：深色主題 ===== */
:root {
    --primary-color: #0d0d0d;
    --secondary-color: #1a1a1a;
    --accent-color: #9f00ff;
    --text-color: #e0e0e0;
    --heading-color: #ffffff;
    --font-family: 'Noto Sans TC', sans-serif;
}

/* ===== 基本設定 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--primary-color);
    color: var(--text-color);
    line-height: 1.6;
}

h1, h2, h3 {
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 1rem;
}

section {
    padding: 6rem 2rem;
    overflow: hidden; /* Prevents layout shifts from animations */
}

/* ===== 互動粒子背景 ===== */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* ===== 導覽列 Navbar ===== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    background: rgba(13, 13, 13, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.logo a {
    color: var(--heading-color);
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
}

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

.nav-links li {
    margin-left: 2rem;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: var(--accent-color);
}

.burger {
    display: none;
}

.burger div {
    width: 25px;
    height: 3px;
    background-color: var(--heading-color);
    margin: 5px;
    transition: all 0.3s ease;
}

.burger.toggle .line1 {
    transform: rotate(-45deg) translate(-5px, 6px);
}
.burger.toggle .line2 {
    opacity: 0;
}
.burger.toggle .line3 {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* ===== 首頁主視覺 Hero Section ===== */
#hero {
    height: 100vh;
    padding: 0;
    background: linear-gradient(rgba(13, 13, 13, 0.7), rgba(13, 13, 13, 0.9)), url('images/hero-background.jpg') no-repeat center center/cover fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.hero-content {
    background: transparent;
    padding: 2rem 4rem;
    border-radius: 10px;
}

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

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.cta-button {
    background: var(--accent-color);
    color: white;
    padding: 0.8rem 1.8rem;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 700;
    transition: background 0.3s ease, transform 0.3s ease;
    cursor: pointer;
}

.cta-button:hover {
    background: #7a00c7;
    transform: translateY(-3px);
}

/* ===== 作品集 Portfolio Section ===== */
#portfolio {
    background: var(--primary-color);
}

#portfolio h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2.5rem;
}

.filter-buttons {
    text-align: center;
    margin-bottom: 3rem;
}

.filter-btn {
    background: transparent;
    border: 1px solid #444;
    color: var(--text-color);
    padding: 0.6rem 1.2rem;
    margin: 0 0.5rem;
    border-radius: 20px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: background 0.3s, color 0.3s;
    cursor: pointer;
}

.filter-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.filter-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.sub-filter-container {
    text-align: center;
    margin: -1.5rem 0 3rem 0; /* 調整與主篩選和作品的間距 */
    overflow: hidden;
    max-height: 200px; /* 給一個足夠的高度 */
    transition: max-height 0.5s ease-out, opacity 0.5s ease-out;
    opacity: 1;
}

.sub-filter-container.hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    margin-bottom: 0;
    pointer-events: none; /* 隱藏時不可點擊 */
}

.portfolio-grid {
    display: grid;
    /* 將 minmax 的 400px 改為 320px，讓排版更緊湊 */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.portfolio-item {
    background-color: transparent;
    border: 1px solid #222;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.4s ease, opacity 0.4s ease;
    cursor: pointer;
}

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


/* 這個 class 負責從佈局中徹底移除元素 */
.portfolio-item.d-none {
    display: none;
}

.glitch-wrapper {
    position: relative;
    overflow: hidden;
}

.portfolio-item img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

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

/* Glitch Effect - Styled to work with JS-created elements */
.glitch-before, .glitch-after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

@keyframes glitch-anim-1 {
  0% { clip-path: polygon(0 2%, 100% 2%, 100% 5%, 0 5%); }
  10% { clip-path: polygon(0 15%, 100% 15%, 100% 15%, 0 15%); }
  20% { clip-path: polygon(0 10%, 100% 10%, 100% 20%, 0 20%); }
  30% { clip-path: polygon(0 1%, 100% 1%, 100% 2%, 0 2%); }
  40% { clip-path: polygon(0 33%, 100% 33%, 100% 33%, 0 33%); }
  50% { clip-path: polygon(0 44%, 100% 44%, 100% 44%, 0 44%); }
  60% { clip-path: polygon(0 50%, 100% 50%, 100% 50%, 0 50%); }
  70% { clip-path: polygon(0 70%, 100% 70%, 100% 70%, 0 70%); }
  80% { clip-path: polygon(0 80%, 100% 80%, 100% 80%, 0 80%); }
  90% { clip-path: polygon(0 50%, 100% 50%, 100% 55%, 0 55%); }
  100% { clip-path: polygon(0 70%, 100% 70%, 100% 80%, 0 80%); }
}

@keyframes glitch-anim-2 {
    0% { clip-path: polygon(0 65%, 100% 65%, 100% 65%, 0 65%);}
    15% { clip-path: polygon(0 40%, 100% 40%, 100% 40%, 0 40%);}
    25% { clip-path: polygon(0 50%, 100% 50%, 100% 50%, 0 50%);}
    35% { clip-path: polygon(0 5%, 100% 5%, 100% 5%, 0 5%);}
    45% { clip-path: polygon(0 20%, 100% 20%, 100% 20%, 0 20%);}
    55% { clip-path: polygon(0 10%, 100% 10%, 100% 10%, 0 10%);}
    65% { clip-path: polygon(0 85%, 100% 85%, 100% 85%, 0 85%);}
    75% { clip-path: polygon(0 40%, 100% 40%, 100% 45%, 0 45%);}
    85% { clip-path: polygon(0 15%, 100% 15%, 100% 25%, 0 25%);}
    95% { clip-path: polygon(0 5%, 100% 5%, 100% 10%, 0 10%);}
    100% { clip-path: polygon(0 90%, 100% 90%, 100% 95%, 0 95%);}
}

.glitch-wrapper:hover .glitch-before {
    opacity: 1;
    transform: translate3d(-3px, 0, 0);
    animation: glitch-anim-1 1s infinite linear alternate-reverse;
}

.glitch-wrapper:hover .glitch-after {
    opacity: 1;
    transform: translate3d(3px, 0, 0);
    animation: glitch-anim-2 1s infinite linear alternate-reverse;
}

/* ===== 關於我 About Section ===== */
#about {
    background-color: var(--secondary-color);
}

.about-container {
    display: flex;
    align-items: center;
    gap: 4rem;
    max-width: 1100px;
    margin: 0 auto;
}

.about-image {
    flex: 1;
}

.about-image img {
    width: 100%;
    max-width: 350px;
    border-radius: 10px;
    border: 3px solid var(--accent-color);
}

.about-text {
    flex: 2;
}

/* Typewriter Cursor */
.typewriter {
    position: relative;
}
.typewriter.typing::after {
    content: '_';
    position: absolute;
    right: -10px; /* Adjust as needed */
    animation: blink 0.7s infinite;
}
@keyframes blink {
    50% { opacity: 0; }
}


/* ===== 聯絡 Contact Section ===== */
#contact {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

#contact p {
    margin-bottom: 2rem;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.contact-form input,
.contact-form textarea {
    background: var(--secondary-color);
    border: 1px solid #333;
    color: var(--text-color);
    padding: 1rem;
    border-radius: 5px;
    font-family: var(--font-family);
    font-size: 1rem;
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.submit-button {
    background: var(--accent-color);
    color: white;
    padding: 1rem;
    text-decoration: none;
    border: none;
    border-radius: 5px;
    font-weight: 700;
    font-size: 1rem;
    transition: background 0.3s ease;
    cursor: pointer;
}

.submit-button:hover {
    background: #7a00c7;
}

.social-links {
    margin-top: 3rem;
}

.social-links a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 1rem;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--accent-color);
}

/* ===== 頁腳 Footer ===== */
footer {
    text-align: center;
    padding: 2rem;
    background-color: var(--secondary-color);
    margin-top: 4rem;
    font-size: 0.9rem;
    color: #888;
}

/* ===== 轉場效果 Transition Overlay (雙向快門新版) ===== */
.transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1001;
    pointer-events: none;
}

/* 建立上下兩個快門面板 */
.transition-overlay::before,
.transition-overlay::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 51%; /* 略大於50%，確保中間無縫隙 */
    background-color: var(--accent-color);
    transform: scaleY(0);
    transition: transform 0.4s cubic-bezier(0.86, 0, 0.07, 1);
}

/* 上方面板 */
.transition-overlay::before {
    top: 0;
    transform-origin: top;
}

/* 下方面板 */
.transition-overlay::after {
    bottom: 0;
    transform-origin: bottom;
}

/* --- 動畫觸發 --- */
/* 階段一：快門關閉 */
.transition-overlay.active::before,
.transition-overlay.active::after {
    transform: scaleY(1);
}

/* 階段二：快門打開 (改變 transform-origin 讓它從中間向外展開) */
.transition-overlay.open::before {
    transform-origin: bottom;
}
.transition-overlay.open::after {
    transform-origin: top;
}


/* ===== Lightbox 燈箱/彈出視窗樣式 ===== */
.lightbox {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: fadeIn 0.4s ease;
}

body.lightbox-active {
    overflow: hidden;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-content {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    animation: zoomIn 0.4s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.8); }
    to { transform: scale(1); }
}

.lightbox-caption {
    margin-top: 15px;
    color: var(--text-color);
    font-size: 1.1rem;
    text-align: center;
    animation: slideUp 0.4s ease;
}

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

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 45px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
}

/* ===== 秘密獎勵 Secret Reward ===== */
.secret-reward-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    color: #0f0;
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.secret-reward-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.secret-reward-overlay pre {
    font-size: 1.2vw;
    line-height: 1.4;
    text-align: center;
}

/* ===== 響應式設計 RWD ===== */
@media screen and (max-width: 1024px) {
    .about-container {
        flex-direction: column;
        text-align: center;
    }
}

@media screen and (max-width: 768px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }

    .nav-links {
        position: fixed;
        right: 0px;
        height: 100vh;
        top: 0;
        background: var(--primary-color);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 80%;
        max-width: 300px;
        transform: translateX(100%);
        transition: transform 0.5s ease-in-out;
        z-index: 999;
    }

    .nav-links li {
        opacity: 0;
        margin: 2rem 0;
        transform: translateX(50px);
        transition: opacity 0.5s ease, transform 0.5s ease;
    }

    .burger {
        display: block;
        z-index: 1001; /* Ensure it's above the nav panel */
        cursor: pointer;
    }
    
    .nav-active {
        transform: translateX(0%);
    }

    .nav-active li {
        opacity: 1;
        transform: translateX(0);
    }
    .nav-active li:nth-child(1) { transition-delay: 0.1s; }
    .nav-active li:nth-child(2) { transition-delay: 0.2s; }
    .nav-active li:nth-child(3) { transition-delay: 0.3s; }

    .hero-content {
        padding: 1rem;
    }

    .secret-reward-overlay pre {
        font-size: 3vw;
    }
    
    /* ===== CRT Scanline Effect (for atmosphere on mobile) ===== */
    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0) 0,
            rgba(255, 255, 255, 0.08) 1px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0) 4px
        );
        pointer-events: none;
        z-index: 9998;
        opacity: 0.5;
        animation: flicker 0.15s infinite;
    }

    @keyframes flicker {
        0% { opacity: 0.4; }
        20% { opacity: 0.6; }
        40% { opacity: 0.3; }
        60% { opacity: 0.7; }
        80% { opacity: 0.4; }
        100% { opacity: 0.5; }
    }

    /* ===== 頁腳連結按鈕樣式 ===== */
.footer-link-button {
    display: inline-block; /* 讓 margin 和 padding 生效 */
    margin-top: 1rem;      /* 與上面的版權文字間隔 */
    padding: 0.7rem 1.5rem;
    border: 1px solid var(--accent-color);
    border-radius: 50px;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    transition: background-color 0.3s, color 0.3s;
}

.footer-link-button:hover {
    background-color: var(--accent-color);
    color: var(--heading-color);
}
}