/**
 * Header v2 — restyles the existing header (header.php) to match the
 * AML-Global streamline design (site-source: .site-header, nav,
 * .services-dropdown, .nav-cta, .mobile-menu-toggle).
 *
 * Styling only: markup, menus and links are unchanged. Loaded after
 * custom.css, so selectors are scoped to #masthead to win the cascade.
 */

/* The phone menu panel (.mobile-menu) and its backdrop sit outside #masthead, so they get the tokens too. */
#masthead,
.mobile-menu,
.als-mobile-nav-backdrop {
    --als-header-red: #d83933;
    --als-header-blue: #1672c8;
    --als-header-action: #0b5ea8;
    --als-header-navy: #0b2b49;
    --als-header-ink: #172534;
    --als-header-line: #dce7ef;
}

/* Bar */
header#masthead.site-header,
.home header#masthead.site-header,
.is-sticky header#masthead.site-header,
.home .is-sticky header#masthead.site-header {
    /* Same side padding as the black top bar (.black-topbar .container), so both line up. */
    padding: 0 1.5rem;
    border-top: 0;
    border-bottom: 1px solid #e7edf2;
    background: #fff;
    box-shadow: none;
    font-family: Arial, Helvetica, sans-serif;
}

.is-sticky header#masthead.site-header {
    box-shadow: 0 6px 18px rgba(11, 43, 73, 0.08);
}

#masthead > .container-fluid {
    padding: 0;
}

#masthead > .container-fluid > .row {
    min-height: 86px;
}

/* Logo */
#masthead .site-logo {
    text-align: left;
}

/* Same size as the reference logo (site-source: .brand, 290 × 65). */
#masthead .site-logo img {
    width: 290px !important;
    max-width: 100%;
    height: auto;
    max-height: none !important;
    /* layout.css pushes the logo in with a per-screen-width margin-left; cancel it. */
    margin-left: 0;
}

/* Hide the flag + "Established in 1985" column (its language switcher is already hidden in custom.css). */
#masthead .row > .left-logo {
    display: none !important;
}

/* Hidden for now to match the reference navigation: "Free Quote" menu item and "Quick Quote" button. */
#masthead .main-navigation ul.primary-menu > li.free-quote,
#masthead .quick-quote-btn {
    display: none !important;
}

/* Quick Quote button (site-source: .nav-cta) */
#masthead .quick-quote-btn a,
#masthead .quick-quote-btn a:visited {
    padding: 11px 20px;
    border: 2px solid var(--als-header-red);
    border-radius: 999px;
    background: var(--als-header-action);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

#masthead .quick-quote-btn a:hover,
#masthead .quick-quote-btn a:focus {
    background: var(--als-header-navy);
    color: #fff;
}

/* Mobile menu toggle (site-source: .mobile-menu-toggle) */
#masthead .side-menu {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    width: 46px;
    height: 44px;
    padding: 0 12px;
    border: 1px solid #cbd9e3;
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
}

#masthead .side-menu span {
    height: 2px;
    margin: 3px 0;
    padding: 0;
    border-radius: 2px;
    background: var(--als-header-navy);
}

#masthead .side-menu:hover {
    border-color: var(--als-header-blue);
    box-shadow: 0 0 0 2px rgba(22, 114, 200, 0.12);
}

