/* ========================================
 * 0. Font Import
 * ======================================== */
@import 'https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;600;700&display=swap';

/* ========================================
 * 1. Base / Wrapper
 * ======================================== */

.hafo-header-wrapper {
    width: 100%;
    position: relative;
    background-color: var(--hafo-color-brand-white);
    font-family: var(--hafo-font-family);
    color: var(--hafo-color-black);
}

.hafo-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
 * 2. Top Bar
 * ======================================== */

.hafo-top-bar {
    background-color: var(--hafo-color-brand);
    color: var(--hafo-color-brand-white);
    padding: 8px 0;
    font-size: 14px;
    font-weight: 300;
    line-height: 1.5;
}

.hafo-top-bar .hafo-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.top-bar-left,
.top-bar-center,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.top-bar-center {
    flex-grow: 1;
    justify-content: center;
}

.top-bar-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.top-bar-item i,
.top-bar-item svg {
    color: var(--hafo-color-green);
}

/* Mobile Top Bar: Marquee animation */
@media (width <= 767px) {
    .hafo-top-bar {
        overflow: hidden;
        position: relative;
    }

    .hafo-top-bar .hafo-container {
        display: block;
        white-space: nowrap;
        animation: marquee 15s linear infinite;
        padding-left: 100%;
    }

    .top-bar-left,
    .top-bar-center,
    .top-bar-right {
        display: inline-block;
        padding: 0 2rem;
    }

    .top-bar-center,
    .top-bar-right {
        display: inline-block !important;
    }
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* ========================================
 * 3. Main Header (Logo, Actions)
 * ======================================== */

.hafo-main-header {
    padding: 24px 0;
    background-color: var(--hafo-color-white);
    border-bottom: 1px solid var(--hafo-color-neutral-200);
}

.header-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 32px;
}

/* Fallback: without search bar keep original layout */
.header-grid:not(.header-grid--with-search) {
    grid-template-columns: 1fr auto;
}

/* Logo */
.header-logo .site-title,
.header-logo .custom-logo-link {
    display: block;
    max-width: 200px;
}

.header-logo img {
    height: 100%;
    object-fit: cover;
}

/* Actions (Cart, Menu) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Mobile Toggle in Header (Figma: circular with navy border) */
.mobile-menu-toggle {
    display: none;
    background: var(--hafo-color-pale-blue);
    border: 1px solid var(--hafo-color-brand);
    border-radius: 100px;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 18px;
    color: var(--hafo-color-brand);
    position: relative;
    overflow: hidden;
}

