.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 40px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background-color: #362f28;
    border-bottom: 1px solid #1a1817;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url(../img/carving1.webp);
    background-repeat: repeat-x;
    background-size: auto 100%;
    background-position: left top;
    opacity: 0.1;
    z-index: -1;
}

.header-logo {
    flex-shrink: 0;
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.3s ease;
}

.header-logo:hover {
    opacity: 0.8;
}

.header-logo img {
    height: 50px;
    width: auto;
    object-fit: contain;
    display: block;
}

.header-nav {
    display: flex;
    gap: 30px;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
    margin-right: 30px;
}

.nav-item {
    color: #E1A300;
    text-decoration: none;
    font-size: 1.12rem;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    background: transparent;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.nav-item:hover {
    opacity: 0.7;
}

/* 下拉選單 */
.nav-item-dropdown {
    position: relative;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 20px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #362f28;
    border: 1px solid rgba(225, 163, 0, 0.3);
    border-radius: 5px;
    padding: 10px 0;
    min-width: 180px;
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.nav-item-dropdown:hover .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-item-dropdown:focus-within .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown-menu li {
    margin: 0;
    padding: 0;
}

.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    color: #E1A300;
    text-decoration: none;
    font-size: 1rem;
    padding: 10px 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
    white-space: nowrap;
}

.nav-dropdown-menu a::after {
    content: '';
    display: block;
    width: 30px;
    height: 30px;
    margin-left: auto;
    /* Push icon to the right if space allows, or use margin-left: 8px to put right next to text */
    background-image: url('../img/Decorations7.webp');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    transform: translateX(-5px) scaleX(-1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.nav-dropdown-menu a:hover {
    background-color: rgba(225, 163, 0, 0.1);
    color: #fff068;
}

.nav-dropdown-menu a:hover::after {
    opacity: 1;
    transform: translateX(0) scaleX(-1);
}

.header-icons {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-shrink: 0;
}

.icon-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: opacity 0.3s ease;
}

.icon-link img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(0.8);
    /* 縮小 80% */
}

.icon-link:hover {
    opacity: 0.7;
}

button.icon-link {
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
    font: inherit;
    color: inherit;
}

/* 頁面搜尋 */
.page-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 10005;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 20px 20px;
    box-sizing: border-box;
    background: rgba(26, 24, 23, 0.72);
    backdrop-filter: blur(3px);
}

.page-search-overlay[hidden] {
    display: none !important;
}

.page-search-panel {
    width: 100%;
    max-width: 520px;
    background-color: #362f28;
    border: 1px solid rgba(225, 163, 0, 0.45);
    border-radius: 5px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    padding: 30px;
    box-sizing: border-box;
}

.page-search-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.page-search-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #E1A300;
    letter-spacing: 0.04em;
}

.page-search-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    background: transparent;
    color: #E1A300;
    font-size: 1.4rem;
    padding: 0;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.page-search-close:hover {
    background-color: rgba(225, 163, 0, 0.12);
    color: #fff068;
}

.page-search-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.page-search-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    font-size: 1rem;
    color: #f5f0e6;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(225, 163, 0, 0.35);
    border-radius: 5px;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.page-search-input::placeholder {
    color: rgba(245, 240, 230, 0.45);
}

.page-search-input:focus {
    border-color: #E1A300;
    box-shadow: 0 0 0 2px rgba(225, 163, 0, 0.2);
}

.page-search-meta {
    margin: 10px 0 8px;
    font-size: 0.88rem;
    color: rgba(245, 240, 230, 0.75);
}

.page-search-meta[hidden] {
    display: none !important;
    margin: 0;
}

