/* Header should be full width regardless of site container width */
.ehs-header .ehs-container {
    width: min(100%, 100% - 3rem);
}

@media (max-width: 640px) {
    .ehs-header .ehs-container {
        width: min(100%, 100% - 1.5rem);
    }
}

.ehs-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000; /* keep header visible above content but below modals */
    background-color: var(--ehs-color-light);
    box-shadow: 0 8px 24px rgba(30, 41, 59, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    border-bottom: 1px solid rgba(30, 41, 59, 0.12);
}

/* Always overlay on desktop: transparent at top, solid on scroll */
@media (min-width: 961px) {
    .ehs-header {
        background-color: transparent;
        box-shadow: none;
        border-bottom-color: transparent;
    }

    .ehs-header .ehs-menu > li > a,
    .ehs-header .ehs-phone,
    .ehs-header .ehs-location,
    .ehs-header .ehs-menu-toggle-line {
        color: var(--ehs-color-light);
    }

    .ehs-header.ehs-header--condensed {
        background-color: var(--ehs-color-light);
        box-shadow: 0 8px 24px rgba(30, 41, 59, 0.08);
        border-bottom-color: rgba(30, 41, 59, 0.12);
    }

    .ehs-header.ehs-header--condensed .ehs-menu > li > a,
    .ehs-header.ehs-header--condensed .ehs-phone,
    .ehs-header.ehs-header--condensed .ehs-location,
    .ehs-header.ehs-header--condensed .ehs-menu-toggle-line {
        color: var(--ehs-color-dark);
    }
    
    /* Ensure dropdown arrows are dark on condensed header */
    .ehs-header.ehs-header--condensed .ehs-menu > li.menu-item-has-children > a::after {
        border-top-color: var(--ehs-color-dark);
    }
    /* Hide any mobile submenu toggles if present due to SSR/cache */
    .ehs-menu > li > .ehs-submenu-toggle { display: none !important; }
}

.ehs-trust-bar {
    background: linear-gradient(135deg, var(--ehs-color-accent) 0%, var(--ehs-color-accent-light) 100%);
    color: var(--ehs-color-light);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    /* Allow smooth collapse on scroll */
    max-height: 200px; /* comfortably above actual content height */
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.25s ease;
    backdrop-filter: blur(8px);
}

.ehs-trust-bar .ehs-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 0;
    text-align: center;
}

/* Hide trust bar when header is condensed (after scroll or menu open) */
.ehs-header--condensed .ehs-trust-bar {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    border-bottom-width: 0;
}

.ehs-trust-message {
    text-transform: uppercase;
    font-weight: 600;
    opacity: 0.95;
    line-height: 1.2;
}

/* Responsive trust bar message */
@media (max-width: 960px) {
    .ehs-trust-bar {
        display: none;
    }
}

.ehs-header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.75rem;
    padding: 1.2rem 0;
}

.ehs-header--condensed .ehs-header-inner {
    padding: 0.85rem 0;
}

/* Transparent variant at top */
.ehs-header.ehs-header--at-top {
    background-color: transparent;
    box-shadow: none;
    border-bottom-color: transparent;
}

.ehs-header.ehs-header--at-top .ehs-menu > li > a,
.ehs-header.ehs-header--at-top .ehs-phone,
.ehs-header.ehs-header--at-top .ehs-location,
.ehs-header.ehs-header--at-top .ehs-menu-toggle-line {
    color: var(--ehs-color-light);
}

.ehs-header.ehs-header--at-top .ehs-menu > li > a {
    border-color: transparent;
}

.ehs-header.ehs-header--at-top .ehs-menu > li > a:focus,
.ehs-header.ehs-header--at-top .ehs-menu > li > a:hover,
.ehs-header.ehs-header--at-top .ehs-menu > li.current-menu-item > a,
.ehs-header.ehs-header--at-top .ehs-menu > li.current-menu-ancestor > a {
    color: var(--ehs-color-light);
    border-color: rgba(255,255,255,0.6);
}

/* Ensure dropdown arrows are white on transparent header */
@media (min-width: 961px) {
    .ehs-header.ehs-header--at-top .ehs-menu > li.menu-item-has-children > a::after {
        border-top-color: rgba(255, 255, 255, 0.8);
    }
}

.ehs-header.ehs-header--at-top .ehs-tagline {
    color: rgba(255,255,255,0.8);
}



.ehs-header.ehs-header--at-top .ehs-button:hover,
.ehs-header.ehs-header--at-top .ehs-button:focus {
    background: var(--ehs-gradient-cta-bright-hover);
}

/* Ensure dropdown menus remain visible on transparent header */
.ehs-header.ehs-header--at-top .ehs-menu li ul {
    background: rgba(14,26,37,0.06);
    backdrop-filter: blur(6px);
}