.mobile-menu-toggle:hover {
    background-color: #e8eef5;
    transform: scale(1.05);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.mobile-menu-toggle[aria-expanded="true"] {
    background-color: var(--hafo-color-brand);
    color: var(--hafo-color-brand-white);
}

.mobile-menu-toggle[aria-expanded="true"]:hover {
    background-color: var(--hafo-color-brand);
    transform: rotate(90deg) scale(1.05);
}

.mobile-menu-toggle i {
    display: none;
    color: currentcolor;
}

/* Hamburger icon - animated lines */
.mobile-menu-toggle .hamburger-icon {
    width: 24px;
    height: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu-toggle .hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: currentcolor;
    border-radius: 2px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon {
    transform: rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
    transform: rotate(90deg);
    transform-origin: center;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
    transform: rotate(0deg);
    transform-origin: center;
}

.hafo-cart-sidebar-toggle {
    background: var(--accordion-bg-hover);
    border: 1px solid var(--hafo-color-black);
    border-radius: 50%;
    width: 52px;
    height: 52px;
    cursor: pointer;
    position: relative;
    color: var(--hafo-color-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.hafo-cart-sidebar-toggle:hover {
    background-color: var(--accordion-bg-hover);
}

.cart-icon-wrapper {
    position: relative;
    display: flex;
}

.hafo-cart-sidebar-toggle__count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--hafo-color-green);
    color: var(--hafo-color-brand-white);
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--hafo-color-brand-white);
}

/* ========================================
 * Header Search Bar
 * ======================================== */

.header-search {
    width: 100%;
    max-width: 560px;
    justify-self: center;
}

/* FiboSearch override: make it match Hafo pill style */
.header-search .dgwt-wcas-search-wrapp,
.header-search .hafo-search-wrap {
    position: relative;
    width: 100%;
}

/* Shared input styles for both FiboSearch and fallback */
.header-search .dgwt-wcas-search-wrapp input[type="search"],
.header-search .dgwt-wcas-sf-wrapp input[type="search"],
.header-search .hafo-search-input {
    width: 100%;
    height: 52px;
    padding: 0 52px 0 24px;
    border: 1px solid var(--hafo-color-neutral-300);
    border-radius: var(--hafo-radius-full);
    background-color: var(--hafo-color-neutral-100);
    font-family: var(--hafo-font-family);
    font-size: var(--hafo-font-size-sm);
    font-weight: var(--hafo-font-weight-normal);
    color: var(--hafo-color-text-primary);
    outline: none;
    transition: border-color var(--hafo-transition-fast), background-color var(--hafo-transition-fast), box-shadow var(--hafo-transition-fast);
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.header-search .dgwt-wcas-search-wrapp input[type="search"]::placeholder,
.header-search .dgwt-wcas-sf-wrapp input[type="search"]::placeholder,
.header-search .hafo-search-input::placeholder {
    color: var(--hafo-color-text-secondary);
    font-weight: var(--hafo-font-weight-normal);
}

.header-search .dgwt-wcas-search-wrapp input[type="search"]:focus,
.header-search .dgwt-wcas-sf-wrapp input[type="search"]:focus,
.header-search .hafo-search-input:focus {
    border-color: var(--hafo-color-brand);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgb(30 49 94 / 8%);
}

/* FiboSearch: hide its own submit button & reposition search icon */
.header-search .dgwt-wcas-search-submit {
    display: none !important;
}

.header-search .dgwt-wcas-ico-magnifier-handler,
.header-search .dgwt-wcas-ico-magnifier {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--hafo-color-text-secondary);
    width: 18px;
    height: 18px;
}

/* Fallback search button (when FiboSearch is not active) */
.hafo-search-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--hafo-color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--hafo-transition-fast);
    line-height: 1;
}

.hafo-search-btn:hover {
    color: var(--hafo-color-brand);
}

/* Mobile Header layout */
@media (width <= 1024px) {
    .hafo-main-header {
        padding: .5rem 1rem;
    }

    .header-grid,
    .header-grid.header-grid--with-search {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 0;
    }

    .header-logo {
        order: 1;
        flex: 1;
    }

    .header-logo .custom-logo-link {
        max-width: 165px;
    }

    .header-search {
        order: 3;
        max-width: 100%;
        flex: 0 0 100%;
        padding-bottom: 8px;
    }

    .header-actions {
        order: 2;
        gap: 16px;
    }

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

}

/* ========================================
 * Mobile Search (full-width below header)
 * ======================================== */

.hafo-mobile-nav-search {
    display: none;
    width: 100%;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--hafo-color-neutral-200);
    background: var(--hafo-color-white);
}

/* Ensure FiboSearch stretches full width */
.hafo-mobile-nav-search .dgwt-wcas-search-wrapp,
.hafo-mobile-nav-search .dgwt-wcas-search-form {
    width: 100%;
    max-width: 100%;
}

.hafo-mobile-nav-search .dgwt-wcas-search-wrapp input[type="search"],
.hafo-mobile-nav-search .dgwt-wcas-sf-wrapp input[type="search"] {
    width: 100%;
}

@media (width <= 1024px) {
    .hafo-mobile-nav-search {
        display: block !important;
    }
}

/* ========================================
 * 4. Navigation Bar
 * ======================================== */

.hafo-nav-bar {
    border-bottom: 1px solid var(--hafo-color-neutral-200);
    background: var(--hafo-color-brand-white);
}

