
:root {
    --header-border-width: 2px;
}

/* ============================================================ */
/* Header base                                                  */
/* ============================================================ */

.site-header {
    position: relative;
    z-index: 50;
}

.site-header.is-sticky {
    position: sticky;
    top: 0;
}

.header-wrapper {
    border-bottom: var(--header-border-width) solid var(--primary-color);
    border-radius: 0 0 16px 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: visible;
}

.site-header.scrolled .header-wrapper {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.header-wrapper .container {
    overflow: visible;
}

/* ============================================================ */
/* Mobile menu portal (teleportado para body via JS)            */
/* ============================================================ */

.mobile-menu-portal {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
}

.mobile-menu-portal .mobile-menu-backdrop,
.mobile-menu-portal .main-navigation.active {
    pointer-events: auto;
}

.mobile-menu-portal .main-navigation:not(.active) {
    pointer-events: none;
}

.mobile-menu-portal .main-navigation {
    z-index: 61;
}

body.menu-open,
body.search-open {
    overflow: hidden;
}

/* ============================================================ */
/* Layout mobile / desktop                                      */
/* ============================================================ */

.header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.header-logo-row,
.header-desktop {
    display: none;
}

.header-nav-spacer,
.search-toggle--desktop {
    display: none;
}

/* Branding */
.site-branding {
    flex-shrink: 0;
    z-index: 10;
}

.custom-logo-link {
    display: block;
    line-height: 0;
    transition: opacity 0.2s ease;
}

.custom-logo-link:hover {
    opacity: 0.85;
}

.custom-logo {
    max-height: 36px;
    width: auto;
    transition: all var(--transition-base);
}

/* Header actions (mobile) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    z-index: 10;
}

.search-toggle,
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #737373;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.search-toggle:active,
.menu-toggle:active,
.menu-close-mobile:active {
    background: #ebebeb;
    color: #404040;
    transform: scale(0.96);
}

.search-toggle:hover,
.menu-toggle:hover {
    background: #f5f5f5;
    color: #404040;
}

.search-toggle > svg {
    flex-shrink: 0;
}

.menu-toggle .menu-toggle-icon--open {
    display: block;
}

.menu-toggle .menu-toggle-icon--close {
    display: none;
}

.menu-toggle.active .menu-toggle-icon--open {
    display: none;
}

.menu-toggle.active .menu-toggle-icon--close {
    display: block;
}

.menu-toggle {
    display: flex;
}

.search-toggle > svg {
    display: block;
}

.search-toggle--desktop {
    justify-self: end;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #525252;
    width: auto;
    min-width: 36px;
    padding: 0 0.25rem;
}

.search-toggle--desktop:hover {
    color: var(--primary-color);
}

.search-modal-loading[hidden],
.search-modal-no-results[hidden],
.search-modal-results[hidden],
.search-modal-see-all[hidden],
.search-modal-prompt.is-hidden {
    display: none !important;
}

/* ============================================================ */
/* Navegação desktop                                            */
/* ============================================================ */

.main-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.primary-menu-container {
    overflow: visible;
}

.primary-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: visible;
}

.primary-menu > li.menu-item-has-children {
    position: relative;
    overflow: visible;
}

.primary-menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0;
    color: #525252;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-decoration: none;
    background: transparent;
    border: none;
    transition: color 0.2s ease;
    position: relative;
}

.primary-menu > li > a:hover,
.primary-menu > li.current-menu-item > a,
.primary-menu > li.current_page_item > a {
    color: var(--primary-color);
    background: transparent;
    transform: none;
}

.primary-menu > li > a::before {
    display: none;
}

.primary-menu > li.menu-item-has-children > a::after {
    content: '';
    width: 14px;
    height: 14px;
    margin-left: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.2s ease;
    display: inline-block;
    font-size: 0;
}

.primary-menu > li.menu-item-has-children:hover > a::after {
    transform: rotate(180deg);
}

/* Botão da seta (toggle do submenu) — visível só no mobile via media query abaixo */
.submenu-toggle {
    display: none;
}

@media (min-width: 769px) {
    .primary-menu > li.menu-item-has-children > a::after {
        pointer-events: none;
    }
}

.menu-item-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.85;
}

.menu-item-icon svg {
    width: 100%;
    height: 100%;
}

/* Submenu dropdown */
.primary-menu .sub-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    min-width: 180px;
    max-width: 280px;
    background: #fff;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    border: 1px solid #e5e5e5;
    padding: 0.5rem 0;
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 50;
    white-space: normal;
}

.primary-menu > li.menu-item-has-children::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 16px;
    background: transparent;
    z-index: 49;
}

.primary-menu > li.menu-item-has-children:hover > .sub-menu,
.primary-menu > li.menu-item-has-children:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateX(-50%) translateY(0);
}