/* Match submenu item colors to main menu when header is transparent (desktop) */
@media (min-width: 961px) {
    .ehs-header.ehs-header--at-top .ehs-menu li ul li a {
        color: var(--ehs-color-light);
    }

    .ehs-header.ehs-header--at-top .ehs-menu li ul li a:focus,
    .ehs-header.ehs-header--at-top .ehs-menu li ul li a:hover {
        background: rgba(255,255,255,0.12);
        color: var(--ehs-color-light);
    }
}

.ehs-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.ehs-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ehs-logo-mark {
    width: clamp(120px, 18vw, 156px);
    height: auto;
    transition: width 0.3s ease;
}

.ehs-header--condensed .ehs-logo-mark {
    width: clamp(108px, 16vw, 140px);
}

.ehs-tagline {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ehs-color-muted);
}

.ehs-nav-rail {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    position: relative;
}

/* Header compact CTA (mobile only) */
.ehs-header-cta {
    display: none;
}

.ehs-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.ehs-nav-close {
    display: none;
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(14, 26, 37, 0.18);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 8px 24px rgba(14, 26, 37, 0.15);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.ehs-nav-close-line {
    position: absolute;
    top: 50%;
    left: 19px;
    right: 19px;
    height: 2px;
    border-radius: 999px;
    background: var(--ehs-color-dark);
    transform: rotate(45deg);
}

.ehs-nav-close-line:nth-child(3) {
    transform: rotate(-45deg);
}

.ehs-nav-close:hover,
.ehs-nav-close:focus {
    border-color: rgba(14, 26, 37, 0.4);
    background: var(--ehs-color-light);
}

.ehs-primary-nav {
    flex: 1;
}

.ehs-menu {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1.75rem;
    margin: 0;
    padding: 0;
    font-weight: 600;
}

.ehs-menu > li {
    position: relative;
}

.ehs-menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0;
    color: var(--ehs-color-dark);
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

/* Add dropdown arrow for menu items with submenus on desktop */
@media (min-width: 961px) {
    .ehs-menu > li.menu-item-has-children > a::after {
        content: '';
        width: 0;
        height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 5px solid currentColor;
        margin-left: 0.25rem;
        transition: transform 0.2s ease;
    }
    
    .ehs-menu > li.menu-item-has-children:hover > a::after,
    .ehs-menu > li.menu-item-has-children:focus-within > a::after {
        transform: rotate(180deg);
    }
}

.ehs-menu > li > a:focus,
.ehs-menu > li > a:hover,
.ehs-menu > li.current-menu-item > a,
.ehs-menu > li.current-menu-ancestor > a {
    color: var(--ehs-color-cta-bright);
    border-color: var(--ehs-color-cta-bright);
}

.ehs-menu li ul {
    position: absolute;
    top: calc(100% + 0.5rem); /* slightly closer to parent to reduce hover gap */
    left: 0;
    min-width: 220px;
    background: var(--ehs-color-light);
    border-radius: var(--ehs-radius-md);
    box-shadow: 0 12px 32px rgba(30, 41, 59, 0.12);
    padding: 0.75rem 0;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 20;
}

/* Create a hover bridge so cursor can travel from parent to submenu without closing */
@media (min-width: 961px) {
    .ehs-menu > li:hover::after,
    .ehs-menu > li:focus-within::after {
        content: "";
        position: absolute;
        left: -8px;
        right: -8px;
        top: 100%;
        height: 20px; /* buffer zone */
        /* invisible area that preserves :hover on parent while moving down */
    }
}

.ehs-menu li:hover > ul,
.ehs-menu li:focus-within > ul {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ehs-menu li ul li a {
    display: block;
    padding: 0.65rem 1.1rem; /* improved density on desktop */
    color: var(--ehs-color-dark);
    font-weight: 500;
}

/* Desktop dropdown item styling improvements */
@media (min-width: 961px) {
    .ehs-menu li ul {
        border: 1px solid rgba(14,26,37,0.08);
    }

    .ehs-menu li ul li a {
        padding: 0.7rem 1rem;
        border-radius: var(--ehs-radius-sm);
        margin: 0 0.35rem; /* inner breathing room */
    }

.ehs-menu li ul li a:focus,
.ehs-menu li ul li a:hover {
    background: rgba(245, 158, 11, 0.15);
    color: var(--ehs-color-cta-bright);
}
}

.ehs-nav-meta {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.ehs-contact {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-start;
    min-width: 0;
}

.ehs-phone {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.29rem;
    color: var(--ehs-color-dark);
}

.ehs-phone:focus,
.ehs-phone:hover {
    color: var(--ehs-color-cta-bright);
}

.ehs-location {
    font-size: 0.8rem;
    color: var(--ehs-color-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ehs-contact-cta {
    margin-top: 0.35rem;
}

.ehs-menu-toggle {
    display: none;
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255,255,255,0.06);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.ehs-menu-toggle-line {
    position: absolute;
    left: 12px;
    right: 12px;
    height: 2px;
    background: var(--ehs-color-dark);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ehs-menu-toggle-line:nth-child(1) { top: 16px; }
.ehs-menu-toggle-line:nth-child(2) { top: 22px; }
.ehs-menu-toggle-line:nth-child(3) { top: 28px; }

body.ehs-nav-open .ehs-menu-toggle-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

body.ehs-nav-open .ehs-menu-toggle-line:nth-child(2) {
    opacity: 0;
}

body.ehs-nav-open .ehs-menu-toggle-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--ehs-color-primary);
    color: var(--ehs-color-light);
    padding: 0.5rem 1rem;
    z-index: 1001;
}

.skip-link:focus {
    top: 0;
}

.screen-reader-text {
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}

.ehs-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14, 26, 37, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    z-index: 900;
}

body.ehs-nav-open .ehs-overlay {
    opacity: 1;
    visibility: visible;
}

body.ehs-nav-open {
    overflow: hidden;
}

@media (max-width: 1200px) {
    .ehs-header-inner {
        gap: 1.25rem;
    }

    .ehs-menu {
        gap: 1.25rem;
    }
}

@media (max-width: 1040px) {
    .ehs-tagline {
        display: none;
    }

    .ehs-menu {
        gap: 1.1rem;
        font-size: 0.95rem;
    }
}

.ehs-mobile-topbar { display: none; }

@media (max-width: 960px) {
    .ehs-header {
        position: fixed;
        width: 100%;
    }

    .ehs-header-inner {
        grid-template-columns: auto auto;
        gap: 0.9rem;
        padding: 1rem 0;
    }

    .ehs-nav-rail {
        position: fixed;
        top: var(--ehs-header-height, 0px);
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        background: var(--ehs-color-light);
        box-shadow: -12px 0 32px rgba(30, 41, 59, 0.12);
        padding: 0; /* header remains visible above; inner paddings handled by sections */
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        transform: translateX(100%);
        transition: transform 0.35s ease;
        z-index: 1100;
        border-left: 1px solid rgba(30, 41, 59, 0.12);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .ehs-nav-close { display: none; }

    .ehs-mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.75rem;
        width: 100%;
        box-sizing: border-box;
        padding: 0.85rem 1.5rem;
        padding-right: calc(1.5rem + env(safe-area-inset-right));
        padding-left: calc(1.5rem + env(safe-area-inset-left));
        border-bottom: 1px solid rgba(14,26,37,0.12);
        background: #f6f8fb; /* slightly tinted to distinguish from menu */
        box-shadow: 0 2px 12px rgba(14,26,37,0.08);
        position: sticky;
        top: 0;
        z-index: 5;
    }

    .ehs-mobile-actions {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        flex: 0 0 auto;
    }

    .ehs-mobile-topbar .ehs-phone {
        margin-left: auto;
        flex: 0 0 auto;
        text-align: right;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 65%;
    }

    .ehs-mobile-topbar .ehs-phone {
        font-family: var(--ehs-font-family-base);
        font-size: 1.06rem;
        letter-spacing: 0.08em;
        color: var(--ehs-color-dark);
    }

.ehs-whatsapp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ehs-color-success);
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.4);
    flex: 0 0 auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .ehs-whatsapp-icon { width: 22px; height: 22px; display: block; }

.ehs-email {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ehs-color-primary);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.35);
    flex: 0 0 auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .ehs-email-icon { width: 22px; height: 22px; display: block; }

.ehs-whatsapp:hover,
.ehs-email:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.5);
}

