/**

 * Xuan Cuong Handicraft - Module: header.css

 * Top Bar, Sticky Navigation, Brand Logo, Mega Menu & Header Actions

 */


/* ==========================================================================
   TOP BAR (LIGHT / PROMO ANNOUNCEMENT - Matches User Screenshot)
   ========================================================================== */
.top-bar {
    background-color: #EFF3DD;
    font-size: 0.95rem;
    padding: 16px 0;
    /* Sticky cùng header: topbar dính ở mép trên, header dính ngay bên dưới (top = --xc-topbar-h, main.js đo) */
    position: sticky;
    top: 0;
    z-index: 100000;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-bar .top-bar {
    top: 32px;
}

/* Ẩn/hiện cùng header khi cuộn xuống/lên (main.js mục 5) */
.top-bar.is-hidden {
    transform: translateY(-100%);
}

.admin-bar .top-bar.is-hidden {
    transform: translateY(calc(-100% - 32px));
}

.top-bar-inner-centered {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Topbar luôn 1 dòng; chữ dài hơn khung thì chạy qua lại theo trục X (main.js thêm .is-marquee) */
.top-bar .top-bar-inner-centered {
    overflow: hidden;
}

.top-bar-announcement-text {
    white-space: nowrap;
    flex-shrink: 0;
    color: #161519;
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 28px;
}

.top-promo-link {
    color: #161519;
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 28px;
    text-decoration-line: underline;
    text-decoration-style: solid;
    text-decoration-skip-ink: none;
    text-decoration-thickness: auto;
    text-underline-offset: auto;
}

.top-bar.is-marquee .top-bar-inner-centered {
    justify-content: flex-start;
}

.top-bar.is-marquee .top-bar-announcement-text {
    animation: xc-topbar-marquee var(--xc-topbar-marquee-duration, 8s) ease-in-out infinite alternate;
    will-change: transform;
}

.top-bar.is-marquee:hover .top-bar-announcement-text,
.top-bar.is-marquee:focus-within .top-bar-announcement-text {
    animation-play-state: paused;
}

@keyframes xc-topbar-marquee {
    0%,
    12% {
        transform: translateX(0);
    }

    88%,
    100% {
        transform: translateX(var(--xc-topbar-shift, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .top-bar.is-marquee .top-bar-announcement-text {
        animation: none;
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.top-promo-link:hover {
    color: var(--xc-primary);
    text-decoration-color: var(--xc-primary);
}

/* ==========================================================================
   MAIN NAVIGATION HEADER (PRIMARY RED #881111)
   ========================================================================== */
.site-header {
    background-color: var(--xc-primary);
    color: #FFFFFF;
    position: sticky;
    top: var(--xc-topbar-h, 0px);
    z-index: 99999;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
    transition: box-shadow 0.3s ease, background-color 0.3s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Cuộn xuống: header trượt lên khỏi màn hình (main.js mục 5), cuộn lên thì hiện lại.
   Chỉ gắn transform khi ẩn: transform làm menu mobile position: fixed bên trong bị lệch */
.site-header.is-hidden {
    transform: translateY(calc(-100% - var(--xc-topbar-h, 0px)));
    box-shadow: none;
}

.admin-bar .site-header.is-hidden {
    transform: translateY(calc(-100% - 32px - var(--xc-topbar-h, 0px)));
}

@media (prefers-reduced-motion: reduce) {
    .site-header {
        transition: box-shadow 0.3s ease, background-color 0.3s ease;
    }

    .top-bar {
        transition: none;
    }
}

/* Offset when WordPress admin bar is present */
.admin-bar .site-header {
    top: calc(32px + var(--xc-topbar-h, 0px));
}


.site-header.is-scrolled {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.admin-bar .site-header.is-scrolled {
    top: calc(32px + var(--xc-topbar-h, 0px));
}


.site-nav-group {
    display: flex;
    align-items: center;
    gap: 40px;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 100px;
    position: relative;
    transition: min-height 0.3s ease, padding 0.3s ease;
}

.site-header.is-scrolled .header-inner {
    min-height: 84px;
}


/* Center Navigation in desktop */
.site-header .main-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    margin: 0 24px;
}

/* ==========================================================================
   BRAND LOGO (HEADER & FOOTER)
   ========================================================================== */
.site-branding {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-logo-wrap {
    display: inline-flex;
    align-items: center;
    color: #FFFFFF;
    text-decoration: none;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
}

.brand-logo-wrap:hover {
    opacity: 0.92;
    transform: scale(1.02);
}

.brand-logo-img {
    display: block;
    object-fit: contain;
    transition: all 0.28s ease;
}

/* Header Logo: Primary Monogram (logo-primary.png) */
.brand-logo-header {
    display: inline-flex;
    align-items: center;
}

.brand-logo-header-img {
    height: 80px;
    width: auto;
    max-height: 80px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

/* Footer Logo: Full with Text (logo-full-with-text.png) */
.brand-logo-footer {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
}

.brand-logo-footer-img {
    width: 140px;
    height: auto;
    max-width: 100%;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

.brand-logo-footer:hover .brand-logo-footer-img {
    transform: translateY(-2px);
    opacity: 0.95;
}

.brand-text-footer {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-by {
    font-family: var(--font-script);
    font-size: 1.2rem;
    color: var(--xc-cta);
    font-style: italic;
}

.brand-name {
    font-family: var(--font-main);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #FFFFFF;
}

.brand-sub {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    letter-spacing: 2px;
    color: #999;
}

/* Navigation Links */
.nav-menu {
    display: flex;
    align-items: center;
    list-style: none;
    gap: 2.2rem;
}

.nav-menu>li {
    position: relative;
}

.nav-menu a {
    color: #FFF;
    font-size: 1rem;
    font-style: normal;
    font-weight: 500;
    line-height: 28px;
}

.nav-menu a:hover {
    color: var(--xc-cta);
}

.nav-arrow {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Sub-menu Dropdown (Figma Ver 2 Node 4259:5860 Open Nav) */
.nav-menu .sub-menu {
    position: absolute;
    top: 60px;
    left: 0;
    min-width: 260px;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: var(--transition);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    width: 320px;
    gap: 16px;
    padding: 40px;
    border-right: 1px solid #E0E1E0;
    border-bottom: 1px solid #E0E1E0;
    border-left: 1px solid #E0E1E0;
    background: #EFF3DD;
}

.nav-menu .menu-item-has-children:hover>.sub-menu,
.nav-menu .menu-item-has-children.is-open>.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-menu .sub-menu li a {
    display: block;
    text-decoration: none;
    transition: all 0.2s ease;
    color: #1E262B;
    font-size: 18px;
    font-style: normal;
    font-weight: 500;
    line-height: 32px;
    border-bottom: 1px solid transparent;

}

.nav-menu .sub-menu li a:hover {
    color: var(--xc-primary);
    padding-left: 4px;
}

/* ==========================================================================
   MEGA MENU DROPDOWN (Matches user reference design)
   ========================================================================== */
.site-header .header-inner {
    position: relative;
}


.nav-menu>li.has-mega-menu {
    position: static;
}

.nav-menu>li.has-mega-menu>a {
    cursor: pointer;
    user-select: none;
    transition: color 0.25s ease;
}

.nav-menu>li.has-mega-menu .mega-toggle-icon,
.nav-menu>li.has-mega-menu .nav-arrow {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s ease;
    font-size: 0.72rem;
    margin-left: 5px;
    display: inline-block;
}

.nav-menu>li.has-mega-menu:hover>a,
.nav-menu>li.has-mega-menu.is-hovered>a,
.nav-menu>li.has-mega-menu.is-open>a {
    color: var(--xc-cta);
}

.nav-menu>li.has-mega-menu:hover .mega-toggle-icon,
.nav-menu>li.has-mega-menu:hover .nav-arrow,
.nav-menu>li.has-mega-menu.is-hovered .mega-toggle-icon,
.nav-menu>li.has-mega-menu.is-hovered .nav-arrow,
.nav-menu>li.has-mega-menu.is-open .mega-toggle-icon,
.nav-menu>li.has-mega-menu.is-open .nav-arrow {
    transform: rotate(180deg);
    color: var(--xc-cta);
}

@media (min-width: 1025px) {
    .site-nav-group {
        height: 100%;
    }

    .site-header .main-navigation {
        height: 100%;
    }

    .nav-menu {
        height: 100%;
        align-items: stretch;
    }

    .nav-menu>li {
        height: 100%;
        display: inline-flex;
        align-items: center;
    }

    .nav-menu>li>a {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 12px 0;
    }
}

.xc-mega-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    display: flex;
    width: min(1440px, calc(100vw - 32px));
    padding: 40px;
    align-items: flex-start;
    gap: 40px;
    border-right: 1px solid #E0E1E0;
    border-bottom: 1px solid #E0E1E0;
    border-left: 1px solid #E0E1E0;
    background: #EFF3DD;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0.25s;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.1);
    z-index: 1050;
}

/* Invisible bridge between header bottom and mega menu dropdown to prevent hover loss */
.xc-mega-menu-dropdown::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    right: 0;
    height: 15px;
    background: transparent;
}

/* Show on hover, JS hovered state, or is-open */
.nav-menu>li.has-mega-menu:hover .xc-mega-menu-dropdown,
.nav-menu>li.has-mega-menu.is-hovered .xc-mega-menu-dropdown,
.nav-menu>li.has-mega-menu.is-open .xc-mega-menu-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.xc-mega-menu-inner {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 32px;
    align-items: start;
}

/* Sub-menu Dropdown for Về chúng tôi (Node 4259:5860 Open Nav) */
.nav-menu>li.has-dropdown {
    position: relative;
}

.xc-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 260px;
    background-color: #FFFFFF;
    border: 1px solid #EAE5D9;
    border-radius: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
    list-style: none;
    padding: 14px 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1050;
}

.nav-menu>li.has-dropdown:hover .xc-dropdown-menu,
.nav-menu>li.has-dropdown.is-open .xc-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.xc-dropdown-menu li a {
    display: block;
    padding: 10px 24px;
    font-family: var(--font-main);
    font-size: 17px;
    color: #2D2D2D !important;
    text-decoration: none;
    transition: all 0.2s ease;
}

.xc-dropdown-menu li a:hover {
    background-color: #F7F5EE;
    color: var(--xc-primary) !important;
    padding-left: 28px;
}

.xc-mega-col-photo {
    width: 100%;
}

.xc-mega-photo-link {
    display: block;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 24px;
}

.xc-mega-photo-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.xc-mega-photo-link img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    display: block;
}

a.xc-mega-view-all-link {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    margin-top: 16px;
    color: var(--primary-color, #811);
    text-align: center;
    font-size: 18px;
    font-style: normal;
    font-weight: 500;
    line-height: 32px;
    text-decoration: none;
    transition: color 0.25s ease, opacity 0.25s ease;
}

a.xc-mega-view-all-link:hover {
    color: var(--primary-color, #811);
    opacity: 0.85;
    text-decoration: underline;
}

.xc-mega-view-all-link .xc-mega-view-all-icon,
.xc-mega-view-all-link svg {
    width: 24px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.xc-mega-view-all-link:hover .xc-mega-view-all-icon,
.xc-mega-view-all-link:hover svg {
    transform: translateX(4px);
}

.xc-mega-heading {
    margin: 0 0 18px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #F0ECE1;
    color: #5F584D;
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 28px;
    border-bottom: 1px solid #C6CBAE;
}

.xc-mega-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.xc-mega-list li {
    margin-bottom: 12px;
}

.xc-mega-list li a {
    color: #1E262B;
    text-decoration: none;
    font-size: 18px;
    font-style: normal;
    font-weight: 500;
    line-height: 32px;
    display: inline-block;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

/* Đồng bộ hiệu ứng hover với link footer: đậm màu + lùi vào */
.xc-mega-list li a:hover {
    color: var(--xc-primary);
    padding-left: 4px;
}

/* ==========================================================================
   HEADER RIGHT ACTIONS: SEARCH ICON, CTA BUTTON, VN/EN SWITCHER
   ========================================================================== */
.header-right-action {
    display: flex;
    align-items: center;
    gap: 40px;
    flex-shrink: 0;
}

/* 1. Search Icon Button & Popup Dropdown */
.header-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-header-search-icon {
    background: transparent;
    border: none;
    color: #FFFFFF;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 6px 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease, color 0.2s ease;
    opacity: 0.95;
    outline: none;
}

.btn-header-search-icon:hover {
    transform: scale(1.12);
    color: #F8F5EE;
    opacity: 1;
}

.header-search-dropdown {
    position: absolute;
    top: calc(100% + 14px);
    right: -10px;
    width: 320px;
    background-color: #FFFFFF;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25);
    border: 1px solid #EAE5D9;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
    z-index: 1060;
}

.header-search-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-search-form {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.header-search-input {
    flex: 1;
    border: 1px solid #E2DDD2;
    border-radius: 6px;
    padding: 8px 14px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: #1F1D1A;
    background-color: #FAF8F5;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.header-search-input:focus {
    border-color: var(--xc-primary);
    background-color: #FFFFFF;
}

.header-search-submit {
    background-color: var(--xc-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.header-search-submit:hover {
    background-color: #6C0E10;
}

/* 2. CTA Button "Yêu cầu đặt hàng" (Golden sand pill button) */
.btn-cta-gold {
    height: 44px;
    border-radius: 8px;
    background: #D6BF89;
    display: flex;
    padding: 4px 12px;
    justify-content: center;
    align-items: center;
    gap: 8px;
    align-self: stretch;
    color: #000;
    text-align: center;
    font-size: var(--fs-body);
    font-style: normal;
    font-weight: 500;
    line-height: 28px;
}

.btn-cta-gold:hover {
    background-color: #DEC894;
    color: #000000 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.header-cta-btn {
    line-height: 1.3;
}

/* 3. Language Switcher: VN / EN */
.header-lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    user-select: none;
}

.header-lang-switcher .lang-code {
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
    padding: 2px 1px;
}

.header-lang-switcher .lang-code.is-active {
    color: #FFFFFF;
    font-weight: 700;
    opacity: 1;
}

.header-lang-switcher .lang-code:hover {
    color: #FFFFFF;
}

.header-lang-switcher .lang-slash {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
    font-size: 0.9rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 6px;
}

.mobile-menu-toggle .bar {
    width: 22px;
    height: 2px;
    background-color: #FFFFFF;
    transition: var(--transition);
}

.mobile-nav-header,
.mobile-nav-cta,
.mobile-nav-topbar-tools,
.nav-menu>li.mobile-only-menu-item {
    display: none;
}

/* Responsive Navigation for Tablets & Mobile (<= 1024px) */
@media screen and (max-width: 1024px) {
    .site-header .main-navigation {
        position: fixed;
        top: 0;
        right: -100%;
        width: 320px;
        max-width: 85vw;
        height: 100vh;
        /* dvh: trừ thanh địa chỉ trình duyệt mobile; bỏ max-height của responsive.css để menu cao đủ màn hình */
        height: 100dvh;
        max-height: none;
        background-color: #FFFFFF;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 12px 16px 30px;
        margin: 0;
        overflow-y: auto;
        transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 1100;
    }

    .site-header .main-navigation.is-open {
        right: 0;
    }

    /* Drawer menu fixed từ mép trên: hạ topbar xuống dưới header để không đè lên drawer */
    body:has(.main-navigation.is-open) .top-bar {
        z-index: 1;
    }

    .nav-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        width: 100%;
    }

    .nav-menu>li {
        width: 100%;
        border-bottom: 1px solid #F0EBE0;
    }

    .nav-menu>li>a {
        color: #1F1D1A;
        padding: 14px 0;
        width: 100%;
        justify-content: space-between;
        font-size: 1.1rem;
    }

    .nav-menu .sub-menu {
        position: static;
        box-shadow: none;
        border: none;
        padding: 0 0 10px 14px;
        background: #FBF9F5;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
    }

    .nav-menu .menu-item-has-children.is-open>.sub-menu {
        display: block;
    }

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

    /* Logo đầu menu mobile */
    .main-navigation .mobile-nav-header {
        display: flex;
        justify-content: start;
        padding-bottom: 1.25rem;
    }

    .main-navigation .mobile-nav-brand {
        display: inline-flex;
    }

    .main-navigation .mobile-nav-brand .brand-logo-header-img {
        height: 52px;
        max-height: 52px;
    }

    .nav-menu>li.mobile-only-menu-item {
        display: block;
    }

    .main-navigation .nav-menu>li.mobile-only-menu-item.current-menu-item>a {
        color: var(--xc-cta, #D6BF89);
    }

    .mobile-nav-cta {
        display: block;
        margin-top: 24px;
    }

    .mobile-nav-cta .btn-cta-gold {
        display: block;
        text-align: center;
        width: 100%;
    }

    .header-cta-btn {
        display: none;
    }
}

@media (max-width: 782px) {
    /* Admin bar WP trên mobile không cố định khi cuộn → topbar + header bám sát mép trên */
    .admin-bar .top-bar {
        top: 0;
    }

    .admin-bar .top-bar.is-hidden {
        transform: translateY(-100%);
    }

    .admin-bar .site-header,
    .admin-bar .site-header.is-scrolled {
        top: var(--xc-topbar-h, 0px);
    }

    .admin-bar .site-header.is-hidden {
        transform: translateY(calc(-100% - var(--xc-topbar-h, 0px)));
    }
}