/* Desktop / tablet layout: logo left, menu and actions right. */
@media (min-width: 768px) {
    #masthead > .container-fluid > .row {
        flex-wrap: nowrap;
        gap: 18px;
    }

    #masthead .row > .col-6.col-md-5 {
        order: 1;
        flex: 0 0 auto;
        max-width: none;
        width: auto;
    }

    #masthead .row > .col-md-5.d-md-block {
        order: 2;
        flex: 1 1 auto;
        max-width: none;
        width: auto;
    }

    #masthead .row > .col-3.col-md-1 {
        order: 3;
        flex: 0 0 auto;
        max-width: none;
        width: auto;
    }

    /* Top-level menu (site-source: nav) */
    #masthead .main-navigation ul.primary-menu {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: nowrap;
        min-height: 86px;
    }

    #masthead .main-navigation ul.primary-menu > li > a,
    .home #masthead .main-navigation ul.primary-menu > li > a {
        padding: 33px 15px;
        color: var(--als-header-ink);
        font-size: 13px;
        font-weight: 700;
        line-height: 20px;
        letter-spacing: normal;
        text-transform: none;
        white-space: nowrap;
    }

    #masthead .main-navigation ul.primary-menu > li:hover > a,
    #masthead .main-navigation ul.primary-menu > li.current-menu-item > a,
    #masthead .main-navigation ul.primary-menu > li.current-menu-ancestor > a {
        color: var(--als-header-blue);
    }

    /* Dropdown arrow (site-source: .services-menu > button::after) */
    #masthead .main-navigation ul.primary-menu > li.menu-item-has-children > a::after,
    .home #masthead .main-navigation ul.primary-menu > li.menu-item-has-children > a::after {
        content: "\25BE";
        position: static;
        display: inline;
        width: auto;
        margin-left: 6px;
        border: 0;
        opacity: 1;
        color: var(--als-header-blue);
    }

    /* Parent items without a link (Services, Resources) open their dropdown on hover. */
    #masthead .main-navigation ul.primary-menu > li > a:not([href]) {
        cursor: default;
    }

    /* "Free Quote" menu item as a pill (site-source: .nav-cta) */
    #masthead .main-navigation ul.primary-menu > li.free-quote {
        margin: 0 6px;
    }

    #masthead .main-navigation ul.primary-menu > li.free-quote > a,
    .home #masthead .main-navigation ul.primary-menu > li.free-quote > a {
        padding: 11px 20px !important;
        border: 2px solid var(--als-header-red);
        border-radius: 999px;
        background: var(--als-header-action);
        color: #fff !important;
        cursor: pointer;
    }

    #masthead .main-navigation ul.primary-menu > li.free-quote:hover > a {
        background: var(--als-header-navy);
    }

    #masthead .main-navigation ul.primary-menu > li.free-quote > a::after {
        color: #fff;
    }

    /* Dropdown panel (site-source: .services-dropdown) */
    #masthead .main-navigation ul ul {
        min-width: 245px;
        margin: 0 !important;
        padding: 8px;
        border: 1px solid var(--als-header-line);
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 16px 36px rgba(11, 43, 73, 0.18);
    }

    #masthead .main-navigation ul ul ul {
        top: -9px;
        left: calc(100% + 8px);
    }

    #masthead .main-navigation ul ul li,
    #masthead .main-navigation ul ul li:hover {
        border: 0;
        background: transparent;
    }

    #masthead .main-navigation ul ul li a,
    #masthead .main-navigation ul ul ul li a,
    #masthead .main-navigation ul.primary-menu > li:hover ul li a {
        padding: 11px 12px;
        border: 0 !important;
        border-radius: 7px;
        background: transparent !important;
        color: var(--als-header-navy) !important;
        font-size: 13px;
        font-weight: 700;
        line-height: 1.2;
        text-transform: none;
        letter-spacing: normal;
        white-space: normal;
        transition: background-color 0.15s ease, color 0.15s ease;
    }

    #masthead .main-navigation ul ul li:hover > a,
    #masthead .main-navigation ul ul li > a:focus,
    #masthead .main-navigation ul ul li.current-menu-item > a {
        background: #edf7fe !important;
        color: var(--als-header-blue) !important;
    }
}

/* Narrower desktops: tighter menu so everything stays on one line. */
@media (min-width: 768px) and (max-width: 1199px) {
    #masthead .site-logo img {
        width: 230px !important;
    }

    #masthead .main-navigation ul.primary-menu > li > a,
    .home #masthead .main-navigation ul.primary-menu > li > a {
        padding-right: 8px;
        padding-left: 8px;
        font-size: 12px;
    }

    #masthead .main-navigation ul.primary-menu > li.free-quote > a,
    .home #masthead .main-navigation ul.primary-menu > li.free-quote > a,
    #masthead .quick-quote-btn a {
        padding: 9px 14px !important;
        font-size: 12px;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    #masthead > .container-fluid > .row {
        gap: 10px;
    }

    #masthead .site-logo img {
        width: 170px !important;
    }

    #masthead .main-navigation ul.primary-menu > li > a,
    .home #masthead .main-navigation ul.primary-menu > li > a {
        padding-right: 5px;
        padding-left: 5px;
        font-size: 11px;
    }
}

/* Phone */
@media (max-width: 767px) {
    header#masthead.site-header,
    .home header#masthead.site-header {
        padding: 12px 1.5rem;
    }

    #masthead > .container-fluid > .row {
        min-height: 0;
    }
}

