/* ==========================================================================
   【全站共用區 (Global / Common)】
   包含：變數、Reset、排版、導覽列、選單、頁尾、通用元件
   ========================================================================== */

/* --- 1. CSS 變數定義 --- */
:root {
    /* 核心色彩系統 */
    --bg-color: #000000;
    --text-main: #FFFFFF;
    --text-muted: #AAAAAA;
    --block-grey: #38393B;
    --header-gradient: linear-gradient(180deg, #323B46 0%, #0C1013 100%);
    --card-gradient: linear-gradient(180deg, #313A45 0%, #0C1013 100%);
    --btn-bg: #FFFFFF;
    --btn-text: #000000;
    --sidebar-inactive-color: #CACACA;

    /* 尺寸變數 */
    --header-height: 70px;
    --sub-nav-height: 50px;
    --logo-width: 190px;
    --logo-height: 30px;
}

/* --- 2. Reset 與基礎設定 --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Noto Sans TC', sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

ul {
    list-style: none;
}

a {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.3s ease;
}

a:hover {
    opacity: 0.8;
}

/* 頂部漸層遮罩層 (提升導覽列可讀性) */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    z-index: 900;
    pointer-events: none;
}

/* --- 3. 字體排版設定 (流體排版) --- */

/* 電腦版 (> 768px): 使用 vw 單位 */
@media screen and (min-width: 769px) {
    h1 { font-size: 3.125vw; font-weight: 700; line-height: 1.2; }
    h2 { font-size: 1.30vw; font-weight: 500; }
    h3 { font-size: 1.04vw; font-weight: 500; }
    h4 { font-size: 0.83vw; font-weight: 300; line-height: 1.6; }
    p, li, a { font-size: 0.83vw; font-weight: 300; line-height: 1.6; }

    /* 強制指定特定元素採用 H3 規格 */
    .btn-contact,
    .sub-nav a,
    .main-menu-list a,
    .group-title span,
    .footer-col h3,
    .service-card-text h3, 
    .card-text h3 {
        font-size: 1.04vw !important;
        font-weight: 500 !important;
    }
}

/* 手機版 (<= 768px): 固定 px 單位 */
@media screen and (max-width: 768px) {
    h1 { font-size: 32px; }
    h2 { font-size: 24px; }
    h3 { font-size: 20px; }
    h4 { font-size: 16px; font-weight: 300; }
    p, li, a { font-size: 16px; font-weight: 300; line-height: 1.6; }

    .btn-contact,
    .sub-nav a,
    .main-menu-list a,
    .group-title span,
    .footer-col h3,
    .service-card-text h3,
    .card-text h3 {
        font-size: 20px !important;
        font-weight: 500 !important;
    }
}

/* --- 4. 通用 UI 元件：按鈕 --- */
.btn {
    padding: 10px 40px;
    border-radius: 50px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-primary { background-color: var(--btn-bg); color: var(--btn-text); }
.btn-primary h3 { color: var(--btn-text) !important; margin: 0; }
.btn-primary:hover { opacity: 0.9; }

.btn-secondary { background-color: transparent; border: 2px solid var(--text-main); color: var(--text-main); }
.btn-secondary:hover { background-color: rgba(255,255,255,0.1); }
.btn-secondary h3 { margin: 0; }

.btn-icon { background: none; border: none; cursor: pointer; display: flex; align-items: center; padding: 5px; }

/* --- 5. 頁首元件 (Header) --- */
header {
    position: fixed;
    top: 35px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1800px;
    height: var(--header-height);
    background: var(--header-gradient);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2vw;
    border-radius: 35px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.logo-container { height: var(--logo-height); display: flex; align-items: center; }
.logo-container img { height: 30px; width: auto; display: block; }

.sub-nav { display: none; }
@media screen and (min-width: 769px) {
    .sub-nav {
        display: flex;
        height: var(--sub-nav-height);
        background-color: var(--block-grey);
        border-radius: 25px;
        padding: 0 60px;
        align-items: center;
    }
    .sub-nav ul { display: flex; gap: 60px; }
}

.action-group { display: flex; align-items: center; gap: 15px; }
.btn-contact {
    background-color: var(--btn-bg);
    color: var(--btn-text);
    height: 50px;
    padding: 0 40px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

@media screen and (max-width: 768px) {
    header {
        width: 92% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: 35px !important;
        padding: 0 20px !important;
    }
    .btn-contact { display: none !important; }
}

/* --- 6. 側邊選單 (Side Menu) --- */
#side-menu {
    position: fixed;
    background: var(--card-gradient);
    z-index: 9999;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: -5px 5px 20px rgba(0,0,0,0.5);
    overflow-y: auto;
    padding-bottom: 100px;
}
#side-menu.active { visibility: visible; opacity: 1; }
#side-menu::-webkit-scrollbar { display: none; }

.menu-header { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.main-menu-list { display: flex; flex-direction: column; gap: 15px; }
.main-menu-list > li > a, .group-title { display: flex; justify-content: space-between; align-items: center; padding: 10px 5px; color: var(--text-main); }
.group-content { display: block; margin-left: 15px; border-left: 1px solid rgba(255,255,255,0.2); padding-left: 10px; margin-top: 5px; margin-bottom: 10px; }
.group-content li a { display: block; padding: 8px 10px; color: rgba(255,255,255,0.7); }
.group-content li a:hover { color: white; background-color: rgba(255,255,255,0.05); border-radius: 4px; }

@media screen and (min-width: 769px) {
    #side-menu {
        top: calc(35px + var(--header-height) + 10px);
        right: 2vw;
        width: 300px;
        max-height: calc(100vh - (35px + var(--header-height) + 30px));
        border-radius: 20px;
        transform: translateY(-20px);
    }
    #side-menu.active { transform: translateY(0); }
}

@media screen and (max-width: 768px) {
    #side-menu {
        top: calc(35px + var(--header-height) + 10px);
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
        width: 92%;
        height: calc(100vh - (35px + var(--header-height) + 20px));
        border-radius: 20px;
    }
    #side-menu.active { transform: translateX(-50%) translateY(0); }
    .main-menu-list { gap: 35px !important; }
    .group-title { margin-bottom: 15px !important; }
    .group-content li a { padding: 15px 10px !important; line-height: 1.5; }
}

/* --- 7. 頁尾 (Footer) --- */
.site-footer {
    background-color: #0C1013;
    color: var(--text-muted);
    padding: 60px 20px 20px 20px;
    margin-top: auto;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto 60px auto;
    flex-wrap: wrap;
    gap: 40px;
}

.footer-col { flex: 1; min-width: 200px; }
.footer-col h3 { color: var(--text-main); margin-bottom: 25px; }
.footer-col ul { display: flex; flex-direction: column; gap: 15px; }
.footer-col ul li a { color: var(--text-muted); }
.footer-col ul li a:hover { color: var(--text-main); }

.footer-btn {
    display: inline-flex;
    background-color: var(--btn-bg);
    color: var(--btn-text);
    padding: 10px 40px;
    border-radius: 25px;
    font-weight: 500;
    margin-bottom: 20px;
    transition: opacity 0.3s;
}
.footer-btn:hover { opacity: 0.9; }

.social-icons { display: flex; gap: 20px; margin-top: 25px; }
.social-icons a svg { width: 24px; height: 24px; fill: #AAAAAA; transition: fill 0.3s; }
.social-icons a:hover svg { fill: var(--text-main); }

.footer-bottom {
    max-width: 1200px; margin: 0 auto; padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center; font-size: 14px; color: #666;
}

@media screen and (min-width: 769px) {
    .footer-col.footer-action { text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
    .social-icons { justify-content: flex-end; }
}

@media screen and (max-width: 768px) {
    .footer-top { flex-direction: column; text-align: center; gap: 50px; }
    .footer-col.footer-action { align-items: center; text-align: center; }
    .social-icons { justify-content: center; }
}

/* --- 8. Cookie 彈窗 (Cookie Popup) --- */
.cookie-popup {
    position: fixed;
    bottom: -150px; /* 初始隱藏在螢幕下方 */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1000px;
    z-index: 10000;
    background: var(--header-gradient);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    padding: 20px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.cookie-popup.show {
    bottom: 30px; /* 顯示時滑入的最終位置 */
    opacity: 1;
    visibility: visible;
}

.cookie-text p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.6;
}

.cookie-text a {
    color: #66B2FF;
    text-decoration: underline;
    transition: color 0.3s;
    font-weight: 500;
}

.cookie-text a:hover {
    color: #99CCFF;
}

.cookie-action .btn-primary {
    white-space: nowrap;
    padding: 12px 35px;
    font-size: 1rem;
    cursor: pointer;
}

@media screen and (max-width: 768px) {
    .cookie-popup {
        flex-direction: column;
        padding: 25px 20px;
        border-radius: 20px;
        text-align: center;
        gap: 20px;
    }
    .cookie-action {
        width: 100%;
    }
    .cookie-action .btn-primary {
        width: 100%;
        padding: 15px 0;
    }
}

/* ==========================================================================
   【首頁專用區 (Homepage Specific)】
   包含：Hero 區塊、背景影片、卡片輪播、關於我、服務項目
   ========================================================================== */

main {
    padding-top: 0;
    flex-grow: 1;
}

/* --- 1. Hero Section (主視覺) --- */
.hero-section {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.video-background {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
}

/* 影片遮罩 */
.video-background::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2;
}

.bg-video {
    width: 100%; height: 100%; object-fit: cover;
    position: absolute; top: 0; left: 0;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 1;
}
.bg-video.active { opacity: 1; }

.hero-content {
    position: relative;
    z-index: 5;
    width: 90%;
    max-width: 1800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2vw;
}

.hero-text { max-width: 50%; }
.hero-text h1 { margin-bottom: 1.5rem; }
.hero-text h2 { margin-bottom: 2.5rem; font-weight: 300; line-height: 1.5; }

/* 標題動畫 */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.hero-text h1, .hero-text h2, .hero-buttons { opacity: 0; }
.fade-in-up { animation: fadeInUp 0.6s ease-out forwards; }
.hero-text h2.fade-in-up { animation-delay: 0.1s; }
.hero-buttons.fade-in-up { animation-delay: 0.2s; }

.hero-buttons { display: flex; gap: 1.5vw; }

.hero-controls { display: flex; flex-direction: column; gap: 15px; }
.control-btn {
    width: 60px; height: 60px; border-radius: 50%;
    background-color: rgba(0,0,0,0.3); border: 2px solid var(--text-main);
    color: var(--text-main); display: flex; justify-content: center; align-items: center;
    cursor: pointer; font-size: 24px; transition: background-color 0.3s ease;
}
.control-btn:hover { background-color: rgba(0,0,0,0.6); }

@media screen and (max-width: 768px) {
    .hero-content {
        flex-direction: column;
        justify-content: flex-end; /* 文字置底 */
        text-align: center;
        padding-bottom: 140px; /* 避開底部卡片 */
        height: 100vh;
    }
    .hero-text { max-width: 100%; margin-bottom: 30px; }
    .hero-buttons { flex-direction: column; justify-content: center; gap: 15px; }
    .btn { white-space: nowrap; width: 100%; max-width: 250px; margin: 0 auto; }
    .hero-controls { display: none !important; }
}

/* --- 2. Card Slider Section (底部卡片輪播) --- */
.card-slider-section {
    position: absolute;
    bottom: 3vh;
    width: 90%;
    max-width: 1800px;
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-container {
    display: flex;
    gap: 1.5vw;
    overflow-x: auto;
    scroll-behavior: smooth;
    -ms-overflow-style: none; scrollbar-width: none;
    cursor: grab;
    padding-bottom: 10px;
    padding-top: 10px;
    width: 100%;
}
.card-container::-webkit-scrollbar { display: none; }

.content-card {
    min-width: 300px;
    flex: 0 0 auto;
    width: 20vw;
    height: 6vw;
    background: var(--card-gradient);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease;
    padding: 0;
    overflow: hidden;
}

.content-card:hover, .content-card.active { transform: translateY(-5px); border-color: rgba(255,255,255,0.5); }

.card-thumbnail {
    height: 100%;
    width: auto;
    aspect-ratio: 1/1;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
    flex-shrink: 0;
    background-color: #222;
}

.card-text {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 20px;
    flex: 1;
}

.card-text h3 { margin-bottom: 5px; white-space: nowrap; }
.card-text h4 { color: var(--text-muted); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 進度條 */
.progress-bar-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 3px;
    background-color: rgba(255, 255, 255, 0.2); opacity: 0; transition: opacity 0.3s ease;
    z-index: 10;
}
.content-card.active .progress-bar-container { opacity: 1; }
.progress-bar { width: 0%; height: 100%; background-color: #FFFFFF; transition: width 0.1s linear; }

/* 滾動箭頭 */
.scroll-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 50px; height: 50px; border-radius: 50%;
    background-color: rgba(30, 30, 30, 0.7); border: 1px solid rgba(255, 255, 255, 0.2);
    color: white; cursor: pointer; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.scroll-arrow.visible { opacity: 1; visibility: visible; }
.scroll-left { left: -20px; }
.scroll-right { right: -20px; }

@media screen and (max-width: 768px) {
    .content-card { width: 280px; min-width: 280px; height: auto; }
    .card-thumbnail { height: 80px; width: 80px; } 
    .scroll-arrow { display: none !important; }
}

/* --- 3. About Section (關於我) --- */
.about-section {
    width: 100%;
    padding: 100px 0;
    background: var(--card-gradient);
    display: flex;
    justify-content: center;
}

.about-container {
    width: 90%; max-width: 1200px;
    display: flex;
    align-items: center;
    gap: 5vw;
}

.about-photo-column { flex: 1; }
.about-photo-column img { width: 100%; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }

.about-text-column { flex: 1.2; }
.about-title { margin-bottom: 2rem; }
.about-title h2 { color: var(--text-main); margin-bottom: 0.5rem; }
.about-text-column h4 { color: var(--text-muted); text-align: justify; line-height: 1.8; font-weight: 300; }

@media screen and (max-width: 768px) {
    .about-container { flex-direction: column; text-align: center; }
    .about-photo-column { width: 80%; margin-bottom: 30px; }
    .about-text-column h4 { text-align: left; }
}

/* --- 4. Services Section (服務項目) --- */
.services-section {
    background-color: var(--bg-color);
    padding: 100px 0;
    position: relative;
}

.services-wrapper {
    position: relative;
    overflow: hidden;
    transition: max-height 0.8s ease-in-out;
}

.services-container {
    width: 90%; max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2vw;
}

.service-card-link { display: block; height: 100%; }
.service-card {
    background: var(--card-gradient);
    border-radius: 20px;
    padding: 20px;
    height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex; flex-direction: column;
}

.service-card-link:hover .service-card { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.3); }

.service-card-image-wrapper { width: 100%; margin-bottom: 20px; }
.service-card-image-wrapper img { width: 100%; height: auto; border-radius: 12px; display: block; }

.service-card-text h3 { margin-bottom: 10px; color: var(--text-main); }
.service-card-text h4 { color: var(--text-muted); font-weight: 300; }

.show-more-container {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 200px;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    background: linear-gradient(to top, var(--bg-color) 30%, rgba(0,0,0,0));
    padding-bottom: 30px; cursor: pointer; display: none;
}
.show-more-container p { font-size: 16px; margin-bottom: 10px; }
#show-more-btn {
    background: none; border: 1px solid var(--text-main); color: var(--text-main);
    width: 40px; height: 40px; border-radius: 50%; font-size: 18px;
    cursor: pointer; transition: all 0.3s ease;
}
#show-more-btn:hover { background-color: var(--text-main); color: var(--bg-color); }

.show-less-btn {
    display: none; margin: 20px auto 0;
    background: none; border: 1px solid var(--text-muted); color: var(--text-muted);
    padding: 8px 20px; border-radius: 20px; cursor: pointer;
    font-size: 14px;
}
.show-less-btn:hover { color: var(--text-main); border-color: var(--text-main); }

@media screen and (max-width: 992px) {
    .services-container { grid-template-columns: repeat(2, 1fr); }
}

@media screen and (max-width: 768px) {
    .services-container { grid-template-columns: 1fr; gap: 30px; }
}

/* ==========================================================================
   【作品集列表專用樣式 (Portfolio Grid System)】
   補強 Layout 空間與 RWD 排版
   ========================================================================== */

/* 1. 列表頁面主容器：解決被 Header 遮擋與貼邊問題 */
.portfolio-list-section {
    width: 90%;
    max-width: 1800px;
    margin: 0 auto;
    padding-top: calc(var(--header-height) + 80px); 
    padding-bottom: 100px;
    min-height: 100vh;
}

/* 2. 標題區域間距 */
.portfolio-header {
    margin-bottom: 50px;
}

/* 3. 卡片網格系統 (Grid System) */
.portfolio-grid {
    display: grid;
    gap: 2vw;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}

/* --- 保留原有的卡片視覺樣式 (Card Visual Styles) --- */
.portfolio-card {
    display: flex;
    flex-direction: column;
    background: var(--card-gradient);
    border-radius: 20px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: 100%;
}

.portfolio-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

.card-img-box {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background-color: #222;
}

.card-img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    display: block;
}

.portfolio-card:hover .card-img-box img {
    transform: scale(1.05);
}

.card-text-box {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
}

.card-text-box h3 {
    margin: 0 0 5px 0;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-text-box h4 {
    margin: 0 0 15px 0;
    color: var(--text-muted);
    font-weight: 300;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 10px;
    margin-top: auto;
}

.card-meta span {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* 4. 手機版強制調整 (Mobile Override) */
@media screen and (max-width: 768px) {
    .portfolio-list-section {
        width: 92%;
        padding-top: 140px;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .card-text-box h3 {
        font-size: 20px !important;
    }
    
    .card-text-box h4 {
        font-size: 16px !important;
    }
}