/* top.css - 國立中央大學光電系專用 */
:root {
    --ncu-red: #a30a0a;
    --ncu-red2: #810000;
    --ncu-blue: #001a33;
    --ncu-gold: #b3995d;
    --text-main: #ffffff;
    --bg-white: #ffffff;
}

.skip-link {
    display: block;
    width: 100%;
    overflow: hidden;
    background: #07081c;
    color: #fff;
}

.header {
    background: var(--ncu-red2);
    border-bottom: 2px solid var(--ncu-blue);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1360px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 90px;
}

.logo {
    width: 150px;
}

.logo img {
    width: 100%;
}

.logo a {
    text-decoration: none;
}

.logo-text .univ {
    display: block;
    color: var(--ncu-blue);
    font-weight: 800;
    font-size: 1.2rem;
}

.logo-text .dept {
    display: block;
    color: #555;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* 主選單設計 */
.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 100%;
}

.nav-menu>li {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-menu>li>a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    padding: 0 15px;
    height: 100%;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.nav-menu>li>a:hover,
.nav-menu>li>a:focus {
    color: #b9b0b0;
    background-color: rgba(0, 51, 102, 0.05);
    outline: none;
}

/* 下拉子選單 (Submenu) */
.submenu {
    position: absolute;
    top: 90px;
    left: 0;
    background: var(--bg-white);
    min-width: 180px;
    list-style: none;
    padding: 10px 0;
    margin: 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-top: 2px solid var(--ncu-blue);
    display: none;
    /* 預設隱藏 */
}

.has-submenu:hover .submenu,
.has-submenu:focus-within .submenu {
    display: block;
    /* 滑鼠懸停或鍵盤聚焦時顯示 */
}

.submenu li a {
    padding: 12px 20px;
    display: block;
    text-decoration: none;
    color: #444;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.submenu li a:hover,
.submenu li a:focus {
    background-color: var(--ncu-blue);
    color: white;
}

/* 語言切換按鈕 */
.lang-switch a {
    border: 1.5px solid #ffffff;
    padding: 5px 12px !important;
    border-radius: 4px;
    margin-left: 10px;
    height: auto !important;
}

/* --- RWD Media Queries --- */
/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.hamburger {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--text-main);
    position: relative;
    transition: background-color 0.2s;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    background-color: var(--text-main);
    left: 0;
    transition: all 0.3s;
}

.hamburger::before {
    top: -8px;
}

.hamburger::after {
    bottom: -8px;
}

.menu-toggle.active .hamburger {
    background-color: transparent;
}

.menu-toggle.active .hamburger::before {
    transform: rotate(45deg);
    top: 0;
}

.menu-toggle.active .hamburger::after {
    transform: rotate(-45deg);
    bottom: 0;
}

@media screen and (max-width: 1200px) {
    .logo {
        width: 100px;
    }

    .menu-toggle {
        padding: 10px;
        z-index: 1001;
    }

    .hamburger {
        display: block;
        width: 25px;
        height: 3px;
        background-color: var(--text-main);
        position: relative;
        transition: background-color 0.2s;
    }

    .hamburger::before,
    .hamburger::after {
        content: '';
        position: absolute;
        width: 100%;
        height: 3px;
        background-color: var(--text-main);
        left: 0;
        transition: all 0.3s;
    }

    .hamburger::before {
        top: -8px;
    }

    .hamburger::after {
        bottom: -8px;
    }

    .menu-toggle.active .hamburger {
        background-color: transparent;
    }

    .menu-toggle.active .hamburger::before {
        transform: rotate(45deg);
        top: 0;
    }

    .menu-toggle.active .hamburger::after {
        transform: rotate(-45deg);
        bottom: 0;
    }


    .menu-toggle {
        display: block;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 90px;
        left: 0;
        width: 100%;
        background-color: var(--ncu-red2);
        height: auto;
        padding: 0;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        max-height: calc(100vh - 90px);
        overflow-y: auto;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu>li {
        width: 100%;
        height: auto;
        flex-direction: column;
        align-items: flex-start;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-menu>li>a {
        padding: 15px 20px;
        width: 100%;
        justify-content: space-between;
    }

    .submenu {
        position: static;
        display: none;
        width: 100%;
        background: transparent;
        box-shadow: none;
        border-top: none;
        padding: 0;
    }

    .has-submenu.open .submenu {
        display: block;
    }

    .has-submenu:hover .submenu,
    .has-submenu:focus-within .submenu {
        display: none;
        /* Override desktop hover behavior on mobile */
    }

    .has-submenu.open:hover .submenu,
    .has-submenu.open:focus-within .submenu {
        display: block;
    }

    .submenu li a {
        padding: 12px 30px;
        color: #efefef;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .submenu li a:hover,
    .submenu li a:focus {
        background-color: rgba(0, 0, 0, 0.15);
        color: white;
    }

}

/* 超小屏幕（手機） */
@media screen and (max-width: 768px) {
    .logo {
        width: 80px;
    }

    .nav-container {
        height: 70px;
        padding: 0 10px;
    }

    .nav-menu {
        top: 70px !important;
        max-height: calc(100vh - 70px);
    }

    .submenu {
        top: auto;
    }
}

/* --- English Version Adjustments --- */
html[lang="en"] .nav-container {
    max-width: 1440px;
    /* Give more space for English menu */
}

html[lang="en"] .logo {
    width: 130px;
    /* Shrink logo slightly */
}

@media screen and (min-width: 1201px) and (max-width: 1440px) {
    html[lang="en"] .logo {
        width: 100px;
        /* Shrink logo more on medium screens */
    }
}

@media screen and (max-width: 1320px) {

    /* Trigger mobile menu earlier for English version if items still don't fit */
    html[lang="en"] .menu-toggle {
        display: block;
    }

    html[lang="en"] .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 90px;
        left: 0;
        width: 100%;
        background-color: var(--ncu-red2);
        height: auto;
        padding: 0;
        box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        max-height: calc(100vh - 90px);
        overflow-y: auto;
    }

    html[lang="en"] .nav-menu.active {
        display: flex;
    }

    html[lang="en"] .nav-menu>li {
        width: 100%;
        height: auto;
        flex-direction: column;
        align-items: flex-start;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    html[lang="en"] .nav-menu>li>a {
        padding: 15px 20px;
        width: 100%;
        justify-content: space-between;
        font-size: 1rem;
    }

    html[lang="en"] .submenu {
        position: static;
        display: none;
        width: 100%;
        background: transparent;
        box-shadow: none;
        border-top: none;
        padding: 0;
    }

    html[lang="en"] .has-submenu.open .submenu {
        display: block;
    }

    html[lang="en"] .has-submenu:hover .submenu {
        display: none;
    }
}