/* ============================================================
   Header navigation corrections
   Loaded last so it overrides megamenu screen.css.

   Fixes two structural faults in the original theme:
   1. The desktop menu only becomes a drawer below 1001px, but the
      hamburger button used Bootstrap's .visible-xs (<768px), so
      between 768px and 1000px the site had NO usable navigation.
   2. Ten top-level items at the theme's 15px padding overflow the
      1170px container, wrapping onto a second line that sits on top
      of the hero section.
   ============================================================ */

/* ---------- 1. Toggle button visibility ----------
   The markup class is .nav-toggle-item (was .visible-xs) so Bootstrap's
   `display:none !important` no longer fights us. */
.header-section ul li.nav-toggle-item { display: none; }

@media only screen and (max-width: 1000px) {
    .header-section ul li.nav-toggle-item { display: block; }
}

/* ---------- 2. Desktop: keep the menu on one line ---------- */
@media only screen and (min-width: 1001px) {

    .header-section #menu > ul {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
    }

    .header-section #menu > ul > li { float: none; flex: 0 0 auto; }

    /* Top-level labels must never break mid-word */
    .header-section #menu > ul > li > a {
        white-space: nowrap;
        font-size: 13px;
        letter-spacing: .02em;
        padding: 30px 13px;
        position: relative;
    }

    /* Submenu items keep their own comfortable spacing */
    .header-section #menu > ul > li ul li > a {
        white-space: normal;
        font-size: 13px;
        padding: 10px 20px;
    }

    /* Tighten progressively on narrower desktops instead of wrapping */
    @media (max-width: 1399px) {
        .header-section #menu > ul > li > a { padding: 30px 10px; font-size: 12.5px; }
    }
    @media (max-width: 1199px) {
        .header-section #menu > ul > li > a { padding: 30px 7px; font-size: 12px; }
        .header-section .logo img { max-width: 122px !important; }
    }

    /* Give the menu the room the logo does not need */
    .header-section .mod-menu > .row > .col-sm-2 { width: 14%; }
    .header-section .mod-menu > .row > .col-sm-10 { width: 86%; }

    /* Underline accent instead of the theme's solid block */
    .header-section #menu > ul > li > a::after {
        content: "";
        position: absolute;
        left: 13px;
        right: 13px;
        bottom: 22px;
        height: 2px;
        background: #ecae3d;
        transform: scaleX(0);
        transform-origin: left center;
        transition: transform .22s ease;
    }
    .header-section #menu > ul > li:hover > a::after,
    .header-section #menu > ul > li.active > a::after { transform: scaleX(1); }

    @media (max-width: 1399px) {
        .header-section #menu > ul > li > a::after { left: 10px; right: 10px; }
    }
    @media (max-width: 1199px) {
        .header-section #menu > ul > li > a::after { left: 7px; right: 7px; }
    }

    /* Dropdown panels: softer, more legible */
    .header-section #menu ul li ul {
        box-shadow: 0 10px 30px rgba(16, 48, 63, .16);
        border-radius: 6px;
        overflow: hidden;
        padding: 6px 0;
    }
    .header-section #menu ul li ul li ul { border-radius: 6px; }
}

/* ---------- 3. Tablet / small laptop drawer (768px - 1000px) ---------- */
@media only screen and (max-width: 1000px) {

    /* Logo column must not be squeezed to 2/12 of the row */
    .header-section .mod-menu > .row > .col-sm-2,
    .header-section .mod-menu > .row > .col-sm-10 {
        width: 100%;
        float: none;
    }

    .header-section .logo img { max-width: 132px !important; }

    /* Drawer panel */
    .header-section #menu {
        background: #fff;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 14px 34px rgba(16, 48, 63, .18);
        max-height: 78vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .header-section #menu > ul li a {
        font-size: 14px;
        padding: 14px 22px;
    }

    /* Nested levels get a visible indent so hierarchy reads clearly */
    .header-section #menu > ul li ul li a { padding-left: 38px; font-size: 13.5px; }
    .header-section #menu > ul li ul li ul li a { padding-left: 54px; }

    .header-section #menu > ul li.active > a { color: #086ca7; font-weight: 600; }

    /* Bootstrap hides .navbar-toggle above 768px - we need it up to 1000px */
    .header-section ul li.nav-toggle-item .navbar-toggle {
        display: block !important;
        float: none;
        margin: 0;
        padding: 12px 14px;
        border: 1px solid rgba(255, 255, 255, .35);
        border-radius: 6px;
        background: transparent;
        color: #fff;
        line-height: 1;
    }
    .header-section ul li.nav-toggle-item .navbar-toggle:hover,
    .header-section ul li.nav-toggle-item .navbar-toggle:focus {
        background: rgba(255, 255, 255, .12);
    }
    .header-section ul li.nav-toggle-item .navbar-toggle i { font-size: 20px; }
}

/* ---------- 4. Phones ---------- */
@media only screen and (max-width: 767px) {
    .header-section .logo img { max-width: 118px !important; }
    .header-section #menu > ul li a { padding: 13px 18px; font-size: 13.5px; }
    .header-section #menu > ul li ul li a { padding-left: 34px; }
    .header-section #menu { max-height: 72vh; }
}

/* ---------- 5. Top contact bar ---------- */
@media only screen and (max-width: 991px) {
    .topbar .col-md-6 { width: 100%; float: none; text-align: center; }
    .topbar .toplist { float: none !important; display: inline-block; }
    .topbar .toplist.pull-left { float: none !important; }
    .topbar .row.nopadding > div + div { margin-top: 2px; }
}

@media only screen and (max-width: 600px) {
    .topbar { font-size: 12px; }
    .topbar .toplist li { display: inline-block; }
}