.primary-menu .sub-menu li {
    margin: 0;
}

.primary-menu .sub-menu a {
    display: block;
    padding: 0.625rem 1rem;
    color: #525252;
    font-size: 0.875rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    border-radius: 0;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: normal;
}

.primary-menu .sub-menu a:hover {
    background: #fafafa;
    color: var(--primary-color);
    transform: none;
}

.primary-menu .sub-menu .sub-menu {
    top: 0;
    left: 100%;
    margin-left: 0.25rem;
    transform: translateX(-6px);
}

.primary-menu .sub-menu li:hover > .sub-menu,
.primary-menu .sub-menu li:focus-within > .sub-menu {
    transform: translateX(0);
}

.drawer-header,
.drawer-search {
    display: none;
}

/* ============================================================ */
/* Overlay de busca (MonetyPressOFC)                            */
/* ============================================================ */

.search-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.search-modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.search-modal-panel {
    position: absolute;
    left: 50%;
    top: 10%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 36rem;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    z-index: 1;
}

.search-modal-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid #e5e5e5;
}

.search-modal-bar-icon {
    flex-shrink: 0;
    color: var(--primary-color);
}

.search-field {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: #171717;
    font-family: inherit;
    outline: none;
}

.search-field::placeholder {
    color: #a3a3a3;
}

.search-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #a3a3a3;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.search-modal-close:hover {
    background: #f5f5f5;
    color: #525252;
}

.search-modal-body {
    max-height: 65vh;
    overflow-y: auto;
    padding: 0.75rem;
}

.search-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 0;
    font-size: 0.875rem;
    color: #737373;
}

.search-modal-spinner {
    animation: searchSpin 0.8s linear infinite;
    color: var(--primary-color);
}

.search-modal-spinner-track {
    opacity: 0.25;
}

.search-modal-spinner-head {
    opacity: 0.75;
}

@keyframes searchSpin {
    to { transform: rotate(360deg); }
}

.search-modal-prompt,
.search-modal-no-results {
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.875rem;
    color: #737373;
    margin: 0;
}

.search-modal-results {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease;
}

.search-result-item:active {
    background: #ebebeb;
}

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-thumb {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    background: #e5e5e5;
}

.search-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.125rem;
    font-weight: 500;
    color: #a3a3a3;
}

.search-result-text {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    display: block;
    font-weight: 500;
    color: #171717;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-cat {
    display: block;
    margin-top: 0.125rem;
    font-size: 0.75rem;
    color: #737373;
}

.search-result-arrow {
    flex-shrink: 0;
    color: #a3a3a3;
}

.search-modal-see-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 0.75rem;
    padding: 0.625rem;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.search-modal-see-all:hover {
    opacity: 0.8;
}

/* ============================================================ */
/* Desktop (≥769px)                                             */
/* ============================================================ */

@media (min-width: 769px) {
    .header-mobile {
        display: none;
    }

    .header-desktop {
        display: grid;
        grid-template-columns: 36px 1fr 36px;
        grid-template-rows: auto auto;
        align-items: center;
        gap: 0 0.5rem;
    }

    /* Elementos do drawer mobile nunca aparecem no desktop */
    .drawer-header,
    .drawer-search,
    .menu-close-mobile,
    .drawer-search-btn {
        display: none !important;
    }

    .header-logo-row {
        display: flex;
        align-items: center;
        justify-content: center;
        grid-column: 1 / -1;
        grid-row: 1;
        padding: 0.75rem 0 0.375rem;
    }

    .header-logo-row .custom-logo {
        max-height: 56px;
    }

    .header-nav-spacer {
        display: block;
        grid-row: 2;
        grid-column: 1;
        width: 36px;
    }

    .header-desktop > .main-navigation {
        grid-row: 2;
        grid-column: 2;
        justify-self: center;
        padding: 0.5rem 0 0.625rem;
        border-top: 1px solid rgba(15, 23, 42, 0.06);
        width: 100%;
        position: static !important;
        transform: none !important;
        visibility: visible !important;
        height: auto !important;
        max-height: none !important;
        flex-direction: row !important;
        align-items: center !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-left: none !important;
        background: transparent !important;
        pointer-events: auto !important;
    }

    .search-toggle--desktop {
        display: flex !important;
        align-items: center;
        justify-content: center;
        grid-row: 2;
        grid-column: 3;
        justify-self: end;
        align-self: center;
        margin-top: 0.5rem;
        width: 36px;
        height: 36px;
        min-width: 36px;
        padding: 0;
    }

    .search-toggle--desktop svg {
        display: block;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

    .search-toggle--desktop:active {
        transform: none;
    }

    .menu-toggle {
        display: none;
    }

    .search-toggle:not(.search-toggle--desktop) {
        display: none !important;
    }
}

@media (min-width: 640px) {
    .search-modal-panel {
        top: 14%;
    }
}

/* ============================================================ */
/* Mobile menu backdrop + drawer                                */
/* ============================================================ */

.mobile-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    min-height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease-out, visibility 0.25s ease-out;
}

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