/* Small phones (site-source: .brand at <= 560px). */
@media (max-width: 560px) {
    #masthead .site-logo img {
        width: 218px !important;
    }
}

/*
 * Phone navigation (site-source: .mobile-menu-toggle, .primary-nav-shell nav,
 * .services-dropdown). Restyles the slicknav menu built by custom.js: a "☰ Menu" /
 * "× Close" button, a panel under the header on the right, a dimmed backdrop and
 * light-blue dropdowns. Open state: body.als-mobile-nav-open (set in custom.js).
 */
.als-mobile-nav-backdrop {
    display: none;
}

@media (max-width: 767px) {
    /* Logo takes the free space, the Menu button keeps its own width (no overlap). */
    header#masthead.site-header,
    .home header#masthead.site-header {
        padding-right: 16px;
        padding-left: 16px;
    }

    #masthead > .container-fluid > .row {
        flex-wrap: nowrap;
        gap: 12px;
    }

    #masthead .row > .col-6.col-md-5 {
        flex: 1 1 auto;
        width: auto;
        max-width: none;
        min-width: 0;
        padding: 0;
    }

    #masthead .row > .col-3.col-md-1 {
        display: none;
    }

    /* Toggle button */
    #masthead .row > .d-md-none {
        display: flex !important;
        flex: 0 0 auto;
        justify-content: flex-end;
        width: auto;
        max-width: none;
        padding: 0;
    }

    #masthead .side-menu {
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 7px;
        width: auto;
        min-width: 82px;
        height: auto;
        min-height: 44px;
        margin: 0;
        padding: 9px 13px;
        float: none;
        border: 1px solid #cbd9e3;
        border-radius: 9px;
        background: #fff;
        color: var(--als-header-navy);
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        font-weight: 900;
        line-height: 1;
        cursor: pointer;
    }

    #masthead .side-menu span {
        display: inline;
        width: auto;
        height: auto;
        margin: 0;
        padding: 0;
        border-radius: 0;
        background: none;
        color: inherit;
    }

    #masthead .side-menu .side-menu__icon {
        font-size: 20px;
        line-height: 1;
    }

    #masthead .side-menu:focus-visible {
        outline: 2px solid var(--als-header-blue);
        outline-offset: 2px;
    }

    body.als-mobile-nav-open #masthead .side-menu {
        border-color: var(--als-header-blue);
        color: var(--als-header-blue);
        box-shadow: 0 0 0 2px rgba(22, 114, 200, 0.12);
    }

    /* The slicknav wrapper takes no space; only its panel is shown. */
    .mobile-menu {
        height: 0;
        box-shadow: none;
        z-index: 10002 !important;
    }

    /* Backdrop below the header */
    body.als-mobile-nav-open .als-mobile-nav-backdrop {
        position: fixed;
        display: block;
        inset: var(--als-mobile-nav-top, 74px) 0 0;
        z-index: 10001;
        width: 100%;
        padding: 0;
        border: 0;
        background: rgba(4, 25, 42, 0.48);
        cursor: default;
    }

    /* Panel */
    .mobile-menu .slicknav_menu ul.slicknav_nav {
        position: fixed;
        top: var(--als-mobile-nav-top, 74px);
        right: 0;
        z-index: 10002;
        width: min(390px, 100vw);
        max-height: calc(100dvh - var(--als-mobile-nav-top, 74px));
        margin: 0;
        padding: 12px 16px calc(22px + env(safe-area-inset-bottom)) !important;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-top: 1px solid var(--als-header-line, #dce7ef);
        background: #fff;
        box-shadow: 0 20px 40px rgba(4, 25, 42, 0.24);
        box-sizing: border-box;
        font-family: Arial, Helvetica, sans-serif;
    }

    .mobile-menu .slicknav_nav li {
        margin: 0;
        border-bottom: 1px solid #e7edf2;
    }

    /* Top-level rows */
    .mobile-menu .slicknav_nav > li > a,
    .mobile-menu .slicknav_nav > li > a.slicknav_row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 48px;
        margin: 0;
        padding: 14px 10px;
        color: var(--als-header-navy);
        font-size: 15px;
        font-weight: 700;
        line-height: 1.25;
        text-transform: none;
        text-decoration: none;
    }

    .mobile-menu .slicknav_nav > li > a.slicknav_row > a {
        flex: 1 1 auto;
        padding: 0;
        margin: 0;
        color: inherit;
        font: inherit;
        text-transform: none;
    }

    .mobile-menu .slicknav_nav > li.current-menu-item > a,
    .mobile-menu .slicknav_nav > li > a:hover {
        color: var(--als-header-blue);
    }

    /* Dropdown arrow (site-source: .services-menu > button::after) */
    .mobile-menu .slicknav_nav li.slicknav_parent > a.slicknav_row > span.slicknav_arrow {
        position: static;
        flex: 0 0 auto;
        margin-left: 12px;
        font-size: 0;
        color: transparent;
    }

    .mobile-menu .slicknav_nav li.slicknav_parent > a.slicknav_row > span.slicknav_arrow::after {
        content: "\25BE";
        position: static;
        display: inline-block;
        width: auto;
        height: auto;
        border: 0;
        color: var(--als-header-blue);
        font-size: 14px;
        line-height: 1;
        transition: transform 0.2s ease;
    }

    .mobile-menu .slicknav_nav li.slicknav_parent.slicknav_open > a.slicknav_row > span.slicknav_arrow::after {
        transform: rotate(180deg);
    }

    /* Dropdown (site-source: .services-dropdown on phones) */
    .mobile-menu .slicknav_nav ul.sub-menu {
        margin: 0 0 10px;
        padding: 5px !important;
        border: 1px solid var(--als-header-line, #dce7ef);
        border-radius: 8px;
        background: #f3f8fc;
    }

    .mobile-menu .slicknav_nav ul.sub-menu li {
        border-bottom: 0;
    }

    .mobile-menu .slicknav_nav ul.sub-menu li a {
        display: block;
        min-height: 43px;
        margin: 0;
        padding: 12px !important;
        border-radius: 6px;
        color: var(--als-header-navy) !important;
        font-size: 14px;
        font-weight: 700;
        line-height: 1.35;
        text-transform: none;
        text-decoration: none;
    }

    .mobile-menu .slicknav_nav ul.sub-menu li a:hover,
    .mobile-menu .slicknav_nav ul.sub-menu li.current-menu-item a {
        background: #edf7fe;
        color: var(--als-header-blue) !important;
    }
}

