/* ============================================================
   ml-header-footer.css — Miracle Leaf canonical Header + Footer
   ------------------------------------------------------------
   Mobile-first. References brand tokens declared in
   ml-brand-typography.php (:root) — never hardcode hex.
   Pairs with markup in elements/site-header.html +
   elements/site-footer.html, enqueued by
   ml-header-footer-styles.php.
   ------------------------------------------------------------
   Tokens used:
     --ml-brand-dark        (#4b6e34)
     --ml-brand-primary     (#86bf3e)
     --ml-gradient-start    (#6c983d)
     --ml-gradient-end      (#8fc943)
     --ml-brand-ink         (#1a2614)
     --ml-brand-surface     (#ffffff)
     --ml-brand-surface-alt (#f4f7f0)
   ============================================================ */

/* ---------- Global anchor offset (matches sticky header height) -------- */
html {
    scroll-padding-top: 6rem;
}

/* ============================================================
   Header — .ml-site-header
   Sticky + minimal (no JS, no transitions). Stacks <768px;
   bar layout >=768px.
   ============================================================ */

.ml-site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--ml-brand-surface);
    border-bottom: 1px solid var(--ml-brand-surface-alt);
    box-shadow: 0 1px 0 rgba(26, 38, 20, 0.04);
}

.ml-site-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
}

.ml-site-header__brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--ml-brand-dark);
    font-weight: 700;
    text-decoration: none;
}

.ml-site-header__brand img,
.ml-site-header__brand svg {
    /* Horizontal logo native = 250x67 (≈3.73:1). Sized via height + auto width
       so aspect ratio is preserved. Tuned to fit the 4rem header inner min-height
       with breathing room above + below. */
    height: 2.75rem;
    width: auto;
    max-width: 12rem;
    display: block;
}

.ml-site-header__brand:focus-visible {
    outline: 2px solid var(--ml-brand-primary);
    outline-offset: 3px;
    border-radius: var(--ml-radius-sm, 4px);
}

/* ---------- Mobile menu toggle (hamburger) ----------
   Visible <768px, hidden >=768px. WCAG: 44x44 hit target. */
.ml-mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 1px solid var(--ml-brand-dark);
    border-radius: var(--ml-radius-sm, 4px);
    color: var(--ml-brand-dark);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ml-mobile-toggle:focus-visible {
    outline: 2px solid var(--ml-brand-primary);
    outline-offset: 2px;
}

.ml-mobile-toggle .ml-mobile-toggle__bars,
.ml-mobile-toggle .ml-mobile-toggle__bars::before,
.ml-mobile-toggle .ml-mobile-toggle__bars::after {
    display: block;
    width: 1.25rem;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    position: relative;
}

.ml-mobile-toggle .ml-mobile-toggle__bars::before,
.ml-mobile-toggle .ml-mobile-toggle__bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.ml-mobile-toggle .ml-mobile-toggle__bars::before { top: -6px; }
.ml-mobile-toggle .ml-mobile-toggle__bars::after  { top:  6px; }

.ml-mobile-toggle[aria-expanded="true"] .ml-mobile-toggle__bars {
    background: transparent;
}
.ml-mobile-toggle[aria-expanded="true"] .ml-mobile-toggle__bars::before {
    top: 0;
    transform: rotate(45deg);
}
.ml-mobile-toggle[aria-expanded="true"] .ml-mobile-toggle__bars::after {
    top: 0;
    transform: rotate(-45deg);
}

/* ---------- Primary nav ----------
   Mobile: slide-in left drawer.
   Desktop: inline horizontal list. */
.ml-primary-nav {
    /* container queries not required — nav itself is invisible until JS toggles */
}

.ml-primary-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ml-primary-nav__list a {
    display: block;
    padding: 0.85rem 1rem;
    color: var(--ml-brand-ink);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--ml-radius-sm, 4px);
}

.ml-primary-nav__list a:hover,
.ml-primary-nav__list a:focus-visible {
    background: var(--ml-brand-surface-alt);
    color: var(--ml-brand-dark);
}

.ml-primary-nav__list a:focus-visible {
    outline: 2px solid var(--ml-brand-primary);
    outline-offset: 2px;
}

/* Active page indicator — underline driven by aria-current="page" */
.ml-primary-nav__list :where([aria-current="page"]) {
    color: var(--ml-brand-dark);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--ml-brand-primary);
    text-decoration-thickness: 3px;
    text-underline-offset: 6px;
}

