/* =========================================
   0. 全域變數與重置 (Variables & Reset)
   ========================================= */
:root {
    --primary-blue: #1c355e;   /* 企業主色 (深藍) */
    --accent-red: #d32f2f;     /* 點綴色 (紅色線條) */
    --footer-bg: #b8c1cb;      /* 頁尾灰藍色 */
    --text-dark: #333333;
    --text-light: #ffffff;
    --text-gray: #555555;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--text-light);
}

a {
    text-decoration: none;
    transition: color var(--transition-speed);
}

/* =========================================
   1. 頁首導覽列 (Smart Header)
   ========================================= */
.site-header {
    padding: 15px 0;
    position: sticky;       /* 讓 Header 黏在最上方 */
    top: 0;
    z-index: 1000;
    background-color: var(--primary-blue); /* 預設在最頂端時的深藍色 */
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease; 
}

/* 狀態 1：往下滑時 -> 往上隱藏 */
.site-header.header-hidden {
    transform: translateY(-100%);
}

/* 狀態 2：往上滑時 -> 出現且呈現 50% 透明度 */
.site-header.header-scrolled-up {
    background-color: rgba(30, 58, 95, 0.5); 
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px); 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); 
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo 區塊 */
.logo-block {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon-placeholder {
    width: 75px;
    height: 75px;
    background-color: #ffffff;
    border: 2px solid var(--accent-red);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.logo-text {
    color: var(--text-light);
    font-size: 42px;
    font-weight: bold;
    letter-spacing: 2px;
    border-bottom: 4px solid var(--accent-red);
}

/* 漢堡按鈕 (預設電腦版隱藏) */
.hamburger-btn {
    display: none;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    z-index: 100;
}

.hamburger-btn .bar {
    width: 20px;
    height: 2px;
    background-color: var(--text-light);
    transition: all 0.3s ease;
    border-radius: 3px;
}

/* 導覽列 */
.nav-block {
    display: flex;
    align-items: center;
    gap: 40px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 40px;
}

.main-nav a {
    color: var(--text-light); 
    font-size: 24px; 
    font-weight: 500; 
    text-align: center;
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
}

.main-nav a:hover {
    opacity: 0.8;
}

/* 語言切換區塊 */
.lang-selector {
    position: relative;
    z-index: 10010 !important; /* 確保層級極高 */
}

.lang-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    cursor: pointer;
    padding: 10px 0;
}

.icon-globe { width: 20px; height: 20px; }
.icon-arrow { width: 16px; height: 16px; }

/* 語言下拉選單 */
.lang-dropdown {
    position: absolute;
    top: 100%;
    right: -10px;
    background-color: #172a4d;
    border-radius: 6px;
    list-style: none;
    width: 110px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 10011 !important; /* 確保下拉不被擋住 */
}

.lang-selector:hover .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-dropdown li a {
    display: block;
    padding: 12px 15px;
    color: #ffffff;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.lang-dropdown li a:hover {
    background-color: #5d6d88;
}

/* =========================================
   2. 英雄區塊 (Hero Section)
   ========================================= */
.hero-section {
    background-image: url('img/company.jpg');  
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    height: 80vh; 
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.5);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-content h1 {
    font-size: 72px;
    color: var(--primary-blue);
    font-weight: 900;
    letter-spacing: 15px;
    text-shadow: 0px 4px 10px rgba(255, 255, 255, 0.8); 
}

/* =========================================
   3. 目錄資訊區塊 (Directory Section)
   ========================================= */
.directory-section {
    background-color: var(--primary-blue);
    padding: 60px 0;
}

.directory-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

.directory-col {
    padding: 0 30px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.directory-col:last-child {
    border-right: none;
}

.col-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-light);
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 25px;
}

.col-title .arrow {
    font-size: 14px;
}

.col-list {
    list-style: none;
}

.col-list li {
    color: rgba(255, 255, 255, 0.8);
    font-size: 20px;
    margin-bottom: 15px;
    line-height: 1.4;
}

/* =========================================
   4. 頁尾區塊 (Footer)
   ========================================= */
.site-footer {
    background-color: var(--footer-bg);
    padding: 24px 0;
    margin-bottom: 0;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
}

.contact-header h2 {
    color: var(--text-gray);
    font-size: 30px;
    font-weight: 800;
}