.nav-bar-inner {
    display: flex;
    align-items: center;
    height: 60px;
    justify-content: space-between;
}

.nav-left,
.nav-right {
    flex-shrink: 0;
}

.nav-right {
    display: flex;
    justify-content: flex-end;
}

.nav-center {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

/* Primary Menu (Walker Output) */
.primary-menu {
    display: flex;
    gap: 48px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.primary-menu>.menu-item>a {
    text-decoration: none;
    color: var(--hafo-color-black);
    font-weight: 400;
    font-size: 18px;
    font-family: var(--hafo-font-family);
    padding: 8px 0;
    display: flex;
    gap: 1rem;
    position: relative;
    transition: color 0.2s ease;
}

.primary-menu>.menu-item>a:hover {
    color: var(--hafo-color-brand) !important;
}

/* Simple Dropdown Styles */
.sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--hafo-color-brand-white);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 10%);
    min-width: 220px;
    z-index: 50;
    border: 1px solid var(--hafo-color-neutral-200);
    border-radius: 8px;
    padding: 8px 0;
    flex-direction: column;
    gap: 0;
}

.menu-item {
    position: relative;
}

.menu-item:hover>.sub-menu {
    display: flex;
}

.sub-menu .menu-item>a {
    padding: 8px 16px;
    display: block;
    color: var(--hafo-color-black);
    text-decoration: none;
    font-size: 14px;
    font-family: var(--hafo-font-family);
    transition: background 0.2s;
}

.sub-menu .menu-item>a:hover {
    background-color: var(--hafo-color-neutral-50);
    color: var(--hafo-color-brand);
}

/* Language Switcher - Pill Style */
.language-switcher {
    background: var(--hafo-color-brand-white);
    border: 1px solid var(--hafo-color-neutral-200);
    padding: 8px 16px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 400;
    font-family: var(--hafo-font-family);
    color: var(--hafo-color-black);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.language-switcher:hover {
    border-color: var(--hafo-color-brand);
    color: var(--hafo-color-brand);
}

/* Mobile Nav: Hide entire nav bar */
@media (width <= 1024px) {
    .hafo-nav-bar {
        display: none;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }
}

/* ========================================
 * 5. Announcement Bar
 * ======================================== */

.announcement-bar {
    background-color: var(--hafo-color-cool-grey);
    color: var(--hafo-color-black);
    padding: 10px 0;
    font-size: 14px;
    font-family: var(--hafo-font-family);
    font-weight: 300;
    position: relative;
    transition: height 0.3s ease, opacity 0.3s ease;
}

.announcement-bar .hafo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.announcement-content {
    text-align: center;
}

.announcement-content__track {
    display: block;
}

.announcement-content__item[aria-hidden="true"] {
    display: none;
}

.announcement-content strong {
    font-weight: 700;
}

.announcement-close {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: currentcolor;
    cursor: pointer;
    opacity: 0.6;
    padding: 4px;
    font-size: 14px;
}

.announcement-close:hover {
    opacity: 1;
}

/* Mobile: Adjust announcement text */
@media (width <= 767px) {
    .announcement-bar {
        font-size: 13px;
    }

    .announcement-bar .hafo-container {
        justify-content: flex-start;
        overflow: hidden;
        padding-right: 48px;
    }

    .announcement-content {
        flex: 1;
        overflow: hidden;
        text-align: left;
        white-space: nowrap;
    }

    .announcement-content__track {
        align-items: center;
        animation: hafo-announcement-marquee 18s linear infinite;
        display: inline-flex;
        min-width: max-content;
        will-change: transform;
    }

    .announcement-content__item {
        display: inline-flex;
        flex-shrink: 0;
        padding-right: var(--hafo-space-8);
    }

    .announcement-content__item[aria-hidden="true"] {
        display: inline-flex;
    }
}

@media (prefers-reduced-motion: reduce) {
    .announcement-content__track {
        animation: none;
    }
}

@keyframes hafo-announcement-marquee {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}
