/* =========================================================
   TSM Header Nav – Clean, Lovable-style (Desktop + Mobile)
   ========================================================= */

/* ---------- Base shell ---------- */
.tsm-header {
    position: sticky;
    top: 0;
    z-index: 999999;
    background: #fff;
    border-bottom: 1px solid rgba(65, 43, 77, 0.08);
    /* CRITICAL: do NOT set overflow:hidden here — that traps dropdowns */
    overflow: visible;
}

/* Kill theme blue/link styles inside the header */
.tsm-header a,
.tsm-header a:visited {
    color: rgba(65, 43, 77, 0.82);
}

.tsm-header a:hover {
    color: #412B4D;
}

/* Stop theme focus rings / weird hover fills on buttons */
.tsm-header button {
    -webkit-tap-highlight-color: transparent;
    outline: none;
    box-shadow: none;
}

.tsm-header button:focus,
.tsm-header button:focus-visible {
    outline: none;
    box-shadow: none;
}

/* ---------- Layout ---------- */
.tsm-header__inner {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 14px 32px;
    display: flex;
    align-items: center;
    gap: 18px;
    /* CRITICAL: overflow must be visible so dropdowns escape */
    overflow: visible;
}

.tsm-header__left {
    flex: 0 0 auto;
}

.tsm-header__right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.tsm-header__brand {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

/* Slightly bigger logo */
.tsm-header__logo {
    max-height: 48px;
    width: auto;
    height: auto;
    display: block;
}

/* ---------- Desktop nav ---------- */
.tsm-header__nav {
    flex: 1 1 auto;
    /* CRITICAL: overflow visible so dropdowns aren't clipped */
    overflow: visible;
}

.tsm-nav {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin: 0;
    padding: 0;
    overflow: visible;
}

.tsm-nav__item {
    position: relative;
    /* Each item is its own stacking context at a high z-index */
    z-index: 1;
}

/* Raise the active/hovered item above siblings */
.tsm-nav__item.has-dropdown:hover,
.tsm-nav__item.has-dropdown:focus-within,
.tsm-nav__item.has-dropdown.is-open {
    z-index: 999999;
}

.tsm-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    color: rgba(65, 43, 77, 0.82);
}

.tsm-nav__chev {
    font-size: 12px;
    opacity: 0.7;
}

/* Lovable pill hover/open */
.tsm-nav__item.has-dropdown:hover>.tsm-nav__link,
.tsm-nav__item.has-dropdown:focus-within>.tsm-nav__link,
.tsm-nav__item.has-dropdown.is-open>.tsm-nav__link {
    background: hsla(101, 14%, 52%, 1);
    color: #412B4D;
}

/* ---------- Dropdown (mega) ---------- */
.tsm-mega {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%) translateY(4px);
    margin-top: 6px;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
    /* z-index relative to the raised .tsm-nav__item stacking context */
    z-index: 9999;
}

/* Hover "bridge" so you can move from tab → panel */
.tsm-mega::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -12px;
    height: 12px;
}

.tsm-nav__item.has-dropdown:hover>.tsm-mega,
.tsm-nav__item.has-dropdown:focus-within>.tsm-mega,
.tsm-nav__item.has-dropdown.is-open>.tsm-mega {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.tsm-mega__panel {
    background: #fff;
    border-radius: 18px;
    border: 1px solid rgba(65, 43, 77, 0.10);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.14);
    padding: 12px 14px;
}

.tsm-mega__heading {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: rgba(65, 43, 77, 0.55);
    font-weight: 800;
    margin: 0 0 6px;
    white-space: nowrap;
}

.tsm-mega__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.tsm-mega__link,
.tsm-mega__link:visited {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.25;
    text-decoration: none;
    color: rgba(65, 43, 77, 0.82);
    white-space: nowrap;
}

.tsm-mega__link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Autosize dropdowns to content */
.tsm-mega--cols-1 {
    width: max-content;
    max-width: min(360px, 92vw);
}

.tsm-mega--cols-1 .tsm-mega__stack {
    display: grid;
    gap: 8px;
}

.tsm-mega--cols-2 {
    width: max-content;
    max-width: min(720px, 94vw);
}

.tsm-mega--cols-2 .tsm-mega__grid {
    display: grid;
    grid-template-columns: max-content max-content;
    column-gap: 24px;
}

/* ---------- Inline search (desktop) ---------- */
.tsm-search-inline {
    display: inline-flex;
    align-items: center;
    height: 40px;
    border-radius: 999px;
    border: 1px solid rgba(65, 43, 77, 0.12);
    background: #fff;
    overflow: hidden;
    width: 44px;
    transition: width 180ms ease, box-shadow 180ms ease;
}

.tsm-search-inline.is-open {
    width: 360px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.10);
}

.tsm-search-inline__btn {
    width: 44px;
    height: 40px;
    border: 0 !important;
    background: transparent !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
}

.tsm-search-inline__btn svg {
    fill: rgba(65, 43, 77, 0.75);
}

.tsm-search-inline__form {
    flex: 1 1 auto;
    display: none;
    align-items: center;
    gap: 10px;
    padding-right: 10px;
    min-width: 0;
}

.tsm-search-inline.is-open .tsm-search-inline__form {
    display: inline-flex;
}

.tsm-search-inline__input {
    width: 100%;
    height: 40px;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: rgba(65, 43, 77, 0.85);
    min-width: 0;
}

.tsm-search-inline__close {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(65, 43, 77, 0.12) !important;
    background: #fff !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: rgba(65, 43, 77, 0.70);
    box-shadow: none !important;
}