.ehs-email:hover {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.5);
}

    body.ehs-nav-open .ehs-nav-rail {
        transform: translateX(0);
    }

    .ehs-primary-nav,
    .ehs-nav-meta {
        width: 100%;
    }

    .ehs-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        font-size: 1.05rem;
        padding: 0.25rem 0;
    }

    /* Parent row uses grid to host label and right toggle */
    .ehs-menu > li {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: stretch;
    }
    .ehs-menu > li > a {
        border: none;
        padding: 0.9rem 1.25rem; /* slight gutters from screen edges */
        font-weight: 500; /* not bold */
        border-bottom: 1px solid rgba(14,26,37,0.08); /* divider */
        color: var(--ehs-color-dark);
    }
    .ehs-menu > li > .ehs-submenu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 1rem;
        min-width: 3rem;
        background: transparent;
        color: var(--ehs-color-dark);
        border: 0;
        border-left: 1px solid rgba(14,26,37,0.12);
        border-bottom: 1px solid rgba(14,26,37,0.08);
        font-weight: 700;
        font-size: 1.25rem;
        cursor: pointer;
    }
    .ehs-menu > li > .ehs-submenu-toggle:focus,
    .ehs-menu > li > .ehs-submenu-toggle:hover {
        background: rgba(14,26,37,0.04);
    }

    /* Collapse submenus by default, expand when parent has .ehs-open */
    .ehs-menu li ul {
        position: relative;
        top: auto;
        left: auto;
        min-width: 100%;
        box-shadow: none;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transform: none;
        background: transparent;
        transition: max-height 0.25s ease, opacity 0.2s ease, visibility 0.2s ease;
    }
    .ehs-menu li.ehs-open > ul {
        max-height: 1000px; /* large enough for contents */
        opacity: 1;
        visibility: visible;
    }

    .ehs-menu li ul li a {
        color: var(--ehs-color-dark);
        padding: 0.9rem 1.25rem;
        padding-left: 2rem; /* indent submenu items */
        border-bottom: 1px solid rgba(14,26,37,0.08);
    }

    .ehs-nav-meta {
        display: none; /* hide old contact block in mobile */
    }

    .ehs-mobile-cta {
        margin-top: auto;
        width: 100%;
        padding: 1rem 1.25rem 1.5rem;
        padding-right: calc(1.25rem + env(safe-area-inset-right));
        padding-left: calc(1.25rem + env(safe-area-inset-left));
        box-sizing: border-box;
        border-top: 1px solid rgba(14,26,37,0.08);
        background: var(--ehs-color-light);
        position: sticky;
        bottom: 0;
    }

    .ehs-mobile-cta .ehs-button {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding-left: 1.1rem;
        padding-right: 1.1rem;
        justify-content: center;
        box-shadow: var(--ehs-shadow-button);
        white-space: normal; /* allow wrap on tiny screens */
        text-align: center;
        line-height: 1.2;
        font-size: 0.88rem;
    }

    .ehs-contact {
        width: 100%;
        gap: 0.6rem;
    }

    .ehs-contact-cta .ehs-button {
        width: 100%;
    }

    .ehs-menu-toggle {
        display: inline-flex;
        margin-left: auto;
        border-color: rgba(14,26,37,0.18);
        background: var(--ehs-color-light);
    }

    .ehs-header-cta {
        display: inline-flex;
        padding: 0.6rem 1rem;
        font-size: 0.82rem;
        letter-spacing: 0.04em;
        white-space: nowrap;
    }

    .ehs-header-actions {
        gap: 0.5rem;
    }
}