/* ---------- Header CTAs ---------- */
.ml-header-ctas {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ml-nav-cta-phone,
.ml-nav-cta-schedule {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    min-height: 2.75rem;
    border-radius: 999px;
    font-family: 'Optician Sans', 'Ridley Grotesk', 'Barlow', Arial, sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}

.ml-nav-cta-phone {
    color: var(--ml-brand-dark);
    background: var(--ml-brand-surface);
    border: 2px solid var(--ml-brand-dark);
}
.ml-nav-cta-phone:hover,
.ml-nav-cta-phone:focus-visible {
    background: var(--ml-brand-surface-alt);
}

.ml-nav-cta-schedule {
    color: var(--ml-brand-surface);
    background: linear-gradient(45deg, var(--ml-gradient-start) 0%, var(--ml-gradient-end) 100%);
    border: 2px solid transparent;
}
.ml-nav-cta-schedule:hover,
.ml-nav-cta-schedule:focus-visible {
    filter: brightness(0.95);
}

.ml-nav-cta-phone:focus-visible,
.ml-nav-cta-schedule:focus-visible {
    outline: 2px solid var(--ml-brand-primary);
    outline-offset: 3px;
}

/* ============================================================
   Submenus (multi-level Main Menu)
   ------------------------------------------------------------
   Markup contract (emitted by ML_Primary_Nav_Walker):
     <li class="ml-has-submenu">
       <a href="...">Parent</a>
       <button class="ml-submenu-toggle" aria-expanded="false">+</button>
       <ul class="sub-menu" data-depth="1">
         <li>...</li>
       </ul>
     </li>
   Desktop: reveal on :hover / :focus-within (no JS required).
   Mobile:  accordion via JS toggling [data-open] on the parent <li>.
   ============================================================ */

.ml-has-submenu {
    position: relative;
}

.ml-submenu-toggle {
    /* Hidden on desktop (CSS dropdown handles it). Visible <768px. */
    display: none;
    background: transparent;
    border: 0;
    color: var(--ml-brand-dark);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    margin: 0;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.ml-submenu-toggle:focus-visible {
    outline: 2px solid var(--ml-brand-primary);
    outline-offset: 2px;
    border-radius: var(--ml-radius-sm, 4px);
}

.ml-submenu-toggle[aria-expanded="true"] > span {
    transform: rotate(45deg);
    display: inline-block;
}

.ml-primary-nav__list .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ml-primary-nav__list .sub-menu a {
    padding: 0.55rem 1rem;
    font-size: 0.92rem;
    font-weight: 400;
}

/* ============================================================
   Mobile (<768px) — slide-in drawer
   ============================================================ */

@media (max-width: 767.98px) {
    .ml-site-header__inner {
        padding: 0.65rem 0.85rem;
    }

    .ml-mobile-toggle {
        display: inline-flex;
    }

    /* Schedule CTA collapses out of header on small screens to save room.
       Phone CTA stays per decision #3 (always show pill). */
    .ml-nav-cta-schedule {
        display: none;
    }

    .ml-primary-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(85vw, 22rem);
        background: var(--ml-brand-surface);
        box-shadow: 2px 0 24px rgba(26, 38, 20, 0.18);
        padding: 4.5rem 1rem 2rem;
        overflow-y: auto;
        transform: translateX(-100%);
        z-index: 1100;
    }

    .ml-primary-nav[data-open="true"] {
        transform: translateX(0);
    }

    .ml-primary-nav__list a {
        padding: 1rem;
        font-size: 1.05rem;
        border-bottom: 1px solid var(--ml-brand-surface-alt);
    }

    /* --- Mobile accordion for submenus --- */
    .ml-has-submenu {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }
    .ml-has-submenu > a {
        flex: 1 1 auto;
    }
    .ml-submenu-toggle {
        display: inline-flex;
    }
    /* Submenus collapsed by default */
    .ml-primary-nav__list .sub-menu {
        flex: 1 0 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.2s ease;
        background: var(--ml-brand-surface-alt);
    }
    .ml-has-submenu[data-open="true"] > .sub-menu {
        max-height: 80vh;
        overflow-y: auto;
    }
    .ml-primary-nav__list .sub-menu a {
        padding-left: 2rem;
        font-size: 1rem;
    }
    .ml-primary-nav__list .sub-menu .sub-menu a {
        padding-left: 3rem;
        font-size: 0.95rem;
    }

    /* In-drawer Schedule CTA (since the header pill is hidden) */
    .ml-primary-nav__drawer-cta {
        display: block;
        margin-top: 1.5rem;
    }

    .ml-primary-nav__drawer-cta .ml-nav-cta-schedule {
        display: inline-flex;
        width: 100%;
    }

    /* Scrim */
    .ml-mobile-scrim {
        position: fixed;
        inset: 0;
        background: rgba(26, 38, 20, 0.45);
        z-index: 1050;
        opacity: 0;
        pointer-events: none;
    }

    .ml-mobile-scrim[data-open="true"] {
        opacity: 1;
        pointer-events: auto;
    }

    /* Body lock when drawer open */
    body.ml-drawer-open {
        overflow: hidden;
    }
}

/* ============================================================
   Desktop (>=768px) — inline nav, hide toggle, hide scrim
   ============================================================ */

@media (min-width: 768px) {
    .ml-mobile-toggle,
    .ml-mobile-scrim,
    .ml-primary-nav__drawer-cta {
        display: none !important;
    }

    .ml-primary-nav {
        display: flex;
        align-items: center;
    }

    .ml-primary-nav__list {
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }

    .ml-primary-nav__list a {
        padding: 0.5rem 0.85rem;
    }

    /* --- Desktop dropdown --- */
    .ml-has-submenu > .sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 14rem;
        background: var(--ml-brand-surface);
        border: 1px solid var(--ml-brand-surface-alt);
        border-radius: var(--ml-radius-sm, 4px);
        box-shadow: 0 8px 24px rgba(26, 38, 20, 0.12);
        padding: 0.5rem 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(4px);
        transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
        z-index: 1200;
        max-height: 75vh;
        overflow-y: auto;
    }

    .ml-has-submenu:hover > .sub-menu,
    .ml-has-submenu:focus-within > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        transition-delay: 0s;
    }

    /* Nested submenu — fly-out to the right */
    .ml-has-submenu .ml-has-submenu > .sub-menu {
        top: 0;
        left: 100%;
    }

    .ml-primary-nav__list .sub-menu a {
        padding: 0.5rem 1rem;
        white-space: nowrap;
        border-radius: 0;
    }

    /* Caret indicator on parents */
    .ml-has-submenu > a::after {
        content: " \25BE";
        font-size: 0.75em;
        opacity: 0.7;
        margin-left: 0.25rem;
    }
    .ml-has-submenu .ml-has-submenu > a::after {
        /* nested level uses right-facing caret */
        content: " \25B8";
    }

    /* Hide the explicit toggle button on desktop — CSS handles reveal */
    .ml-submenu-toggle {
        display: none !important;
    }
}