.tsm-search-inline__close:hover {
    background: rgba(65, 43, 77, 0.06) !important;
    color: #412B4D;
}

/* ---------- CTA ---------- */
.tsm-header__cta,
.tsm-drawer__cta {
    box-sizing: border-box;
    display: inline-block;
    line-height: 1;
    text-align: center;
    text-decoration: none;

    font-family: "DM Sans", Sans-serif;
    font-size: 16px;
    font-weight: 600;

    background-color: transparent;
    background-image: linear-gradient(90deg,
            var(--e-global-color-accent) 0%,
            var(--e-global-color-secondary) 100%);

    box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 14px 22px;

    color: var(--e-global-color-primary) !important;
    transition: all 0.3s;

    flex: 0 0 auto;
    white-space: nowrap;
}

.tsm-header__cta {
    margin-left: 0;
}

.tsm-drawer__cta {
    width: 100%;
}

.tsm-header__cta:hover,
.tsm-drawer__cta:hover {
    filter: brightness(1.03);
}

.tsm-header__cta:active,
.tsm-drawer__cta:active {
    transform: translateY(1px);
}

/* ---------- Burger (mobile only) ---------- */
.tsm-header__burger {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(65, 43, 77, 0.10);
    background: #fff;
    cursor: pointer;
    padding: 10px;
    box-shadow: none;
    outline: none;
}

.tsm-header__burger span {
    display: block;
    height: 2px;
    background: rgba(65, 43, 77, 0.80);
    border-radius: 2px;
}

.tsm-header__burger span+span {
    margin-top: 6px;
}

@media (min-width: 1025px) {
    .tsm-header__burger {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .tsm-header__nav {
        display: none;
    }

    .tsm-search-inline {
        display: none;
    }

    .tsm-header__cta {
        display: none !important;
    }

    .tsm-header__right {
        display: none !important;
    }

    .tsm-header__burger {
        display: inline-flex !important;
        flex-direction: column;
        justify-content: center;
        margin-left: auto;
    }
}

/* ---------- Mobile drawer ---------- */
.tsm-drawer {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, visibility 180ms ease;
}

.tsm-drawer.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tsm-drawer__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}

.tsm-drawer__panel {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 100vw;
    max-width: 100vw;
    background: #fff;
    padding: 16px 16px 20px;
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.tsm-drawer__top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 0;
    border-bottom: 0;
}

.tsm-drawer__title {
    display: none;
}

.tsm-drawer__close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(65, 43, 77, 0.10);
    background: #fff;
    cursor: pointer;
    color: #412B4D;
    box-shadow: none;
}

.tsm-drawer__content {
    padding-top: 14px;
    overflow: auto;
    height: calc(100% - 56px);
    display: flex;
    flex-direction: column;
}

.tsm-drawer__cta {
    order: 1;
    margin: 0 0 14px;
}

.tsm-drawer__search {
    order: 2;
    display: flex;
    gap: 12px;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(65, 43, 77, 0.10);
    margin-bottom: 14px;
}

.tsm-drawer__search-input {
    flex: 1 1 auto;
    height: 44px;
    border-radius: 14px;
    border: 1px solid rgba(65, 43, 77, 0.16);
    padding: 0 14px;
    outline: none;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 1.2;
}

.tsm-drawer__search-input::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tsm-drawer__search-btn {
    height: 44px;
    border-radius: 14px;
    border: 0 !important;
    background: #412B4D !important;
    color: #fff !important;
    padding: 0 14px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: none !important;
}

.tsm-drawer .tsm-drawer__search-btn:hover,
.tsm-drawer .tsm-drawer__search-btn:focus,
.tsm-drawer .tsm-drawer__search-btn:focus-visible,
.tsm-drawer .tsm-drawer__search-btn:active {
    background: #412B4D !important;
    color: #fff !important;
    box-shadow: none !important;
    outline: none !important;
    filter: brightness(0.96);
}

.tsm-mnav {
    order: 3;
    list-style: none;
    padding: 0;
    margin: 0;
}

.tsm-mnav__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(65, 43, 77, 0.08);
    cursor: pointer;
}

.tsm-mnav__link {
    text-decoration: none;
    color: rgba(65, 43, 77, 0.88) !important;
    font-weight: 700;
    font-size: 16px;
    padding: 0;
}

.tsm-mnav__toggle {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: rgba(65, 43, 77, 0.60);
}

.tsm-mnav__toggle:hover {
    background: rgba(65, 43, 77, 0.06);
    color: #412B4D;
}

.tsm-mnav__sub {
    display: none;
    padding: 10px 0 14px;
    border-bottom: 1px solid rgba(65, 43, 77, 0.08);
}

.tsm-mnav__item.is-open>.tsm-mnav__sub {
    display: block;
}

.tsm-mnav__heading {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: rgba(65, 43, 77, 0.55);
    font-weight: 800;
    margin: 10px 0 8px;
}

.tsm-mnav__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.tsm-mnav__sublink {
    text-decoration: none;
    color: rgba(65, 43, 77, 0.85) !important;
    font-weight: 700;
    font-size: 13px;
    padding: 6px 0;
    display: inline-block;
}

/* Push sticky header down when WP admin bar is showing */
.admin-bar .tsm-header {
    top: 32px;
}

@media screen and (max-width: 782px) {

    /* Admin bar is 46px tall on mobile */
    .admin-bar .tsm-header {
        top: 46px;
    }
}

/* Let WP admin bar dropdowns appear above the header */
.admin-bar .tsm-header {
    z-index: 99998;
}