/* Page header title: rendered as an <h1> when the page content has none (template-parts/header-title.php).
   Keep it looking exactly like the former <div> (no h1 margin / line-height from Bootstrap). */
.page-header h1.page-title {
    margin: 0;
    line-height: 1.5;
}

/* Quick Quote dropdown (live-site "Get a Free Quote" behaviour): hover or keyboard focus on the button
   lists the four quote forms; a click on the button itself still opens /pages/quick-quote/.
   Markup: ALS_Block_Registrar::quote_dropdown_menu(), used by the Company Hero block. */
.als-quote-dropdown {
    position: relative;
    display: inline-block;
}

.als-quote-dropdown .als-quote-dropdown__menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    z-index: 50;
    min-width: 220px;
    margin: 8px 0 0;
    padding: 6px 0;
    list-style: none;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(4, 28, 49, 0.25);
    transform: translateX(-50%);
    text-align: center;
}

/* Bridge the 8px gap so the menu doesn't close while the pointer moves down to it. */
.als-quote-dropdown .als-quote-dropdown__menu::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.als-quote-dropdown:hover .als-quote-dropdown__menu,
.als-quote-dropdown:focus-within .als-quote-dropdown__menu {
    display: block;
}

.als-quote-dropdown .als-quote-dropdown__menu li {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #eee;
}

.als-quote-dropdown .als-quote-dropdown__menu li:last-child {
    border-bottom: 0;
}

.als-quote-dropdown .als-quote-dropdown__menu a,
.als-quote-dropdown .als-quote-dropdown__menu a:visited {
    display: block;
    padding: 12px 16px;
    color: #333;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
}

.als-quote-dropdown .als-quote-dropdown__menu a:hover,
.als-quote-dropdown .als-quote-dropdown__menu a:focus {
    background: #f1f1f1;
    color: #0b2b49;
    text-decoration: none;
}

/* The Company Hero clips its overflow; let the dropdown hang below the hero instead of being cut off.
   (Its backdrops clip themselves, so nothing else spills out.) */
.als-company-hero-block:has(.als-quote-dropdown) {
    z-index: 5;
    overflow: visible;
}

/* Quick Quote page (/pages/quick-quote/): four service cards in two columns (icon, title, text and a
   full-width button), each opening its quote form. */
