/*
 * FE-019: Global Header Redesign
 * All new header styles — matches Figma 20:609
 */

:root {
    --hdr-ink: #18181B;
    --hdr-ink-soft: #3F3F46;
    --hdr-ink-muted: #71717A;
    --hdr-line: #F4F4F5;
    --hdr-line-strong: #E4E4E7;
    --hdr-surface: #ffffff;
    --hdr-surface-hover: #FAFAFA;
    --hdr-brand: #01BF5A;
    --hdr-brand-dark: #00A34D;
    --hdr-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Reset old header styles ── */
.header {
    position: relative;
    z-index: 100;
    width: 100%;
    margin: 0;
    top: 0;
}

.header-inner {
    background-color: var(--hdr-surface);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid var(--hdr-line);
    transition: none;
    padding: 0;
}

.header-inner .row {
    margin: 0;
}

/* ── Header container ── */
.hdr-container {
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    padding: 0 24px;
}

/* ── Brand section ── */
.hdr-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.hdr-brand-logo {
    height: 50px;
    width: auto;
}

/* ── Desktop nav ── */
.hdr-nav {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.hdr-nav-list {
    display: flex;
    align-items: center;
    gap: 24px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.hdr-nav-list li {
    margin: 0;
    padding: 0;
}

.hdr-nav-list li::after,
.hdr-nav-list li::before {
    content: none;
}

.hdr-nav-list > li > a,
.hdr-nav-list > li > .hdr-nav-sub-toggle {
    font-family: "Roboto", sans-serif;
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: 0.01em;
    color: var(--hdr-ink-soft);
    text-decoration: none;
    padding: 30px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    transition: color 0.2s var(--hdr-ease);
    cursor: pointer;
    background: none;
    border: none;
    outline: none;
    white-space: nowrap;
}

/* Animated underline indicator — scales from center across the full text width */
.hdr-nav-list > li > a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 20px;
    height: 2px;
    background: var(--hdr-brand);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s var(--hdr-ease);
}

.hdr-nav-list > li:hover > a::after,
.hdr-nav-list > li:focus-within > a::after,
.hdr-nav-list > li.current-menu-item > a::after,
.hdr-nav-list > li.current-menu-ancestor > a::after,
.hdr-nav-list > li.current-menu-parent > a::after {
    transform: scaleX(1);
}

/* Parent link state — holds while the cursor is anywhere inside the <li> (including the dropdown) */
.hdr-nav-list > li:hover > a,
.hdr-nav-list > li:focus-within > a,
.hdr-nav-list > li.current-menu-item > a,
.hdr-nav-list > li.current-menu-ancestor > a,
.hdr-nav-list > li.current-menu-parent > a,
.hdr-nav-list > li > .hdr-nav-sub-toggle:hover {
    color: var(--hdr-ink);
}

/* Has-children chevron */
.hdr-nav-chevron {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
    color: currentColor;
    opacity: 0.55;
    transition: transform 0.3s var(--hdr-ease), opacity 0.2s var(--hdr-ease), color 0.2s var(--hdr-ease);
}

.hdr-nav-list > li:hover > a .hdr-nav-chevron,
.hdr-nav-list > li:focus-within > a .hdr-nav-chevron,
.hdr-nav-list > li.current-menu-item > a .hdr-nav-chevron,
.hdr-nav-list > li.current-menu-ancestor > a .hdr-nav-chevron,
.hdr-nav-list > li.current-menu-parent > a .hdr-nav-chevron {
    transform: rotate(180deg);
    opacity: 1;
    color: var(--hdr-brand);
}

/* ── Desktop dropdown ── */
.hdr-nav-list > li {
    position: relative;
}

.hdr-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: var(--hdr-surface);
    border: 1px solid var(--hdr-line-strong);
    border-radius: 10px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 12px 28px rgba(17, 17, 17, 0.08);
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition:
        opacity 0.25s var(--hdr-ease),
        transform 0.25s var(--hdr-ease),
        visibility 0.25s var(--hdr-ease);
    z-index: 200;
    list-style: none;
    margin: 0;
}

.hdr-nav-list > li:hover > .hdr-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.hdr-dropdown__item {
    margin: 0;
    padding: 0;
    list-style: none;
    position: relative;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        opacity 0.25s var(--hdr-ease),
        transform 0.25s var(--hdr-ease);
}

/* Reveal direct children of the first-level dropdown when the top-level <li> is hovered */
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item,
.hdr-nav-list > li:focus-within > .hdr-dropdown > .hdr-dropdown__item {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger first-level dropdown items for graceful reveal */
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item:nth-child(1) { transition-delay: 0.04s; }
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item:nth-child(2) { transition-delay: 0.07s; }
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item:nth-child(3) { transition-delay: 0.10s; }
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item:nth-child(4) { transition-delay: 0.13s; }
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item:nth-child(5) { transition-delay: 0.16s; }
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item:nth-child(6) { transition-delay: 0.19s; }
.hdr-nav-list > li:hover > .hdr-dropdown > .hdr-dropdown__item:nth-child(n+7) { transition-delay: 0.22s; }

.hdr-dropdown > .hdr-dropdown__item + .hdr-dropdown__item {
    border-top: 1px solid var(--hdr-line);
}

.hdr-dropdown__item::after,
.hdr-dropdown__item::before,
.hdr-dropdown li::after,
.hdr-dropdown li::before {
    content: none;
}

.hdr-dropdown__link {
    font-family: "Roboto", sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: var(--hdr-ink-soft);
    text-decoration: none;
    padding: 12px 22px 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    white-space: nowrap;
    transition:
        background 0.2s var(--hdr-ease),
        color 0.2s var(--hdr-ease),
        padding-left 0.25s var(--hdr-ease);
}

.hdr-dropdown__label {
    flex: 1 1 auto;
    min-width: 0;
}

/* Right-pointing caret on items that have a sub-menu */
.hdr-dropdown__caret {
    flex-shrink: 0;
    color: var(--hdr-ink-muted);
    opacity: 0.5;
    transition:
        transform 0.25s var(--hdr-ease),
        color 0.2s var(--hdr-ease),
        opacity 0.2s var(--hdr-ease);
}

.hdr-dropdown__item--has-sub:hover > .hdr-dropdown__link .hdr-dropdown__caret {
    color: var(--hdr-brand);
    opacity: 1;
    transform: translateX(3px);
}

/* Left accent bar that slides in on hover */
.hdr-dropdown__link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 0;
    background: var(--hdr-brand);
    border-radius: 0 2px 2px 0;
    transform: translateY(-50%);
    transition: height 0.25s var(--hdr-ease);
}

.hdr-dropdown__item:hover > .hdr-dropdown__link {
    background: var(--hdr-surface-hover);
    color: var(--hdr-ink);
    padding-left: 24px;
}

.hdr-dropdown__item:hover > .hdr-dropdown__link::before {
    height: 18px;
}

/* ── Cascading sub-menu (depth 2+) ── */
.hdr-dropdown--sub {
    position: absolute;
    top: -7px;            /* align with parent item's top edge, accounting for panel padding */
    left: calc(100% + 6px);
    min-width: 220px;
    background: var(--hdr-surface);
    border: 1px solid var(--hdr-line-strong);
    border-radius: 10px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 12px 28px rgba(17, 17, 17, 0.08);
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-6px);
    transition:
        opacity 0.22s var(--hdr-ease),
        transform 0.25s var(--hdr-ease),
        visibility 0.22s var(--hdr-ease);
    z-index: 210;
    list-style: none;
    margin: 0;
}

