/*
 * Global header/navigation stylesheet.
 *
 * Every rule below is ported unchanged from site.legacy.css, reassembled in
 * its original cascade order (base rules, then the "2026 institutional
 * redesign" overrides, then the "premium mega navigation" overrides) so the
 * final computed styles match the approved static build exactly. See
 * assets/css/legacy/site.legacy.css for the untouched source.
 *
 * Loaded globally because header.php renders on every template.
 */

/* --- Page loader (final, non-blocking brand-loader version) --- */
.js .page-loader { display: block; position: fixed; z-index: 9998; inset: 0 0 auto; height: 3px; background: transparent; pointer-events: none; }
.page-loader img { display: none; }
.page-loader::after { content: ""; display: block; width: 38%; height: 100%; background: linear-gradient(90deg, var(--green), #9ed2bd); box-shadow: 0 0 16px rgba(95,155,133,.65); animation: loaderTrack .85s var(--ease) infinite; }
.page-loader.is-hidden { opacity: 0; visibility: hidden; }
@keyframes loaderTrack { from { transform: translateX(-110%); } to { transform: translateX(370%); } }

/* --- Base header/nav structure --- */
.site-header { position: relative; z-index: 100; background: rgba(247, 244, 238, .94); }
.utility-bar { background: var(--navy); color: rgba(255,255,255,.78); font-size: .78rem; }
.utility-inner { display: flex; min-height: 38px; align-items: center; justify-content: space-between; gap: 24px; }
.utility-inner div { display: flex; gap: 24px; }
.utility-inner a { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; transition: color .2s; }
.utility-inner a:hover { color: var(--white); }
.utility-inner .icon { width: 15px; height: 15px; }
.nav-wrap { border-bottom: 1px solid rgba(8,29,51,.09); }
.nav-inner { display: flex; min-height: 94px; align-items: center; justify-content: space-between; gap: 32px; }
.brand { flex: 0 0 auto; }
.brand img { width: 300px; }
.site-nav { display: flex; align-items: center; gap: 26px; }
.site-nav > a:not(.button) { position: relative; color: var(--navy); font-size: .9rem; font-weight: 700; text-decoration: none; }
.site-nav > a:not(.button)::after { content: ""; position: absolute; left: 0; right: 100%; bottom: -9px; height: 2px; background: var(--green); transition: right .3s var(--ease); }
.site-nav > a:hover::after, .site-nav > a[aria-current="page"]::after { right: 0; }
.menu-toggle { display: none; border: 0; background: transparent; color: var(--navy); font-weight: 800; }
.menu-toggle .icon { width: 25px; height: 25px; }

@media (max-width: 1060px) {
    .brand img { width: 250px; }
    .site-nav { gap: 16px; }
    .site-nav > a:not(.button) { font-size: .82rem; }
}

@media (max-width: 820px) {
    .utility-inner > p { display: none; }
    .utility-inner { justify-content: flex-end; }
    .nav-inner { min-height: 80px; }
    .brand img { width: 228px; }
    .js .menu-toggle { display: inline-flex; align-items: center; gap: 8px; }
    .site-nav { display: grid; gap: 0; width: 100%; padding: 18px 0 26px; }
    .js .site-nav { position: absolute; top: 100%; left: 0; right: 0; padding-inline: 20px; border-bottom: 1px solid var(--stone); background: var(--ivory); box-shadow: var(--shadow-sm); visibility: hidden; opacity: 0; transform: translateY(-10px); transition: .25s var(--ease); }
    .js .site-nav.is-open { visibility: visible; opacity: 1; transform: none; }
    .site-nav > a:not(.button) { padding: 13px 4px; font-size: .95rem; }
    .site-nav > a:not(.button)::after { bottom: 8px; }
    .site-nav .button { margin-top: 10px; }
}

@media (max-width: 600px) {
    .utility-inner a:last-child { display: none; }
    .brand img { width: 210px; }
    .menu-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* --- 2026 institutional redesign: sticky header, mega-menu groups --- */
.site-header { position: sticky; top: 0; backdrop-filter: blur(18px); transition: box-shadow .3s var(--ease); }
.site-header.is-scrolled { box-shadow: 0 15px 45px rgba(8,29,51,.12); }
.utility-bar { max-height: 38px; overflow: hidden; transition: max-height .35s var(--ease), opacity .25s; }
.site-header.is-scrolled .utility-bar { max-height: 0; opacity: 0; }
.site-header.is-scrolled .nav-inner { min-height: 72px; }
.nav-inner { transition: min-height .35s var(--ease); }
.site-nav { gap: 21px; }
.nav-group { position: relative; }
.nav-parent { position: relative; padding: 12px 0; border: 0; background: transparent; color: var(--navy); font-size: .9rem; font-weight: 800; cursor: pointer; }
.nav-parent::after { content: ""; position: absolute; left: 0; right: 100%; bottom: 5px; height: 2px; background: var(--green); transition: right .3s var(--ease); }
.nav-group:is(:hover,:focus-within,.is-open,.is-current) .nav-parent::after { right: 0; }
.nav-parent span { display: inline-block; margin-left: 3px; transition: transform .25s; }
.nav-group:is(:hover,:focus-within,.is-open) .nav-parent span { transform: rotate(180deg); }
.nav-dropdown { position: absolute; top: calc(100% + 10px); left: -22px; display: grid; width: 310px; padding: 12px; border: 1px solid rgba(8,29,51,.09); border-radius: 20px; background: rgba(255,255,255,.98); box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-8px); transition: .25s var(--ease); }
.nav-group:is(:hover,:focus-within,.is-open) .nav-dropdown { opacity: 1; visibility: visible; transform: none; }
.nav-dropdown a { display: grid; padding: 13px 14px; border-radius: 13px; color: var(--navy); text-decoration: none; }
.nav-dropdown a:hover, .nav-dropdown a[aria-current="page"] { background: var(--sage); }
.nav-dropdown strong { font-size: .88rem; }
.nav-dropdown span { color: var(--slate); font-size: .72rem; font-weight: 500; }
.urgent-nav { display: inline-flex; align-items: center; gap: 7px; color: #a83b35 !important; }
.urgent-nav > span { width: 8px; height: 8px; border-radius: 50%; background: #d55249; box-shadow: 0 0 0 0 rgba(213,82,73,.45); animation: urgentPulse 1.8s infinite; }
@keyframes urgentPulse { 70% { box-shadow: 0 0 0 9px rgba(213,82,73,0); } 100% { box-shadow: 0 0 0 0 rgba(213,82,73,0); } }
.nav-parent:focus-visible, .site-nav a:focus-visible { outline: 3px solid #7fc5f0; outline-offset: 4px; }

@media (max-width: 1120px) {
    .site-nav { gap: 14px; }
    .site-nav > a:not(.button), .nav-parent { font-size: .8rem; }
}

@media (max-width: 820px) {
    .site-header.is-scrolled .nav-inner { min-height: 66px; }
    .site-nav { align-items: stretch; }
    .nav-group { border-bottom: 1px solid var(--stone); }
    .nav-parent { width: 100%; display: flex; justify-content: space-between; padding: 14px 4px; font-size: .95rem; text-align: left; }
    .nav-dropdown { position: static; width: 100%; max-height: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; opacity: 1; visibility: hidden; overflow: hidden; transform: none; background: transparent; transition: max-height .3s var(--ease); }
    .nav-group.is-open .nav-dropdown { max-height: 320px; padding: 0 0 10px; visibility: visible; }
    .nav-dropdown a { padding: 10px 14px; }
}

/* --- Content-strategy navigation refinements --- */
@media (min-width: 1121px) {
    .site-nav { gap: 16px; }
    .site-nav > a:not(.button), .nav-parent { font-size: .82rem; }
}
@media (min-width: 981px) {
    .nav-dropdown.services-dropdown { right: -60px; left: auto; width: min(720px, 78vw); }
}
@media (max-width: 980px) {
    .nav-group.is-open .nav-dropdown { max-height: 560px; }
    .nav-group.is-open .services-dropdown { max-height: 850px; }
}

@media (min-width: 821px) and (max-width: 1240px) {
    .nav-inner { gap: 20px; }
    .brand img { width: 270px; }
    .site-nav { gap: 12px; }
    .site-nav > a:not(.button), .nav-parent { font-size: .76rem; }
    .site-nav .button-small { padding-inline: 15px; }
}

/* --- Final cascade override: services dropdown width at desktop --- */
@media (min-width: 981px) {
    .nav-dropdown.services-dropdown {
        left: -210px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: min(680px, 78vw);
    }
}
@media (max-width: 980px) {
    .nav-dropdown.services-dropdown { width: 100%; grid-template-columns: 1fr; }
    .nav-group.is-open .services-dropdown { max-height: 680px; }
}
@media (min-width: 981px) and (max-width: 1120px) {
    .nav-dropdown.services-dropdown { left: -330px; }
}

/* --- 2026-09-18 premium mega navigation --- */
.mega-menu-intro,
.mega-menu-grid { min-width: 0; }
.mega-menu-intro p,
.mega-menu-intro strong,
.mega-menu-intro span,
.mega-link-copy strong,
.mega-link-copy small { display: block; }

@media (min-width: 981px) {
    .nav-dropdown,
    .nav-dropdown.services-dropdown {
        top: calc(100% + 14px);
        left: auto;
        display: block;
        padding: 0;
        overflow: visible;
        border: 1px solid rgba(95,155,133,.38);
        border-radius: 27px;
        background:
            radial-gradient(circle at 8% 0%, rgba(130,192,167,.15), transparent 30%),
            linear-gradient(145deg, rgba(255,255,255,.99), rgba(245,249,247,.985));
        box-shadow:
            0 34px 90px rgba(8,29,51,.24),
            0 8px 24px rgba(8,29,51,.1),
            inset 0 0 0 1px rgba(255,255,255,.9);
        opacity: 0;
        visibility: hidden;
        transform: translateY(14px) scale(.985);
        transform-origin: 50% 0;
        transition: opacity .24s ease, visibility .24s ease, transform .34s var(--ease);
    }
    .nav-dropdown.foundation-dropdown { left: -300px; width: min(850px, 76vw); }
    .nav-dropdown.services-dropdown { right: -420px; width: min(980px, 86vw); }
    .nav-dropdown::before {
        content: "";
        position: absolute;
        right: 0;
        bottom: 100%;
        left: 0;
        height: 16px;
    }
    .nav-dropdown::after {
        content: "";
        position: absolute;
        z-index: 4;
        top: -1px;
        right: 28px;
        left: 28px;
        height: 3px;
        border-radius: 0 0 999px 999px;
        background: linear-gradient(90deg, transparent, #6fb397 26%, #1f5f51 50%, #6fb397 74%, transparent);
        box-shadow: 0 0 20px rgba(95,155,133,.58);
    }
    .nav-group:is(:hover,:focus-within,.is-open) .nav-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
    }
    .mega-menu-intro {
        position: relative;
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 18px;
        overflow: hidden;
        min-height: 120px;
        padding: 24px 26px;
        border-bottom: 1px solid rgba(8,29,51,.1);
        border-radius: 26px 26px 0 0;
        background:
            linear-gradient(110deg, rgba(8,29,51,.98), rgba(18,73,65,.96)),
            var(--navy);
    }
    .mega-menu-intro::after {
        content: "RAF";
        position: absolute;
        right: 18px;
        bottom: -31px;
        color: rgba(255,255,255,.045);
        font: 800 7.5rem/1 var(--serif);
        letter-spacing: -.08em;
        pointer-events: none;
    }
    .foundation-dropdown .mega-menu-intro { grid-template-columns: auto 1fr; }
    .mega-menu-mark {
        position: relative;
        z-index: 1;
        display: grid !important;
        width: 62px;
        height: 62px;
        place-items: center;
        border: 1px solid rgba(186,226,209,.3);
        border-radius: 20px;
        background: rgba(255,255,255,.08);
        box-shadow: inset 0 1px rgba(255,255,255,.12), 0 12px 28px rgba(0,0,0,.17);
    }
    .mega-menu-mark img { width: 42px; filter: brightness(0) invert(1); opacity: .92; }
    .mega-menu-intro > div { position: relative; z-index: 1; }
    .mega-menu-intro .mega-menu-kicker {
        color: #a9d8c5;
        font-size: .65rem;
        font-weight: 900;
        letter-spacing: .14em;
        text-transform: uppercase;
    }
    .mega-menu-intro > div > strong { margin-top: 4px; color: var(--white); font: 700 1.25rem/1.25 var(--serif); }
    .mega-menu-intro p { margin-top: 5px; color: rgba(255,255,255,.65); font-size: .72rem; line-height: 1.45; }
    .mega-menu-feature {
        position: relative;
        z-index: 2;
        display: inline-flex !important;
        min-height: 40px;
        align-items: center;
        gap: 8px;
        padding: 10px 14px !important;
        border: 1px solid rgba(255,255,255,.19) !important;
        border-radius: 999px !important;
        background: rgba(255,255,255,.09) !important;
        color: var(--white) !important;
        font-size: .7rem;
        font-weight: 800;
        white-space: nowrap;
        box-shadow: none !important;
    }
    .mega-menu-feature:hover { background: rgba(255,255,255,.16) !important; transform: translateY(-2px); }
    .mega-menu-feature .icon { width: 15px; height: 15px; }
    .mega-menu-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0,1fr));
        gap: 9px;
        padding: 14px;
    }
    .institutions-menu-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .nav-dropdown .mega-menu-grid > a {
        position: relative;
        display: grid;
        grid-template-columns: 43px minmax(0,1fr) 18px;
        align-items: center;
        gap: 12px;
        min-height: 78px;
        padding: 12px 13px;
        overflow: hidden;
        border: 1px solid rgba(8,29,51,.075);
        border-radius: 17px;
        background: rgba(255,255,255,.72);
        color: var(--navy);
        opacity: 0;
        transform: translateY(10px);
        transition:
            opacity .25s ease,
            transform .34s var(--ease),
            border-color .3s ease,
            background .3s ease,
            box-shadow .3s ease;
    }
    .nav-dropdown .mega-menu-grid > a::before {
        content: "";
        position: absolute;
        top: -50%;
        bottom: -50%;
        left: -42%;
        width: 28%;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,.9), transparent);
        transform: skewX(-18deg);
        transition: left .7s var(--ease);
        pointer-events: none;
    }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a { opacity: 1; transform: none; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(2) { transition-delay: .025s; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(3) { transition-delay: .05s; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(4) { transition-delay: .075s; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(5) { transition-delay: .1s; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(6) { transition-delay: .125s; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(7) { transition-delay: .15s; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(8) { transition-delay: .175s; }
    .nav-group:is(:hover,:focus-within,.is-open) .mega-menu-grid > a:nth-child(9) { transition-delay: .2s; }
    .nav-dropdown .mega-menu-grid > a:hover,
    .nav-dropdown .mega-menu-grid > a:focus-visible,
    .nav-dropdown .mega-menu-grid > a[aria-current="page"] {
        z-index: 2;
        border-color: rgba(74,145,119,.55);
        background: linear-gradient(135deg, #fff, #edf7f2);
        box-shadow: 0 12px 30px rgba(8,29,51,.12), 0 0 0 3px rgba(95,155,133,.09), 0 0 25px rgba(95,155,133,.13);
        transform: translateY(-3px) translateX(2px);
    }
    .nav-dropdown .mega-menu-grid > a:hover::before { left: 118%; }
    .mega-link-icon {
        position: relative;
        display: grid !important;
        width: 43px;
        height: 43px;
        place-items: center;
        border: 1px solid rgba(95,155,133,.22);
        border-radius: 14px;
        background: linear-gradient(145deg, #eff7f3, #e1eee8);
        color: var(--forest) !important;
        transition: color .3s, background .3s, transform .35s var(--ease), box-shadow .3s;
    }
    .mega-link-icon .icon { width: 21px; height: 21px; }
    .mega-menu-grid > a:hover .mega-link-icon,
    .mega-menu-grid > a:focus-visible .mega-link-icon,
    .mega-menu-grid > a[aria-current="page"] .mega-link-icon {
        color: var(--white) !important;
        background: linear-gradient(145deg, #285f50, #65a58d);
        box-shadow: 0 8px 19px rgba(50,107,87,.26), 0 0 18px rgba(95,155,133,.18);
        transform: translateY(-2px) rotate(-3deg) scale(1.04);
    }
    .mega-link-copy { min-width: 0; color: inherit !important; }
    .mega-link-copy strong { color: var(--navy); font: 800 .78rem/1.25 var(--sans); letter-spacing: -.015em; }
    .mega-link-copy small { margin-top: 4px; color: var(--slate); font-size: .63rem; font-weight: 520; line-height: 1.35; }
    .mega-link-arrow {
        display: grid !important;
        width: 18px;
        height: 18px;
        place-items: center;
        color: rgba(8,29,51,.28) !important;
        transform: translateX(-3px);
        transition: color .3s, transform .35s var(--ease);
    }
    .mega-link-arrow .icon { width: 16px; height: 16px; }
    .mega-menu-grid > a:hover .mega-link-arrow,
    .mega-menu-grid > a:focus-visible .mega-link-arrow,
    .mega-menu-grid > a[aria-current="page"] .mega-link-arrow { color: var(--forest) !important; transform: translateX(2px); }
}

@media (min-width: 981px) and (max-width: 1180px) {
    .nav-dropdown.foundation-dropdown { left: -250px; width: min(800px, 78vw); }
    .nav-dropdown.services-dropdown { right: -330px; width: min(930px, 90vw); }
    .mega-menu-grid { gap: 7px; padding: 12px; }
    .nav-dropdown .mega-menu-grid > a { min-height: 74px; padding: 10px; }
}

@media (max-width: 980px) {
    .nav-dropdown.foundation-dropdown,
    .nav-dropdown.services-dropdown { width: 100%; }
    .nav-dropdown .mega-menu-intro { display: none; }
    .nav-dropdown .mega-menu-grid,
    .nav-dropdown .institutions-menu-grid { display: grid; grid-template-columns: 1fr; gap: 5px; padding: 5px 0 10px; }
    .nav-dropdown .mega-menu-grid > a {
        display: grid;
        grid-template-columns: 38px minmax(0,1fr) 16px;
        align-items: center;
        gap: 11px;
        padding: 10px 12px;
        border: 1px solid transparent;
        border-radius: 14px;
        background: rgba(255,255,255,.45);
    }
    .nav-dropdown .mega-menu-grid > a:hover,
    .nav-dropdown .mega-menu-grid > a[aria-current="page"] { border-color: rgba(95,155,133,.28); background: var(--sage); }
    .mega-link-icon { display: grid !important; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: rgba(95,155,133,.12); color: var(--forest) !important; }
    .mega-link-icon .icon { width: 19px; height: 19px; }
    .mega-link-copy { color: inherit !important; }
    .mega-link-copy strong { color: var(--navy); font-size: .8rem; }
    .mega-link-copy small { margin-top: 2px; color: var(--slate); font-size: .66rem; }
    .mega-link-arrow { display: grid !important; color: var(--forest) !important; }
    .mega-link-arrow .icon { width: 14px; height: 14px; }
    .nav-group.is-open .foundation-dropdown { max-height: 650px; }
    .nav-group.is-open .services-dropdown { max-height: 930px; }
}