@media (max-width: 640px) {
    .ehs-header-inner {
        padding: 0.85rem 0;
    }

    .ehs-logo-mark {
        width: clamp(110px, 38vw, 140px);
    }

    .ehs-nav-rail {
        padding-top: 0;
    }

    .ehs-menu {
        font-size: 1.05rem;
    }

    /* Prevent horizontal overflow on small phones and respect safe areas */
    .ehs-mobile-cta {
        padding-right: calc(1.25rem + env(safe-area-inset-right));
        padding-left: calc(1.25rem + env(safe-area-inset-left));
    }

    .ehs-mobile-cta .ehs-button {
        padding-left: 1.2rem;
        padding-right: 1.2rem;
    }
}

/* Ensure CTA is hidden on desktop irrespective of .ehs-button defaults */
@media (min-width: 961px) {
    .ehs-header-cta { display: none; }
}

/* Ensure hamburger appears white when header is at top on mobile against light hero */
@media (max-width: 960px) {
    .ehs-header.ehs-header--at-top .ehs-menu-toggle {
        border-color: rgba(255,255,255,0.55);
        background: rgba(255,255,255,0.12);
    }
    .ehs-header.ehs-header--at-top .ehs-menu-toggle-line {
        background: #fff;
    }
}

/* Logo Image Styles */
.ehs-logo-image {
    max-width: 100%;
    height: auto;
    display: block;
    transition: width 0.3s ease, height 0.3s ease;
}

/* Regular logo (shown by default) */
.ehs-logo-image--regular {
    display: block;
}

/* Condensed logo (hidden by default) */
.ehs-logo-image--condensed {
    display: none;
}

/* Responsive logo sizing */
@media (max-width: 640px) {
    .ehs-logo-image--regular {
        max-width: clamp(120px, 18vw, 156px);
    }
    
    .ehs-logo-image--condensed {
        max-width: clamp(100px, 15vw, 130px);
    }
}

@media (min-width: 641px) and (max-width: 960px) {
    .ehs-logo-image--regular {
        max-width: clamp(108px, 16vw, 140px);
    }
    
    .ehs-logo-image--condensed {
        max-width: clamp(90px, 13vw, 120px);
    }
}

@media (min-width: 961px) {
    .ehs-logo-image--regular {
        max-width: clamp(120px, 18vw, 156px);
    }
    
    .ehs-logo-image--condensed {
        max-width: clamp(108px, 16vw, 140px);
    }
}