/* Decorative connector — bridges the 6px gap so hover doesn't break between panels */
.hdr-dropdown--sub::before {
    content: "";
    position: absolute;
    top: 0;
    left: -10px;
    width: 10px;
    height: 100%;
}

/* Show the sub-panel when its parent item is hovered */
.hdr-dropdown__item--has-sub:hover > .hdr-dropdown--sub,
.hdr-dropdown__item--has-sub:focus-within > .hdr-dropdown--sub {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
}

/* Parent item of an open sub-menu stays highlighted */
.hdr-dropdown__item--has-sub:hover > .hdr-dropdown__link,
.hdr-dropdown__item--has-sub:focus-within > .hdr-dropdown__link {
    background: var(--hdr-surface-hover);
    color: var(--hdr-ink);
    padding-left: 24px;
}

.hdr-dropdown__item--has-sub:hover > .hdr-dropdown__link::before,
.hdr-dropdown__item--has-sub:focus-within > .hdr-dropdown__link::before {
    height: 18px;
}

/* Reveal + stagger sub-panel items when the parent item is hovered */
.hdr-dropdown__item--has-sub:hover > .hdr-dropdown--sub > .hdr-dropdown__item,
.hdr-dropdown__item--has-sub:focus-within > .hdr-dropdown--sub > .hdr-dropdown__item {
    opacity: 1;
    transform: translateY(0);
}

.hdr-dropdown__item--has-sub:hover > .hdr-dropdown--sub > .hdr-dropdown__item:nth-child(1) { transition-delay: 0.03s; }
.hdr-dropdown__item--has-sub:hover > .hdr-dropdown--sub > .hdr-dropdown__item:nth-child(2) { transition-delay: 0.06s; }
.hdr-dropdown__item--has-sub:hover > .hdr-dropdown--sub > .hdr-dropdown__item:nth-child(3) { transition-delay: 0.09s; }
.hdr-dropdown__item--has-sub:hover > .hdr-dropdown--sub > .hdr-dropdown__item:nth-child(4) { transition-delay: 0.12s; }
.hdr-dropdown__item--has-sub:hover > .hdr-dropdown--sub > .hdr-dropdown__item:nth-child(n+5) { transition-delay: 0.15s; }

