/**
 * Clean Header Design - Ancient Chinese Minimalist Style
 * Single source of truth for header styles
 */

/* ================================
   Navbar Base
   ================================ */
.navbar {
    background: linear-gradient(180deg, #fdf8f0 0%, #f5ede0 100%);
    border-bottom: 3px solid #8b4513;
    box-shadow: 0 2px 8px rgba(93, 64, 55, 0.1);
    position: sticky;
    top: 0;
    z-index: 2000;
    padding: 0.75rem 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

/* ================================
   Brand Area
   ================================ */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.nav-brand .seal {
    width: 42px;
    height: 42px;
    background: #8b1a1a;
    color: #ffd700;
    border: 2px solid #5a1212;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    font-family: var(--font-kai, "Ma Shan Zheng", serif);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.nav-brand h1 {
    font-size: 1.5rem;
    margin: 0;
    color: #5C1010;
    font-weight: 600;
    letter-spacing: 1px;
    font-family: var(--font-kai, "Noto Serif TC", serif);
}

.nav-brand a {
    color: #5C1010;
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-brand a:hover {
    color: #8b1a1a;
}

/* ================================
   Navigation Menu
   ================================ */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: #2B2B2B;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-family: var(--font-serif, "Noto Sans TC", sans-serif);
}

.nav-menu li a:hover {
    color: #8b1a1a;
    background: rgba(139, 26, 26, 0.05);
}

.nav-menu li a.active {
    color: #8b1a1a;
    background: rgba(139, 26, 26, 0.08);
    font-weight: 600;
}

/* CTA Button */
.nav-menu li a.btn-cta {
    background: linear-gradient(135deg, #8b1a1a, #a82020);
    color: #fff !important;
    padding: 0.5rem 1.25rem;
    border-radius: 25px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(139, 26, 26, 0.3);
}

.nav-menu li a.btn-cta:hover {
    background: linear-gradient(135deg, #a82020, #c02525);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 26, 26, 0.4);
}

/* ================================
   Language Switcher
   ================================ */
.lang-switcher {
    position: relative;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border: 1.5px solid #8b4513;
    color: #5D4037;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    font-family: var(--font-serif);
}

.lang-btn:hover {
    background: #8b4513;
    color: #fff;
    transform: translateY(-1px);
}

.lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border: 1.5px solid #8b4513;
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 140px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 2100;
    display: none;
}

.lang-menu.show {
    display: block;
}

.lang-menu li {
    list-style: none;
}

.lang-menu li a {
    display: block;
    padding: 0.6rem 1rem !important;
    font-size: 0.95rem !important;
    color: #2B2B2B !important;
    text-decoration: none;
    border-radius: 0 !important;
    background: transparent !important;
}

.lang-menu li a:hover {
    background: rgba(139, 26, 26, 0.08) !important;
    color: #8b1a1a !important;
}

/* ================================
   Mobile Toggle Button
   ================================ */
.nav-toggle {
    display: none;
    background: #fff;
    border: 1.5px solid #8b4513;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.nav-toggle:hover {
    background: #f5ede0;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #8b4513;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.nav-toggle.is-active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.is-active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.is-active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Overlay */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2040;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-overlay.is-active {
    display: block;
    opacity: 1;
}

/* ================================
   Mobile Responsive
   ================================ */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex !important;
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 280px;
        max-width: 80vw;
        background: #fdf8f0;
        padding: 5rem 2rem 2rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        box-shadow: -4px 0 12px rgba(0, 0, 0, 0.2);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 2050;
        overflow-y: auto;
    }

    .nav-menu.is-open {
        transform: translateX(0);
    }

    .nav-menu li {
        width: 100%;
    }

    .nav-menu li a {
        width: 100%;
        padding: 0.75rem 1rem !important;
        border-radius: 6px !important;
    }

    .nav-menu li a.btn-cta {
        margin-top: 1rem !important;
        text-align: center;
    }

    .lang-switcher {
        width: 100%;
        margin-top: 1rem;
    }

    .lang-btn {
        width: 100%;
        justify-content: space-between;
        padding: 0.75rem 1rem;
    }

    .lang-menu {
        position: static;
        width: 100%;
        margin-top: 0.5rem;
        border: 1px dashed #8b4513;
    }
}

/* ================================
   Global Modal Styles
   ================================ */
.global-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.global-modal.is-visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.global-modal-box {
    background: linear-gradient(135deg, #fdf4e3 0%, #f5e6d3 100%);
    border: 2px solid #8b4513;
    border-radius: 16px;
    padding: 24px 28px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    text-align: center;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.global-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.global-modal-icon.success {
    color: #4caf50;
}

.global-modal-icon.error {
    color: #f44336;
}

.global-modal-icon.warning {
    color: #ff9800;
}

.global-modal-icon.info {
    color: #2196f3;
}

.global-modal-icon.confirm {
    color: #ff9800;
}

.global-modal-message {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 24px;
    line-height: 1.6;
}

.global-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.global-modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-modal-btn.primary {
    background: linear-gradient(135deg, #8b1a1a, #a02020);
    color: #fff;
}

.global-modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 26, 26, 0.4);
}

.global-modal-btn.secondary {
    background: #e0e0e0;
    color: #333;
}

.global-modal-btn.secondary:hover {
    background: #d0d0d0;
}


/* ================================
   Navbar Container & Layout
   ================================ */
.navbar {
    background: var(--bg-primary, #fdf4e3);
    /* Border and shadow are now handled in ancient-chinese.css */
    position: sticky;
    top: 0;
    z-index: 2060;
    padding: 0.5rem 0;
    transition: all 0.3s ease;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    overflow: visible;
}

/* ================================
   Brand Identity (Seal & Title)
   ================================ */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.nav-brand .seal {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    background-color: var(--ancient-red, #8B1A1A);
    color: #fff;
    border: 3px solid #5a1212;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-kai, "Ma Shan Zheng", serif);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 0, 0, 0.2);
    position: relative;
    /* Texture effect for seal */
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.15'/%3E%3C/svg%3E");
}

.nav-brand h1 {
    font-size: 1.6rem;
    margin: 0;
    color: var(--ancient-red-dark, #5C1010);
    font-family: var(--font-kai, "Ma Shan Zheng", serif);
    letter-spacing: 2px;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.nav-brand a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ================================
   Navigation Menu
   ================================ */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-menu>li>a {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 1.05rem;
    font-family: var(--font-serif, "Noto Serif TC", serif);
    font-weight: 600;
    color: var(--ancient-ink, #2B2B2B);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.nav-menu>li>a:hover,
.nav-menu>li>a.active {
    color: var(--ancient-red, #8B1A1A);
}


/* Primary Button (CTA) */
.nav-menu>li>a.btn-cta {
    background: linear-gradient(135deg, var(--ancient-red, #8B1A1A) 0%, #a02020 100%);
    color: #fff !important;
    /* Force white text */
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 6px rgba(139, 26, 26, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.nav-menu>li>a.btn-cta::after {
    display: none;
    /* No underline for button */
}

.nav-menu>li>a.btn-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(139, 26, 26, 0.3);
    background: linear-gradient(135deg, #a02020 0%, var(--ancient-red, #8B1A1A) 100%);
}

/* ================================
   Language Switcher
   ================================ */
.lang-switcher {
    position: relative;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid var(--ancient-brown, #5D4037);
    color: var(--ancient-brown, #5D4037);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    font-family: var(--font-serif);
}

.lang-btn:hover {
    background: var(--ancient-brown, #5D4037);
    color: var(--bg-primary, #F5E6D3);
}

.lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    background: var(--bg-secondary, #FDF5E6);
    border: 1px solid var(--ancient-brown, #5D4037);
    border-radius: 4px;
    padding: 0.5rem 0;
    min-width: 140px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 2100;
    display: none;
    /* Hidden by default, JS toggles this */
}

/* For animation if using class-based toggle */
.lang-menu.show {
    display: block;
}

.lang-menu li {
    list-style: none;
}

.lang-menu li a {
    display: block;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    color: var(--ancient-ink, #2B2B2B);
    text-decoration: none;
    transition: background 0.2s;
    font-family: var(--font-serif);
}

.lang-menu li a:hover {
    background: rgba(139, 69, 19, 0.1);
    color: var(--ancient-red, #8B1A1A);
}

/* ================================
   Mobile Navigation
   ================================ */
.nav-toggle {
    display: none;
    /* Hidden on desktop */
    background: #fff;
    border: 1px solid var(--ancient-brown, #5D4037);
    cursor: pointer;
    padding: 6px;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.nav-toggle:hover {
    background: var(--bg-secondary, #FDF5E6);
}

.nav-toggle span {
    display: block;
    width: 22px;
    /* Width of the lines */
    height: 2px;
    /* Thickness of lines */
    background-color: var(--ancient-brown, #5D4037);
    margin: 2.5px 0;
    /* Spacing between lines */
    transition: all 0.3s ease;
    border-radius: 2px;
}

.nav-toggle.is-active {
    border-color: var(--ancient-red, #8B1A1A);
    box-shadow: 0 0 5px rgba(139, 26, 26, 0.2);
}

.nav-toggle.is-active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
    background-color: var(--ancient-red, #8B1A1A);
}

.nav-toggle.is-active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.is-active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
    background-color: var(--ancient-red, #8B1A1A);
}

.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 2040;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-overlay.is-active {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {


    /* FORCE hamburger button to show as a box */
    .nav-toggle {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 40px !important;
        height: 40px !important;
        background: #fff !important;
        border: 1px solid var(--ancient-brown, #5D4037) !important;
        border-radius: 4px !important;
        padding: 6px !important;
        margin-left: auto !important;
        /* Push to the right */
    }

    .nav-toggle span {
        display: block !important;
        width: 22px !important;
        height: 2px !important;
        background-color: var(--ancient-brown, #5D4037) !important;
        margin: 2.5px 0 !important;
    }

    /* FORCE menu to be hidden by default & slide from right */
    .nav-menu {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        height: 100vh !important;
        width: 260px !important;
        max-width: 75vw !important;
        background: var(--bg-primary, #fdf4e3) !important;
        padding: 4rem 1.5rem 2rem !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.15) !important;
        transform: translateX(100%) !important;
        /* HIDDEN by default */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 2050 !important;
        overflow-y: auto !important;
    }

    .nav-menu.is-open {
        transform: translateX(0) !important;
        /* SHOW when open */
    }

    .nav-menu>li {
        width: 100% !important;
        margin: 0 !important;
    }

    /* RESET the blocky button look from responsive.css */
    .nav-menu>li>a {
        display: block !important;
        padding: 0.75rem 0.5rem !important;
        font-size: 1.05rem !important;
        border: none !important;
        background: transparent !important;
        text-align: left !important;
        border-bottom: 1px dashed rgba(139, 69, 19, 0.25) !important;
        width: 100% !important;
        color: var(--ancient-ink, #2B2B2B) !important;
        white-space: nowrap !important;
    }

    .nav-menu>li>a::after {
        display: none !important;
    }

    .nav-menu>li>a.btn-cta {
        margin-top: 1rem !important;
        text-align: center !important;
        background: var(--ancient-red, #8B1A1A) !important;
        color: #fff !important;
        border: none !important;
        border-radius: 50px !important;
        padding: 0.6rem 1.5rem !important;
    }

    /* Mobile Language Switcher */
    .lang-switcher {
        width: 100% !important;
        margin-top: 1rem !important;
    }

    .lang-btn {
        width: 100% !important;
        justify-content: space-between !important;
        padding: 0.8rem !important;
        font-size: 1rem !important;
    }

    .lang-menu {
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        border: 1px dashed var(--ancient-brown) !important;
        margin-top: 0.5rem !important;
        /* No !important here so JS can toggle display */
    }

    .lang-menu.show {
        display: block;
    }

    /* Overlay */
    .nav-overlay.is-active {
        display: block !important;
        opacity: 1 !important;
    }
}

/* ================================
   Global Modal Styles
   ================================ */
.global-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.global-modal.is-visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.global-modal-box {
    background: linear-gradient(135deg, #fdf4e3 0%, #f5e6d3 100%);
    border: 2px solid var(--ancient-brown, #8b4513);
    border-radius: 16px;
    padding: 24px 28px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    text-align: center;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.global-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.global-modal-icon.success {
    color: #4caf50;
}

.global-modal-icon.error {
    color: #f44336;
}

.global-modal-icon.warning {
    color: #ff9800;
}

.global-modal-icon.info {
    color: #2196f3;
}

.global-modal-icon.confirm {
    color: #ff9800;
}

.global-modal-message {
    font-size: 1.1rem;
    color: var(--ancient-ink, #333);
    margin-bottom: 24px;
    line-height: 1.6;
}

.global-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.global-modal-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-modal-btn.primary {
    background: linear-gradient(135deg, var(--ancient-red, #8b1a1a), #a02020);
    color: #fff;
}

.global-modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 26, 26, 0.4);
}

.global-modal-btn.secondary {
    background: #e0e0e0;
    color: #333;
}

.global-modal-btn.secondary:hover {
    background: #d0d0d0;
}

/* Mobile Layout Fix - Safe Append */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 1rem !important;
        padding: 0 1rem !important;
        flex-wrap: nowrap !important;
    }
}