@media (max-width: 768px) {
    .mobile-menu-backdrop {
        display: block;
    }

    .header-wrapper {
        border-radius: 0 0 16px 16px;
    }

    /* Nav é teleportado para #mobileMenuPortal via JS */
    .header-desktop {
        display: none;
    }

    .main-navigation {
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        width: min(20rem, 85vw);
        height: 100dvh;
        height: 100vh;
        max-height: 100dvh;
        background: #fff;
        z-index: 61;
        flex-direction: column;
        align-items: stretch;
        transform: translateX(100%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.25s ease-out, visibility 0s linear 0.25s;
        overflow: hidden;
        border-left: 1px solid #e5e5e5;
        box-shadow: -25px 0 50px -12px rgba(0, 0, 0, 0.25);
    }

    .main-navigation.active {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        transition: transform 0.25s ease-out, visibility 0s linear 0s;
    }

    .drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #f5f5f5;
        flex-shrink: 0;
        background: #fff;
    }

    .drawer-logo {
        max-height: 36px;
        width: auto;
        max-width: 160px;
        object-fit: contain;
    }

    .drawer-site-name {
        font-size: 1.125rem;
        font-weight: 800;
        color: var(--primary-color);
    }

    .menu-close-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        border: none;
        border-radius: 12px;
        background: transparent;
        color: #737373;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s ease, transform 0.1s ease;
    }

    .menu-close-mobile:hover {
        background: #f5f5f5;
    }

    .primary-menu-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 0.75rem;
    }

    .primary-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0.125rem;
    }

    .primary-menu > li > a {
        display: flex;
        align-items: center;
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        font-weight: 500;
        text-transform: none;
        letter-spacing: normal;
        color: #374151;
        border-radius: 12px;
        position: relative;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .primary-menu > li > a:active {
        background: #ebebeb;
    }

    .primary-menu > li > a:hover,
    .primary-menu > li.current-menu-item > a,
    .primary-menu > li.current_page_item > a {
        background: #f5f5f5;
        color: #171717;
    }

    /* No mobile a seta do link some — usamos um botão dedicado .submenu-toggle */
    .primary-menu > li.menu-item-has-children > a::after {
        display: none !important;
    }

    .primary-menu > li.menu-item-has-children {
        position: relative;
    }

    .primary-menu > li.menu-item-has-children > a {
        padding-right: 3rem;
    }

    .primary-menu > li.menu-item-has-children > .submenu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 0.25rem;
        top: 0.25rem;
        width: 2.25rem;
        height: 2.25rem;
        padding: 0;
        border: none;
        border-radius: 10px;
        background: transparent;
        color: #525252;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s ease, transform 0.2s ease;
        z-index: 2;
    }

    .primary-menu > li.menu-item-has-children > .submenu-toggle:active {
        background: #ebebeb;
    }

    .primary-menu > li.menu-item-has-children > .submenu-toggle svg {
        width: 16px;
        height: 16px;
        transition: transform 0.2s ease;
    }

    .primary-menu > li.menu-item-has-children.menu-open > .submenu-toggle svg {
        transform: rotate(180deg);
    }

    .primary-menu .sub-menu {
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        box-shadow: none !important;
        border: none !important;
        background: transparent;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        margin: 0;
        transition: max-height 0.3s ease;
    }

    .primary-menu li.menu-open > .sub-menu {
        max-height: 800px;
        padding-left: 0.5rem;
    }

    .primary-menu .sub-menu a {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        border-radius: 12px;
    }

    .drawer-search {
        display: block;
        padding: 0.75rem;
        border-top: 1px solid #f5f5f5;
        flex-shrink: 0;
    }

    .drawer-search-btn {
        display: flex !important;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        height: auto;
        padding: 0.625rem 0.75rem;
        border: 1px solid #e5e5e5;
        border-radius: 12px;
        background: transparent;
        color: #737373;
        font-size: 0.875rem;
        cursor: pointer;
        transition: border-color 0.15s ease;
    }

    .drawer-search-btn:hover {
        border-color: var(--primary-color);
        background: transparent;
        color: #737373;
    }
}

/* ============================================================ */
/* Utilitários                                                  */
/* ============================================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.no-menu-assigned {
    padding: 1rem;
    text-align: center;
}

.no-menu-assigned p {
    color: var(--text-light);
    font-size: var(--font-sm);
    margin: 0;
}

@media (max-width: 992px) {
    .primary-menu {
        gap: 1rem;
    }
}