/* Viewport-edge safety: if the sub-panel would overflow right, flip it to the left of the parent */
.hdr-dropdown__item--has-sub.is-flip > .hdr-dropdown--sub,
.hdr-dropdown > .hdr-dropdown__item--has-sub:nth-last-child(-n+2) > .hdr-dropdown--sub {
    /* Opt-in flip via .is-flip (JS can set it). The :nth-last-child safety net is a no-op unless CSS is used. */
}

/* ── Right section (phone + CTA) ── */
.hdr-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.hdr-phone {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: color 0.2s var(--hdr-ease);
}

.hdr-phone-icon {
    width: 32px;
    height: 32px;
    border-radius: 9999px;
    background: var(--hdr-line);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s var(--hdr-ease), transform 0.3s var(--hdr-ease);
}

.hdr-phone-icon svg {
    width: 16px;
    height: 16px;
    color: var(--hdr-ink-soft);
    transition: color 0.2s var(--hdr-ease);
}

.hdr-phone:hover .hdr-phone-icon {
    background: rgba(1, 191, 90, 0.12);
    transform: rotate(-8deg);
}

.hdr-phone:hover .hdr-phone-icon svg {
    color: var(--hdr-brand-dark);
}

.hdr-phone-number {
    font-family: "Roboto", sans-serif;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.01em;
    color: var(--hdr-ink-soft);
    white-space: nowrap;
    transition: color 0.2s var(--hdr-ease);
}

.hdr-phone:hover .hdr-phone-number {
    color: var(--hdr-ink);
}

.hdr-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 22px;
    border-radius: 9999px;
    background: var(--hdr-brand);
    color: #ffffff;
    font-family: "Roboto", sans-serif;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.01em;
    text-decoration: none;
    white-space: nowrap;
    box-shadow:
        0 1px 2px rgba(1, 191, 90, 0.25),
        0 4px 12px rgba(1, 191, 90, 0.22);
    transition:
        background 0.2s var(--hdr-ease),
        box-shadow 0.2s var(--hdr-ease),
        transform 0.2s var(--hdr-ease);
}

.hdr-cta:hover,
.hdr-cta:focus,
.hdr-cta:active {
    text-decoration: none;
}

.hdr-cta:hover {
    background: var(--hdr-brand-dark);
    box-shadow:
        0 2px 4px rgba(1, 191, 90, 0.3),
        0 8px 20px rgba(1, 191, 90, 0.32);
    color: #ffffff;
    transform: translateY(-1px);
}

.hdr-cta:active {
    transform: translateY(0);
}

/* ── Hide old elements ── */
.header-inner-desktop {
    display: none;
}

.header-inner-widget {
    display: none;
}

.btn-mobile-menu {
    display: none;
}

/* ── Mobile overlay ── */
.hdr-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.hdr-overlay.is-active {
    opacity: 1;
}

/* ── Mobile icon buttons (phone, quote, hamburger) — match the desktop .hdr-phone-icon chip style ── */
.hdr-icon-btn {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    border-radius: 9999px;
    background: var(--hdr-line);
    color: var(--hdr-ink-soft);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    position: relative;
    outline: none;
    transition:
        background 0.2s var(--hdr-ease),
        color 0.2s var(--hdr-ease),
        transform 0.3s var(--hdr-ease);
}

.hdr-icon-btn:hover {
    background: rgba(1, 191, 90, 0.12);
    color: var(--hdr-brand-dark);
    transform: rotate(-8deg);
}

.hdr-icon-btn:active {
    transform: rotate(-8deg);
}

.hdr-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Hamburger-specific: must sit above the open mobile panel */
.hdr-hamburger {
    z-index: 102;
}

