/* =============================================================================
   MERLOWS — Site navigation + brand logo
   Loads after main.css and app-mobile.css.
   Desktop (>1024px): lockup logo, dropdowns, Topics mega panel.
   Mobile/tablet (<=1024px): compact logo, Menu + Search buttons in the app
   bar, full menu in the #mlws-sheet-menu bottom sheet.
   ========================================================================== */

:root {
    --brand-navy: #0B2D63;
    --brand-crimson: #8B1A2B;
    --brand-gold: #C9A04A;
}

.logo-area picture { display: flex; align-items: center; }

/* ---------------------------------------------------------------- DESKTOP */
@media (min-width: 1025px) {
    :root { --header-height: 88px; }

    .site-header .logo-area img {
        height: 44px;
        width: auto;
        max-width: none;
    }

    .mlws-hdr-btn { display: none; }

    /* Keep the bar to one row: socials live in the footer and menu sheet. */
    .header-actions .header-social-links { display: none !important; }

    .main-nav > .mlws-nav { gap: 2px; }

    /* Dropdown triggers are buttons (they open a panel, not a page) but look
       like the neighbouring links. */
    .mlws-nav > li > .mlws-nav-trigger {
        display: flex;
        align-items: center;
        gap: 6px;
        height: 100%;
        padding: 0 14px;
        border: 0;
        background: none;
        font: inherit;
        font-size: 14px;
        font-weight: 600;
        color: var(--primary-color);
        cursor: pointer;
        border-radius: var(--radius-sm);
        white-space: nowrap;
        transition: color 0.2s, background 0.2s;
    }
    .mlws-nav > li > .mlws-nav-trigger::after {
        content: '';
        width: 5px;
        height: 5px;
        border-right: 1.5px solid currentColor;
        border-bottom: 1.5px solid currentColor;
        transform: rotate(45deg);
        margin-top: -2px;
        transition: transform 0.2s;
    }
    .mlws-nav > li > .mlws-nav-trigger:hover,
    .mlws-nav > li.is-open > .mlws-nav-trigger { background: #F5E6A3; }
    .mlws-nav > li.is-open > .mlws-nav-trigger::after,
    .mlws-nav > li:hover > .mlws-nav-trigger::after { transform: rotate(-135deg); margin-top: 2px; }

    .mlws-nav > li > a[aria-current="page"],
    .mlws-nav > li.current-menu-ancestor > .mlws-nav-trigger {
        box-shadow: inset 0 -3px 0 var(--brand-gold);
        border-radius: 0;
    }

    /* Open on hover (from main.css) or click / Enter (.is-open, site-nav.js). */
    .main-nav .mlws-nav > li.is-open > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }
    /* A click-closed panel stays shut even while hovered. */
    .main-nav .mlws-nav > li.is-closed > .sub-menu {
        opacity: 0;
        visibility: hidden;
    }

    /* ---- Topics mega panel ---------------------------------------------- */
    .main-nav .mlws-nav > li.mlws-has-mega { position: static; }
    .main-nav .mlws-mega {
        left: 50%;
        top: calc(100% - 1px);
        width: min(1100px, calc(100vw - 48px));
        padding: 28px 32px;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        border-top: 3px solid var(--brand-gold);
    }
    .mlws-mega__grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
        gap: 24px 32px;
    }
    .mlws-mega__head {
        display: block;
        margin-bottom: 10px;
        padding-bottom: 8px;
        border-bottom: 1px solid #E2E8F0;
        font-family: var(--font-heading);
        font-size: 15px;
        font-weight: 700;
        color: var(--brand-navy);
        text-decoration: none;
    }
    a.mlws-mega__head:hover { color: var(--brand-crimson); }
    .mlws-mega__col ul { list-style: none; margin: 0; padding: 0; }
    /* main.css styles every `.sub-menu li a` with !important; the mega panel
       needs a lighter list, so match that weight with higher specificity. */
    .main-nav .mlws-mega .mlws-mega__col li a {
        display: block !important;
        padding: 6px 8px !important;
        margin: 0 -8px;
        font-size: 14px !important;
        color: var(--text-main) !important;
        transition: color 0.15s, background 0.15s !important;
    }
    .main-nav .mlws-mega .mlws-mega__col li a:hover,
    .main-nav .mlws-mega .mlws-mega__col a[aria-current="page"] {
        color: var(--brand-crimson) !important;
        background: #FBF5E4 !important;
        padding-left: 8px !important;
    }

    .mlws-nav a:focus-visible,
    .mlws-nav-trigger:focus-visible {
        outline: 2px solid var(--brand-gold);
        outline-offset: 2px;
    }
}