/* ============================================================
   Footer — .ml-site-footer
   3-column layout on desktop, stack <768px.
   ============================================================ */

.ml-site-footer {
    background: var(--ml-brand-ink);
    color: var(--ml-brand-surface);
    padding: 2.5rem 0 1rem;
    margin-top: 3rem;
}

.ml-site-footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.ml-site-footer h2,
.ml-site-footer h3 {
    color: var(--ml-brand-surface);
    font-family: 'Optician Sans', 'Ridley Grotesk', 'Barlow', Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.95rem;
    margin: 0 0 1rem;
    font-weight: 400;
}

.ml-site-footer p,
.ml-site-footer li {
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.55;
    font-size: 0.92rem;
}

.ml-site-footer ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ml-site-footer li {
    /* anchors carry their own min-height padding — no extra margin needed */
    margin: 0;
}

.ml-site-footer a {
    color: var(--ml-brand-surface);
    text-decoration: underline;
    text-decoration-color: rgba(134, 191, 62, 0.6);
    text-underline-offset: 3px;
    /* WCAG 2.5.8 AA target-size minimum (24x24); we exceed to 44 for full 2.5.5
       on mobile, where stacked footer links would otherwise be 18px tall. */
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.25rem 0;
}

.ml-site-footer a:hover,
.ml-site-footer a:focus-visible {
    color: var(--ml-brand-primary);
    text-decoration-color: var(--ml-brand-primary);
}

.ml-site-footer a:focus-visible {
    outline: 2px solid var(--ml-brand-primary);
    outline-offset: 3px;
    border-radius: var(--ml-radius-sm, 4px);
}

.ml-footer-col-about p {
    margin: 0 0 0.75rem;
}

.ml-footer-col-about .ml-footer-phone {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--ml-brand-primary);
    text-decoration: none;
    font-size: 1rem;
}
.ml-footer-col-about .ml-footer-phone:hover,
.ml-footer-col-about .ml-footer-phone:focus-visible {
    color: var(--ml-brand-surface);
}

/* Bottom bar — copyright + legal */
.ml-footer-bottom {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.ml-footer-copy {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.5;
}

/* ============================================================
   Desktop footer (>=768px) — 3 columns
   ============================================================ */

@media (min-width: 768px) {
    .ml-site-footer__inner {
        grid-template-columns: 2fr 1fr 1fr;
        gap: 3rem;
        padding: 0 2rem;
    }

    .ml-footer-bottom {
        padding: 1.25rem 2rem;
    }
}

/* ============================================================
   prefers-reduced-motion respect
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .ml-primary-nav,
    .ml-mobile-scrim {
        transition: none !important;
    }
}