.page-search-results {
    list-style: none;
    margin: 0;
    padding: 0 4px 0 0;
    max-height: min(52vh, 360px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-search-result {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 5px;
    border: 1px solid rgba(225, 163, 0, 0.22);
    background: rgba(0, 0, 0, 0.18);
    text-decoration: none;
    color: #f5f0e6;
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.page-search-result:hover {
    background-color: rgba(225, 163, 0, 0.1);
    border-color: rgba(225, 163, 0, 0.45);
    color: #fff068;
}

.page-search-result-cat {
    font-size: 0.78rem;
    color: #E1A300;
    opacity: 0.95;
}

.page-search-result:hover .page-search-result-cat {
    color: #fff068;
}

.page-search-result-title {
    font-size: 1rem;
    line-height: 1.35;
}

body.page-search-open {
    overflow: hidden;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-width: 36px;
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 11;
    line-height: 1;
    color: #E1A300;
    transition: opacity 0.25s ease;
}

.mobile-menu-toggle:hover {
    opacity: 0.85;
}

.mobile-menu-toggle-icon {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
    pointer-events: none;
}

.mobile-menu-toggle-label {
    font-size: 0.53rem;
    margin-top: 2px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #E1A300;
    user-select: none;
    pointer-events: none;
}

.mobile-menu-toggle.active {
    opacity: 0.9;
}

.mobile-nav {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    box-sizing: border-box;
    background-color: #362f28;
    background-image: url(../img/index-bg3.png);
    background-size: cover;
    background-position: center top;
    flex-direction: column;
    padding: calc(env(safe-area-inset-top, 0px) + 72px) 24px calc(env(safe-area-inset-bottom, 0px) + 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1002;
}

/* 全螢幕選單時：Logo 與右側圖示（含漢堡）疊在選單之上，以便關閉或前往首頁 */
.header:has(.mobile-nav.active) .header-logo,
.header:has(.mobile-nav.active) .header-icons {
    position: relative;
    z-index: 1003;
}

body.mobile-nav-open {
    overflow: hidden;
}

.mobile-nav-item {
    color: #E1A300;
    text-decoration: none;
    font-size: 1rem;
    padding: 12px 0;
    transition: opacity 0.3s ease;
}


.mobile-nav-item:active {
    opacity: 0.6;
}

@media (hover: hover) {
    .mobile-nav-item:hover {
        opacity: 0.7;
    }
}

.mobile-nav-group {
    border-bottom: 1px solid rgba(225, 163, 0, 0.2);
}

.mobile-nav-group:last-child {
    border-bottom: none;
}

.mobile-nav-title {
    color: #E1A300;
    font-size: 1.1rem;
    padding: 14px 0;
    cursor: pointer;
    list-style: none;
    /* Hide default marker */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
    position: relative;
}
.mobile-nav-title::before {
    content: '';
    background-image: url(../img/Decorations0.webp);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 18px;
    height: 18px;
    margin-right: 4px;
}
.mobile-nav-title::after {
    content: '';
    background-image: url(../img/Decorations0-2.webp);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
}
.mobile-nav-title::-webkit-details-marker {
    display: none;
}

.mobile-nav-title:active {
    opacity: 0.6;
}

@media (hover: hover) {
    .mobile-nav-title:hover {
        opacity: 0.7;
    }
}

.mobile-nav-submenu {
    display: flex;
    flex-direction: column;
    padding: 10px 20px;
    overflow: hidden;
    will-change: max-height, opacity;
    background-color: #f5f0e6;
    background-image: url(../img/cloud-bg2.webp);
    background-size: cover;
    background-position: center top;
    border: 1px solid #E1A300;
    border-radius: 5px;
}

.mobile-nav-submenu-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.mobile-nav-subitem {
    display: block;
    width: 100%;
    padding: 10px 0;
    color: #1a1817;
    text-align: center;
    border-bottom: 1px dashed #362f28;
    font-size: 0.95rem;
    opacity: 0.9;
}

.mobile-nav-subitem:last-child {
    border-bottom: none;
}

@media (max-width: 1024px) {
    .header {
        padding: 15px 30px;
    }

    .header-nav {
        gap: 20px;
        margin-right: 20px;
    }

    .nav-item {
        font-size: 1rem;
    }

    .main-banner {
        margin-top: 10px;
    }

    .page-banner {
        margin-top: 82px !important;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 12px 20px;
        flex-wrap: nowrap;
    }

    .header-logo img {
        height: 40px;
    }

    .header-nav {
        display: none;
    }

    .nav-dropdown-menu {
        display: none;
    }

    .header-icons {
        gap: 15px;
    }

    .icon-link {
        width: 20px;
        height: 20px;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .mobile-nav {
        display: flex;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition:
            opacity 0.38s ease,
            visibility 0.38s ease;
    }

    .mobile-nav.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .page-banner {
        margin-top: 65px !important;
    }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .mobile-nav {
        transition-duration: 0.01ms;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 10px 15px;
    }

    .header-logo img {
        height: 35px;
    }

    .header-nav {
        display: none;
    }

    .header-icons {
        gap: 12px;
    }

    .icon-link {
        width: 18px;
        height: 18px;
    }

    .mobile-menu-toggle-icon {
        width: 20px;
        height: 20px;
    }


    .mobile-nav {
        padding: calc(env(safe-area-inset-top, 0px) + 64px) 15px calc(env(safe-area-inset-bottom, 0px) + 18px);
    }

    .mobile-nav-item {
        font-size: 1rem;
        padding: 10px 0;
    }

    .page-banner {
        margin-top: 55px !important;
    }
}