.contact-details {
    color: var(--text-gray);
    font-size: 18px;
    font-weight: bold;
    display: flex;
    gap: 15px;
    align-items: center;
}

.copyright {
    color: var(--text-gray);
    font-size: 14px;
    font-weight: bold;
}

.footer-logo {
    color: var(--primary-blue);
    font-size: 64px;
    font-weight: 900;
    line-height: 1;
}

/* 確保 Email 連結與旁邊的文字看起來一致 */
.footer-email {
    color: var(--text-gray);      /* 保持與 ADD/TEL 相同的顏色 */
    text-decoration: none;        /* 移除底線 */
    cursor: pointer;              /* 滑鼠移入顯示手指指標 */
    transition: opacity 0.2s;
}

/* 當滑鼠移上去時，加上一點視覺反饋 */
.footer-email:hover {
    opacity: 0.7;
    color: #666666;                  /* 滑鼠懸停時微調顏色 */
}

/* =========================================
   5. 共用元件：懸浮提示框 (Tooltip)
   ========================================= */
.col-list li, .contact-details span {
    position: relative;
}

.nav-icon-link:hover {
    background-color: #ffffff !important;
    color: var(--primary-blue) !important;
    transform: scale(1.1);
}

.nav-icon-link::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 135%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background-color: rgba(0, 0, 0, 0.85);
    color: #ffffff !important;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: normal;
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    line-height: 1.4;
    letter-spacing: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 999;
}

.nav-icon-link::before {
    content: '';
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 999;
}

.nav-icon-link:hover::after,
.nav-icon-link:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* =========================================
   6. 專屬英文版微調 (html[lang="en"])
   ========================================= */
html[lang="en"] .logo-text {
    font-size: 36px;
    line-height: 1.2;
    margin-top: 4px;
}

html[lang="en"] .hero-content h1 {
    font-size: 72px;
    color: var(--primary-blue);
    line-height: 2;
    text-align: center;
    text-shadow: 0px 4px 10px rgba(255, 255, 255, 0.8); 
}

html[lang="en"] .footer-info {
    display: flex;
    flex-direction: column;
}

html[lang="en"] .footer-email {
    color: var(--text-gray);
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
}

html[lang="en"] .copyright-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

html[lang="en"] .copyright-row .copyright {
    margin: 0;
}


/* =========================================
   ★ RWD 響應式排版設計：平板 (Max-Width: 1180px) ★
   ========================================= */
@media (max-width: 1180px) {
    .header-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .logo-text { font-size: 30px; }

    .hero-content h1 {
        font-size: 50px;
        letter-spacing: 10px;
    }

    .directory-container {
        grid-template-columns: repeat(2, 1fr); /* 4 欄改為 2 欄 */
        row-gap: 40px;
    }

    .directory-col:nth-child(2) { border-right: none; }

    .footer-container {
        flex-direction: column;
        text-align: center;
        gap: 30px;
    }
    
    .contact-header { justify-content: center; }

    /* 英文版微調 */
    html[lang="en"] .logo-text { font-size: 30px; }
    html[lang="en"] .hero-content h1 { font-size: 24px; }
}


/* =========================================
   ★ RWD 響應式排版設計：手機 (Max-Width: 768px) ★
   ========================================= */
