/* =========================================================
   HEADER REDESIGN
   Uses the site's real brand tokens already defined in the
   parent theme's style.css (from the cab-core CSS block):
   --cab-primary (#2D4698), --cab-accent (#D4A017), --cab-dark.
   ========================================================= */

/* ---------- Fixed heights so sticky mode never causes
   a layout jump (protects CLS) ---------- */
:root {
    --itb-topbar-h: 42px;
    --itb-masthead-h: 84px;
    --itb-masthead-h-mobile: 64px;
}

/* ===== TOP UTILITY BAR ===== */
#top-header {
    background: var(--cab-dark, #0f1b3d);
    border-bottom: 1px solid rgba(255,255,255,.08);
    height: var(--itb-topbar-h);
}
#top-header .container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    box-sizing: border-box;
}
#quick-contact ul {
    display: flex;
    align-items: center;
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}
#quick-contact li { font-size: 12.5px; color: #a9b4d6; }
#quick-contact .quick-message { display: none; } /* redundant next to visible phone/email */
#quick-contact a {
    color: var(--cab-accent, #D4A017);
    text-decoration: none;
    font-weight: 700;
}
#quick-contact a:hover { color: #fff; }

/* search box: centered, flexible width, but never wider than
   its allotted space (min-width:0 stops flex items from
   refusing to shrink below their content size, which was
   letting this overflow past the container edge) */
#header-search {
    flex: 1 1 auto;
    max-width: 360px !important;
    width: 100%;
    min-width: 0;
    margin: 0 auto;
    position: relative;
    box-sizing: border-box;
}
#header-search .right-bar { width: 100%; min-width: 0; }
#header-search .search-form {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(15,27,61,.08));
    position: relative;
}
#header-search .search-form label { flex: 1; display: block; margin: 0; }
#header-search .search-field {
    width: 100%;
    border: 0;
    outline: 0;
    padding: 9px 16px;
    font-size: 13.5px;
    background: transparent;
    color: var(--cab-dark, #0f1b3d);
}
#header-search .search-submit {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    cursor: pointer;
    width: 34px;
    height: 34px;
    margin: 4px;
    border-radius: 50%;
    flex-shrink: 0;
    background-color: var(--cab-primary, #2D4698);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 15px;
    text-indent: -9999px;
    overflow: hidden;
    transition: background-color .15s ease;
}
#header-search .search-submit:hover { background-color: var(--cab-primary-dark, #1c2f6b); }

/* Guard against a second/duplicate search form rendering
   anywhere else inside the header or mobile nav markup */
#masthead .search-form,
.wrap-menu-content .search-form,
#main-nav .search-form {
    display: none !important;
}

/* live results dropdown (injected by header-search.js).
   Hidden with three separate properties + !important so no
   competing theme/page-builder rule can force it visible. */
#header-search .itb-search-results {
    position: absolute !important;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(15,27,61,.12));
    overflow: hidden;
    z-index: 1000;
    display: none !important;
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity .12s ease;
}
#header-search .itb-search-results.is-open {
    display: block !important;
    max-height: 400px !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}
.itb-search-results a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--cab-dark, #0f1b3d);
    font-size: 13.5px;
    border-bottom: 1px solid #f0f1f5;
}
.itb-search-results a:last-child { border-bottom: 0; }
.itb-search-results a:hover,
.itb-search-results a.is-active { background: var(--cab-platinum, #F3F9FA); }
.itb-search-results .itb-result-price {
    font-weight: 700;
    color: var(--cab-primary, #2D4698);
    white-space: nowrap;
}
.itb-search-results .itb-result-empty,
.itb-search-results .itb-result-loading {
    padding: 14px 16px;
    font-size: 13px;
    color: #888;
}

/* ===== MAIN HEADER BAR ===== */
header#masthead.site-header {
    background: var(--cab-primary, #2D4698);
    border-bottom: none;
    box-shadow: 0 2px 8px rgba(15,27,61,.12);
    height: var(--itb-masthead-h);
}
header#masthead .container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    box-sizing: border-box;
}
.site-branding {
    display: flex;
    align-items: center;
    height: 100%;
    flex-shrink: 0;
}
.site-branding .custom-logo-link {
    display: flex;
    align-items: center;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}
.site-branding .custom-logo {
    height: 74px !important;
    width: auto !important;
    max-width: none !important;
    display: block !important; /* guards against any hidden/collapsed state */
}

#main-nav { height: 100%; display: flex; align-items: center; }
.main-navigation { height: 100%; }
.main-navigation .wrap-menu-content { height: 100%; }
.menu-main-menu-container { height: 100%; }
#primary-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 100%;
}
#primary-menu > li { position: relative; height: 100%; display: flex; align-items: center; }
#primary-menu > li > a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .02em;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: border-color .15s ease, color .15s ease;
}
#primary-menu > li > a:hover,
#primary-menu > li.current-menu-item > a {
    color: var(--cab-accent, #D4A017);
    border-bottom-color: var(--cab-accent, #D4A017);
}

/* dropdown submenu */
#primary-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: #fff;
    list-style: none;
    margin: 0;
    padding: 8px;
    border-radius: 12px;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(15,27,61,.12));
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
    z-index: 1000;
}
#primary-menu li:hover > .sub-menu,
#primary-menu li:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#primary-menu .sub-menu li { height: auto; }
#primary-menu .sub-menu a {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--cab-dark, #0f1b3d);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 0 !important;
}
#primary-menu .sub-menu a:hover { background: var(--cab-platinum, #F3F9FA); color: var(--cab-primary, #2D4698); }