.als-quote-chooser {
    max-width: 980px;
    margin: 10px auto 50px;
    font-family: Arial, Helvetica, sans-serif;
}

.als-quote-chooser .als-quote-chooser__intro {
    margin: 0 0 26px;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.4;
    color: #0b2b49;
    text-align: center;
}

.als-quote-chooser__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.als-quote-chooser .als-quote-chooser__card,
.als-quote-chooser .als-quote-chooser__card:visited {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 28px 28px 26px;
    border: 1px solid #dce7ef;
    border-top: 4px solid #d83a34;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(11, 43, 73, 0.07);
    color: #172534;
    text-align: left;
    text-decoration: none;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.als-quote-chooser .als-quote-chooser__card:hover,
.als-quote-chooser .als-quote-chooser__card:focus-visible {
    box-shadow: 0 14px 30px rgba(11, 43, 73, 0.14);
    transform: translateY(-3px);
    text-decoration: none;
    outline: none;
}

.als-quote-chooser__icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-bottom: 18px;
    border-radius: 50%;
    background: #e9f4fc;
    color: #0b5ea8;
}

.als-quote-chooser__icon svg {
    display: block;
    width: 24px;
    height: 24px;
}

.als-quote-chooser__title {
    margin-bottom: 8px;
    font-size: 23px;
    font-weight: 800;
    line-height: 1.2;
    color: #0b2b49;
}

.als-quote-chooser__text {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #526b7c;
}

/* Full-width button look (the whole card is the link); auto top margin lines the buttons up. */
.als-quote-chooser__cta {
    display: block;
    width: 100%;
    margin-top: auto;
    padding: 13px 18px;
    border-radius: 6px;
    background: #0b5ea8;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

.als-quote-chooser .als-quote-chooser__card:hover .als-quote-chooser__cta,
.als-quote-chooser .als-quote-chooser__card:focus-visible .als-quote-chooser__cta {
    background: #0b2b49;
}

@media (max-width: 700px) {
    .als-quote-chooser__grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }

    .als-quote-chooser .als-quote-chooser__card {
        padding: 24px 20px 22px;
    }
}

/* Desktop dropdowns: smoother hover. The panel stays open ~0.2s after the pointer leaves (so a slightly
   diagonal move doesn't close it), a transparent bridge covers the gap under the item, keyboard focus
   opens it too, and the last items open to the left so the panel stays on screen. */
@media (min-width: 768px) {
    #masthead .main-navigation ul.primary-menu > li {
        position: relative;
    }

    #masthead .main-navigation ul.primary-menu > li > ul {
        display: block;
        top: 100%;
        left: 0;
        z-index: 100;
        visibility: hidden;
        opacity: 0;
        transform: translateY(6px);
        pointer-events: none;
        transition: opacity 0.15s ease 0.2s, transform 0.15s ease 0.2s, visibility 0s linear 0.35s;
    }

    #masthead .main-navigation ul.primary-menu > li:hover > ul,
    #masthead .main-navigation ul.primary-menu > li:focus-within > ul {
        visibility: visible;
        opacity: 1;
        transform: none;
        pointer-events: auto;
        transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
    }

    /* Bridge between the menu item and its panel. */
    #masthead .main-navigation ul.primary-menu > li > ul::before {
        content: "";
        position: absolute;
        top: -14px;
        left: 0;
        right: 0;
        height: 14px;
    }

    /* Rightmost items: align the panel to the item's right edge. */
    #masthead .main-navigation ul.primary-menu > li:nth-last-child(-n+2) > ul {
        left: auto;
        right: 0;
    }
}

/* Keep the header (and its dropdown panels) above page content. Without this the menu sits at z-index 1 in
   the page's root stacking context, so any positioned section with a higher z-index (e.g. the homepage
   Company Hero) covered the open dropdowns. */
#masthead.site-header {
    position: relative;
    z-index: 1000;
}

/* Phones: stop pages scrolling sideways. The client-logo slider (#jssor_1) is 980px wide and stays
   980px on inner pages, which pushed the floating Quick Quote / Call us / chat buttons off-screen. */
.jssor-slider { max-width: 100%; overflow: hidden; }
/* Form pages: the hidden "Contact Last Name" label is 15px too wide on phones */
.wpforms-field-label.wpforms-label-hide { left: 0 !important; width: 1px !important; overflow: hidden !important; }