@media (max-width: 768px) {
    /* Header & 漢堡選單 */
    .header-container {
        position: relative;
        flex-direction: row; 
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
    }
    
    .logo-block { gap: 10px; }
    .logo-icon-placeholder { width: 45px; height: 45px; }
    .logo-icon-placeholder img { height: 45px !important; }
    
    .logo-text {
        font-size: 18.5px;
        border-bottom: 2px solid var(--accent-red);
    }

    .hamburger-btn { display: flex; }

    /* 下拉面板導覽列 */
    .nav-block {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--primary-blue);
        flex-direction: column;
        align-items: center;
        padding: 20px 0;
        gap: 20px;
        box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
        z-index: 90;
    }

    .nav-block.active { display: flex; }
    
    .main-nav {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .main-nav a { font-size: 20px; }

    /* 手機版語言選單 (置中往下 & 配合 JS 強制顯示) */
    /* =========================================
       手機版 (768px以下) 語言切換：隱藏圖示、直接橫向顯示一行
       ========================================= */
    /* 1. 隱藏地球儀與箭頭圖示，減少使用者點擊步驟 */
    .lang-trigger {
        display: none !important;
    }

    /* 2. 讓語言區塊容器滿版，並給予舒適的上下間距 */
    .lang-selector {
        width: 100% !important;
        position: relative !important;
        padding: 5px 50px 0 50px !important;
        z-index: 10010 !important;
    }

    /* 3. 解除原本的滑鼠 Hover 隱藏邏輯，強制變為 Flex 橫向整排顯示 */
    .lang-dropdown {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        transform: none !important;
        
        /* 強制永遠顯示並橫向排列 */
        display: flex !important;
        flex-direction: row !important; 
        justify-content: center !important;
        align-items: center !important;
        gap: 3px !important; /* 按鈕彼此之間的左右間距 */
        
        width: 100% !important;
        background-color: transparent !important; /* 拔掉原先的深藍色下拉底色包圍盒 */
        box-shadow: none !important;
        list-style: none !important;
        
        /* 覆蓋掉 Hover 隱藏的開關屬性，讓它直接常駐可見 */
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        padding: 0 !important;
    }

    /* 4. 讓 3 個語言選項平均瓜分整行寬度，並讓內部文字置中 */
    .lang-dropdown li {
        flex: 1 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        justify-content: center !important; /* 確保內部的 a 標籤置中 */
    }

    /* 5. 移除框線與背景，改為跟首頁導覽列一樣的「純文字 + 預留透明底線」 */
    .lang-dropdown li a {
        display: inline-block !important; /* 讓底線寬度剛剛好包住文字 */
        padding: 8px 2px !important;      /* 縮小左右 padding 讓底線更貼合字數 */
        font-size: 16px !important;       /* 稍微放大字體配合無框線視覺 */
        font-weight: 500 !important;
        color: #ffffff !important;
        white-space: nowrap !important;
        
        /* 移除先前的按鈕樣式 */
        background-color: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        
        /* 預留一條透明的 2px 底線，防止點擊時畫面跳動 */
        border-bottom: 2px solid transparent !important; 
        transition: border-color 0.2s !important;
    }

    /* 6. 當點擊時的反饋效果 */
    .lang-dropdown li a:active {
        border-bottom: 2px solid rgba(255, 255, 255, 0.5) !important;
    }

    /* 7. ★ 核心：讓目前所在語系的按鈕，底線永遠停留保持顯示 ★ */
    /* 當網頁是繁體中文時，底線停留在 [data-lang="tw"] */
    html[lang="zh-Hant"] .lang-dropdown li a[data-lang="tw"],
    /* 當網頁是簡體中文時，底線停留在 [data-lang="cn"] */
    html[lang="zh-Hans"] .lang-dropdown li a[data-lang="cn"],
    /* 當網頁是英文版時，底線停留在 [data-lang="en"] */
    html[lang="en"] .lang-dropdown li a[data-lang="en"] {
        border-bottom: 2px solid var(--text-light) !important;
        font-weight: bold !important; /* (選用) 讓當前語言的字體稍微加粗，視覺更清晰 */
    }

    /* 英雄區塊 (Hero Banner) 比例修正 */
    .hero-section {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9;
        background-size: cover !important;
    }

    .hero-content h1 {
        font-size: 32px;
        letter-spacing: 5px;
        text-align: center;
    }

    /* 目錄改為單欄 */
    .directory-container {
        grid-template-columns: 1fr;
        padding: 0 20px;
    }

    .directory-col {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        padding: 0 0 20px 0;
    }

    .directory-col:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    /* 頁尾調整 */
    .contact-header h2 { font-size: 26px; }
    
    .contact-details, .footer-email {
        font-size: 16px;
        flex-direction: column;
        gap: 5px;
    }

    .copyright { font-size: 10px; }
    .footer-logo { font-size: 40px; }
    
    .copyright-row {
        flex-direction: column-reverse; 
        align-items: flex-start;
        gap: 8px;
        margin-top: -5px;
    }

    /* 英文版微調 */
    html[lang="en"] .logo-text { font-size: 18px; }
    html[lang="en"] .footer-email {
        font-size: 16px;
    }
}