.menu-toggle { display: none; }

/* ===== STICKY ON SCROLL =====
   On scroll: hide the logo/nav bar and the contact-info links
   entirely. Keep only a compact search bar pinned to the top. */
body.itb-scrolled { padding-top: 56px; }

body.itb-scrolled header#masthead.site-header { display: none !important; }

body.itb-scrolled #top-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 999;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 16px rgba(15,27,61,.10);
    animation: itb-header-drop .2s ease;
}
body.itb-scrolled #top-header .container {
    justify-content: center;
}
body.itb-scrolled #quick-contact { display: none; }
body.itb-scrolled #header-search { max-width: 480px; }

@keyframes itb-header-drop {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    body.itb-scrolled #top-header { animation: none; }
}

/* ===== MOBILE ===== */
@media (max-width: 880px) {
    #top-header .container { padding: 0 16px; gap: 12px; }
    #quick-contact .quick-email { display: none; } /* keep just the phone link on small screens */
    #header-search { max-width: none; }

    header#masthead.site-header,
    body.itb-scrolled header#masthead.site-header { height: var(--itb-masthead-h-mobile); }
    body.itb-scrolled { padding-top: var(--itb-masthead-h-mobile); }
    header#masthead .container { padding: 0 16px 0 0; }
    .site-branding { padding: 0 16px; }
    .site-branding .custom-logo { height: 52px !important; }

    #main-nav { height: auto; }
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border: 0;
        border-radius: 8px;
        background: #fff;
        cursor: pointer;
        font-size: 0; /* hide the "Menu" text, show icon only */
        position: relative;
    }
    .menu-toggle::before {
        content: "";
        width: 18px; height: 2px;
        background: var(--cab-primary, #2D4698);
        box-shadow: 0 -6px 0 var(--cab-primary, #2D4698), 0 6px 0 var(--cab-primary, #2D4698);
    }
    .wrap-menu-content {
        display: none;
        position: fixed;
        top: var(--itb-masthead-h-mobile);
        left: 0; right: 0;
        bottom: 0;
        background: #fff;
        overflow-y: auto;
        z-index: 998;
    }
    body.itb-scrolled .wrap-menu-content { top: var(--itb-masthead-h-mobile); }
    .main-navigation.is-open .wrap-menu-content { display: block; }
    #primary-menu {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        padding: 8px 0;
    }
    #primary-menu > li {
        height: auto;
        flex-direction: column;
        align-items: stretch;
        border-bottom: 1px solid #f0f1f5;
    }
    #primary-menu > li > a {
        height: auto;
        padding: 14px 20px;
        border-bottom: 0;
        color: var(--cab-dark, #0f1b3d); /* panel bg is white here, unlike the blue desktop bar */
    }
    #primary-menu > li > a:hover,
    #primary-menu > li.current-menu-item > a {
        color: var(--cab-primary, #2D4698);
    }
    #primary-menu .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: var(--cab-platinum, #F3F9FA);
        border-radius: 0;
        display: none;
        margin: 0;
        padding: 4px 0;
    }
    #primary-menu li.is-expanded > .sub-menu { display: block; }

    /* ===== REAL mobile menu trigger =====
       This is the actual element the theme renders on mobile
       (<a id="mobile-trigger"><i class="fa fa-bars"></i></a>),
       not .menu-toggle. By default it renders as its own
       full-width black bar below the header. This pulls it
       into the blue header bar itself, right-aligned, as a
       small icon button — fixed positioning is used since it
       sits outside #masthead in the DOM (a sibling near the
       top of #page), so it can't be reached with normal
       in-flow header CSS. */
    #mobile-trigger {
        position: fixed !important;
        top: calc(var(--itb-topbar-h) + (var(--itb-masthead-h-mobile) - 40px) / 2) !important;
        right: 16px !important;
        left: auto !important;
        bottom: auto !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #fff !important;
        border-radius: 8px !important;
        z-index: 1001 !important; /* above the sticky masthead */
        box-shadow: 0 2px 6px rgba(15,27,61,.15);
        transition: top .15s ease;
    }
    body.itb-scrolled #mobile-trigger {
        display: none !important;
    }
    #mobile-trigger i {
        background: none !important;
        color: var(--cab-primary, #2D4698) !important;
        font-size: 18px !important;
        margin: 0 !important;
    }
}

@media (min-width: 881px) {
    #mobile-trigger { display: none !important; }
}

/* =========================================================
   BREADCRUMB ALIGNMENT
   The breadcrumb bar uses its own max-width:1100px container,
   which doesn't match the header's 1240px one, so "Home / ..."
   sat at a different left edge than the logo above it. This
   re-aligns them to the same edge.
   ========================================================= */
.cab-route-page .cab-breadcrumb,
nav.cab-breadcrumb {
    max-width: 1240px !important;
}