@media (min-width: 1025px) and (max-width: 1200px) {
    .site-header .logo-area img { height: 38px; }
    .mlws-nav > li > a,
    .mlws-nav > li > .mlws-nav-trigger { padding: 0 9px !important; font-size: 13px !important; }
}

/* ----------------------------------------------------------- MOBILE/TABLET */
@media (max-width: 1024px) {
    .mlws-hdr-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 0;
        border-radius: 12px;
        background: none;
        color: var(--brand-navy);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .mlws-hdr-btn svg { width: 24px; height: 24px; }
    .mlws-hdr-btn:active { background: rgba(11, 45, 99, 0.08); }
    .mlws-hdr-btn:focus-visible { outline: 2px solid var(--brand-gold); outline-offset: 1px; }
    .mlws-hdr-btn--menu { left: 6px; }
    .mlws-hdr-btn--search { right: 6px; }

    /* ---- Menu sheet ----------------------------------------------------- */
    .mlws-mnav { list-style: none; margin: 0 0 8px; padding: 0; }
    .mlws-mnav > li { border-bottom: 1px solid rgba(15, 23, 42, 0.07); }
    .mlws-mnav--flat > li:last-child { border-bottom: 0; }

    .mlws-mnav__link,
    .mlws-mnav__group > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 52px;
        padding: 0 4px;
        font-family: var(--font-heading);
        font-size: 17px;
        font-weight: 600;
        color: var(--brand-navy);
        text-decoration: none;
        cursor: pointer;
        list-style: none;
        -webkit-tap-highlight-color: transparent;
    }
    .mlws-mnav__group > summary::-webkit-details-marker { display: none; }
    .mlws-mnav__group > summary::after {
        content: '';
        width: 8px;
        height: 8px;
        margin-right: 6px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg) translateY(-3px);
        transition: transform 0.2s;
    }
    .mlws-mnav__group[open] > summary::after { transform: rotate(-135deg) translateY(-3px); }
    .mlws-mnav__group[open] > summary { color: var(--brand-crimson); }

    .mlws-mnav__group > ul {
        list-style: none;
        margin: 0 0 10px;
        padding: 0 0 0 12px;
        border-left: 2px solid var(--brand-gold);
    }
    .mlws-mnav__sub {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 0 8px;
        font-size: 15px;
        color: var(--text-main);
        text-decoration: none;
    }
    .mlws-mnav__sub--head { font-weight: 700; color: var(--brand-navy); }
    .mlws-mnav__sub--deep { padding-left: 22px; font-size: 14px; color: #475569; min-height: 40px; }
    .mlws-mnav__label {
        padding: 12px 8px 4px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #475569;
    }
    .mlws-mnav a[aria-current="page"] { color: var(--brand-crimson); font-weight: 700; }
    .mlws-mnav a:active { background: #EEF4FB; }

    .mlws-mnav-legal {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 20px;
        list-style: none;
        margin: 8px 0 0;
        padding: 12px 4px 0;
        border-top: 1px solid rgba(15, 23, 42, 0.07);
    }
    .mlws-mnav-legal a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        font-size: 14px;
        color: #475569;
        text-decoration: none;
    }

    /* The menu is long: give it the full available height. */
    .mlws-sheet--menu { max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
    .mlws-nav-trigger::after,
    .mlws-mnav__group > summary::after { transition: none; }
}