.hdr-hamburger svg {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hdr-hamburger .hdr-hamburger-x {
    position: absolute;
    transform: rotate(90deg);
    opacity: 0;
}

.hdr-hamburger.is-active .hdr-hamburger-bars {
    transform: rotate(90deg);
    opacity: 0;
}

.hdr-hamburger.is-active .hdr-hamburger-x {
    transform: rotate(0deg);
    opacity: 1;
}

/* ── Mobile menu panel ── */
.hdr-mobile {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    padding: 0 24px;
    z-index: 101;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease, border-top-color 0.35s ease;
    border-top: 1px solid transparent;
}

.hdr-mobile.is-open {
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    border-top-color: #E4E4E7;
}

.hdr-mobile-list {
    list-style: none;
    margin: 0 0 24px 0;
    padding: 0;
}

.hdr-mobile-list li {
    margin: 0;
    padding: 0;
}

.hdr-mobile-list > li > a,
.hdr-mobile-list > li > .hdr-mobile-toggle {
    font-family: "Roboto", sans-serif;
    font-weight: 500;
    font-size: 16px;
    line-height: 24px;
    color: #0A0A0A;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid #F4F4F5;
    cursor: pointer;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid #F4F4F5;
    width: 100%;
    text-align: left;
    outline: none;
}

.hdr-mobile-list > li > a:hover {
    color: #01BF5A;
}

.hdr-mobile-chevron {
    width: 16px;
    height: 16px;
    color: #A1A1AA;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.hdr-mobile-chevron.is-expanded {
    transform: rotate(180deg);
}

/* Mobile sub-menu */
.hdr-mobile-sub {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.hdr-mobile-sub.is-open {
    max-height: 600px;
}

.hdr-mobile-sub li {
    margin: 0;
    padding: 0;
}

.hdr-mobile-sub a {
    font-family: "Roboto", sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
    color: #52525B;
    text-decoration: none;
    display: block;
    padding: 10px 0 10px 16px;
    border-bottom: 1px solid #F9F9FA;
    transition: color 0.15s ease;
}

.hdr-mobile-sub a:hover {
    color: #0A0A0A;
}

/* Mobile CTA */
.hdr-mobile-cta {
    display: block;
    width: 100%;
    height: 48px;
    line-height: 48px;
    text-align: center;
    border-radius: 9999px;
    background: #01BF5A;
    color: #ffffff;
    font-family: "Roboto", sans-serif;
    font-weight: 500;
    font-size: 16px;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(1, 191, 90, 0.3);
    transition: background 0.15s ease;
    margin-top: 8px;
}

.hdr-mobile-cta:hover {
    background: #00A34D;
    color: #ffffff;
}

/* ── Responsive: tighten nav before it cramps (desktop with many menu items) ── */
@media screen and (max-width: 1080px) {
    .hdr-container {
        padding: 0 18px;
    }

    .hdr-nav-list {
        gap: 14px;
    }

    .hdr-right {
        gap: 10px;
    }

    .hdr-cta {
        height: 38px;
        padding: 0 16px;
    }
}

/* Below this, the phone number text starts to push the nav into the CTA — collapse to icon-only */
@media screen and (max-width: 960px) {
    .hdr-nav-list {
        gap: 10px;
    }

    .hdr-phone-number {
        display: none;
    }

    .hdr-phone {
        gap: 0;
    }
}

/* ── Responsive: tablet and below ── */
@media screen and (max-width: 900px) {
    .hdr-nav {
        display: none;
    }

    .hdr-phone {
        display: none;
    }

    .hdr-cta {
        display: none;
    }

    .hdr-icon-btn {
        display: inline-flex;
    }

    .hdr-right {
        gap: 8px;
    }

    .hdr-overlay {
        display: block;
        pointer-events: none;
    }

    .hdr-overlay.is-active {
        pointer-events: auto;
    }

    .hdr-mobile {
        display: block;
    }

    .hdr-container {
        padding: 0 16px;
        height: 70px;
    }
}

/* Narrowest screens */
@media screen and (max-width: 375px) {
    .hdr-brand-logo {
        height: 40px;
    }

    .hdr-container {
        padding: 0 12px;
    }
}

/* ── Accessibility ── */
@media (prefers-reduced-motion: reduce) {
    .hdr-dropdown,
    .hdr-mobile-sub,
    .hdr-hamburger svg,
    .hdr-overlay {
        transition: none;
    }
}

/* Mouse focus: no outline. Keyboard focus-visible: branded ring. */
.hdr-brand:focus,
.hdr-nav a:focus,
.hdr-nav button:focus,
.hdr-cta:focus,
.hdr-phone:focus,
.hdr-hamburger:focus,
.hdr-mobile a:focus,
.hdr-mobile button:focus,
.hdr-mobile-cta:focus,
.hdr-overlay:focus {
    outline: none;
}

.hdr-brand:focus-visible,
.hdr-nav a:focus-visible,
.hdr-nav button:focus-visible,
.hdr-phone:focus-visible,
.hdr-mobile a:focus-visible,
.hdr-mobile button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(1, 191, 90, 0.25);
    border-radius: 4px;
}

.hdr-cta:focus-visible,
.hdr-mobile-cta:focus-visible,
.hdr-hamburger:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(1, 191, 90, 0.25),
        0 2px 8px rgba(1, 191, 90, 0.3);
}
