/*
 * Global header / nav rebuild - hand-written, unminified (unlike the
 * compiled style.css bundle) per astro-site/CLAUDE.md's documented scoped-
 * <style> bug class: this file is linked as a plain stylesheet instead.
 * See samples/Meta investment navigation review/design_handoff_header_nav/
 * README.md for the full spec this implements.
 *
 * Brand purple intentionally stays the site's real token (#693BB8), not the
 * mockup's #5b21b6 - see the plan file / conversation for why. CTA hover
 * reuses the site's already-computed darken(7.5%) shade (#59329B, found
 * live in style.css's .btn-primary:hover) instead of the mockup's #4a1a96.
 *
 * Tokens are prefixed --mi- and defined on :root (not just `.mi-header`)
 * because the mobile drawer (`.mi-drawer`, rendered by MobileNav.astro) is a
 * DOM sibling of the header, not a descendant of it - a shared ancestor was
 * needed. The prefix avoids any collision with Bootstrap's own --primary/
 * --secondary/gray custom properties already on :root.
 */
:root {
  --mi-purple: #693BB8;
  --mi-purple-dark: #59329B;
  --mi-focus-ring: rgba(105, 59, 184, .25);
  --mi-ink: #1a1820;
  --mi-ink-body: #2a2733;
  --mi-grey-text: #56525f;
  --mi-grey-muted: #6b6875;
  --mi-icon-stroke: #8b8794;
  --mi-divider: #cfccd8;
  --mi-border: #e0dde8;
  --mi-border-input: #d5d1de;
  --mi-strip-bg: #f7f6f9;
  --mi-strip-border: #ebe8f0;
  --mi-hover-bg: #f4f2f8;
  --mi-child-bg: #faf9fc;
}

/* ---------- Shared resets ---------- */
.mi-header, .mi-drawer {
  font-family: "PT Sans", Helvetica, Arial, sans-serif, -apple-system;
}
.mi-header *, .mi-drawer * {
  box-sizing: border-box;
}
.mi-header a, .mi-drawer a,
.mi-header button, .mi-drawer button {
  text-decoration: none;
}
.mi-header button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}
.mi-header :focus-visible, .mi-drawer :focus-visible {
  outline: 2px solid var(--mi-purple);
  outline-offset: 2px;
}
.mi-icon-stroke, .mi-strip__icon {
  color: var(--mi-icon-stroke);
  flex-shrink: 0;
}

/* Sentinel used by the sticky-shadow IntersectionObserver (scripts.js) */
.mi-sentinel {
  height: 1px;
}

/* Mobile (<900px): the whole 88px header sticks as one unit - see
   design_handoff_header_nav README.md, "Collapsed bar": "Sticky, same as
   desktop. The whole 88px sticks; do not shrink-on-scroll." Desktop
   (>=900px) instead sticks only the 72px nav bar band - see the
   min-width:900px block below, which sets this back to `static` and moves
   the sticky/stuck-shadow rules onto `.mi-navbar`. */
.mi-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  transition: box-shadow .18s ease;
}
.mi-header.mi-header--stuck {
  box-shadow: 0 1px 3px rgba(26, 24, 32, .05);
}

/* ---------- Utility strip (34px / 32px mobile) ---------- */
.mi-strip {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--mi-strip-bg);
  border-bottom: 1px solid var(--mi-strip-border);
  font-size: 12px;
  color: var(--mi-grey-text);
  white-space: nowrap;
  overflow: hidden;
}
.mi-strip__left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.mi-strip__contact {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--mi-grey-text);
}
.mi-strip__contact:hover {
  color: var(--mi-ink);
}
.mi-strip__icon {
  width: 11px;
  height: 11px;
}
.mi-strip__email {
  display: none;
}
.mi-strip__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.mi-strip__locale {
  color: var(--mi-grey-text);
}
.mi-strip__locale:hover {
  color: var(--mi-ink);
}
.mi-strip__locale--active {
  font-weight: 600;
  color: var(--mi-ink);
}
.mi-strip__divider {
  color: var(--mi-divider);
}

/* ---------- Nav bar (72px / 56px mobile) ---------- */
.mi-navbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--mi-strip-border);
  white-space: nowrap;
}

.mi-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mi-logo__mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}
.mi-logo__word {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}
.mi-logo__name {
  font-size: 15px;
  font-weight: 700;
  color: var(--mi-ink);
  letter-spacing: -0.01em;
}
.mi-logo__tagline {
  display: none;
}

.mi-nav {
  display: none;
}

.mi-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.mi-search-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--mi-grey-text);
}
.mi-search-toggle svg {
  width: 19px;
  height: 19px;
}
.mi-search-toggle:hover {
  background: var(--mi-hover-bg);
}
.mi-login, .mi-cta {
  display: none;
}

.mi-hamburger {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--mi-ink-body);
  position: relative;
}
.mi-hamburger__icon {
  width: 21px;
  height: 21px;
  position: absolute;
}
.mi-hamburger__icon--close {
  display: none;
  color: var(--mi-purple);
}
.mi-hamburger.is-open {
  background: var(--mi-hover-bg);
}
.mi-hamburger.is-open .mi-hamburger__icon--open {
  display: none;
}
.mi-hamburger.is-open .mi-hamburger__icon--close {
  display: block;
  width: 19px;
  height: 19px;
}

/* Search overlay - behaviour is specced (icon opens a panel, Escape closes,
   focus management), the desktop visual layout is explicitly marked "not yet
   designed" in the README, so this is a minimal functional overlay. */
.mi-search-panel {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--mi-border);
  box-shadow: 0 12px 28px rgba(26, 24, 32, .12);
  z-index: 45;
}
.mi-search-panel.is-open {
  display: block;
}
.mi-search-panel .gcse-search {
  width: 100%;
}

/* ---------- Mobile drawer (<900px) ---------- */
.mi-drawer {
  position: fixed;
  top: 88px;
  left: 0;
  right: 0;
  height: calc(100dvh - 88px);
  background: #fff;
  z-index: 40;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  transform: translateX(100%);
  transition: transform .22s ease-out, visibility .22s ease-out;
}
.mi-drawer.is-open {
  visibility: visible;
  transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
  .mi-drawer {
    transition: opacity .22s ease-out;
    transform: none;
  }
  .mi-drawer:not(.is-open) {
    opacity: 0;
  }
  .mi-drawer.is-open {
    opacity: 1;
  }
}

.mi-drawer__search {
  padding: 14px 16px 12px;
  flex: 0 0 auto;
}
.mi-drawer__search-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  background: var(--mi-strip-bg);
  border: 1px solid var(--mi-border);
  border-radius: 7px;
}
.mi-drawer__search-field .gcse-search {
  width: 100%;
}

.mi-drawer__nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.mi-drawer__row-wrap {
  border-top: 1px solid var(--mi-strip-border);
}
.mi-drawer__row {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--mi-ink-body);
  text-align: left;
}
.mi-drawer__row--link.is-active,
.mi-drawer__row[aria-expanded="true"],
.mi-drawer__row.is-active {
  color: var(--mi-purple);
}
.mi-drawer__chevron {
  width: 12px;
  height: 12px;
  color: var(--mi-icon-stroke);
  flex-shrink: 0;
  transition: transform .15s ease;
}
.mi-drawer__row[aria-expanded="true"] .mi-drawer__chevron {
  transform: rotate(180deg);
}

.mi-drawer__panel-grid {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .15s ease;
  background: var(--mi-child-bg);
  border-top: 1px solid var(--mi-strip-border);
}
.mi-drawer__panel-grid.is-open {
  grid-template-rows: 1fr;
}
.mi-drawer__panel-inner {
  overflow: hidden;
  padding: 4px 0;
}
.mi-drawer__child {
  display: block;
  height: 46px;
  line-height: 46px;
  padding-left: 30px;
  font-size: 15px;
  color: var(--mi-ink-body);
}
.mi-drawer__child.is-active {
  color: var(--mi-purple);
}

.mi-drawer__actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--mi-border);
}
.mi-cta--block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 50px;
  background: var(--mi-purple);
  color: #fff;
  border-radius: 7px;
  font-size: 16px;
  font-weight: 600;
}
.mi-login--block {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  border: 1px solid var(--mi-border-input);
  border-radius: 7px;
  font-size: 16px;
  font-weight: 600;
  color: var(--mi-ink-body);
}

@media (min-width: 900px) {
  .mi-drawer, .mi-hamburger {
    display: none;
  }

  .mi-header {
    position: static;
    box-shadow: none;
  }
  .mi-header.mi-header--stuck {
    box-shadow: none;
  }
  .mi-strip {
    height: 34px;
    padding: 0 28px;
    font-size: 13px;
  }
  .mi-strip__left {
    gap: 22px;
  }
  .mi-strip__icon {
    width: 12px;
    height: 12px;
  }
  .mi-strip__email {
    display: flex;
  }
  .mi-strip__right {
    gap: 10px;
  }

  .mi-navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 72px;
    gap: 20px;
    padding: 0 28px;
    transition: box-shadow .18s ease;
  }
  .mi-header.mi-header--stuck .mi-navbar {
    box-shadow: 0 1px 3px rgba(26, 24, 32, .05);
  }

  .mi-logo {
    gap: 10px;
  }
  .mi-logo__mark {
    width: 34px;
    height: 34px;
  }
  .mi-logo__name {
    font-size: 17px;
  }
  .mi-logo__tagline {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: var(--mi-grey-muted);
    letter-spacing: 0.04em;
  }

  .mi-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: auto;
  }
  .mi-nav__link {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    color: var(--mi-ink-body);
    padding: 10px 10px;
    border-radius: 6px;
    white-space: nowrap;
  }
  .mi-nav__link:hover, .mi-nav__link.is-active {
    background: var(--mi-hover-bg);
    color: var(--mi-purple);
  }

  .mi-dropdown {
    position: relative;
  }
  .mi-dropdown__chevron {
    width: 9px;
    height: 9px;
    color: var(--mi-icon-stroke);
    transition: transform .15s ease;
  }
  .mi-dropdown.is-open .mi-dropdown__chevron {
    transform: rotate(180deg);
  }
  .mi-dropdown__panel {
    position: absolute;
    top: 46px;
    left: 0;
    min-width: 232px;
    background: #fff;
    border: 1px solid var(--mi-border);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(26, 24, 32, .12);
    padding: 8px;
    z-index: 30;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .14s ease-out, transform .14s ease-out;
  }
  .mi-dropdown.is-open .mi-dropdown__panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  @media (prefers-reduced-motion: reduce) {
    .mi-dropdown__panel {
      transform: none;
    }
  }
  .mi-dropdown__panel a {
    display: block;
    padding: 9px 11px;
    border-radius: 5px;
    font-size: 14px;
    color: var(--mi-ink-body);
    white-space: nowrap;
  }
  .mi-dropdown__panel a:hover, .mi-dropdown__panel a:focus, .mi-dropdown__panel a.is-active {
    background: var(--mi-hover-bg);
    color: var(--mi-purple);
  }

  .mi-actions {
    gap: 14px;
  }
  .mi-search-toggle {
    width: 38px;
    height: 38px;
  }
  .mi-search-toggle svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
  }
  .mi-login, .mi-cta {
    display: inline-flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    border-radius: 6px;
    white-space: nowrap;
  }
  .mi-login {
    padding: 9px 16px;
    border: 1px solid var(--mi-border-input);
    color: var(--mi-ink-body);
  }
  .mi-login:hover {
    border-color: var(--mi-purple);
    color: var(--mi-purple);
  }
  .mi-cta {
    gap: 7px;
    padding: 10px 18px;
    background: var(--mi-purple);
    color: #fff;
  }
  .mi-cta:hover {
    background: var(--mi-purple-dark);
  }
}

@media (min-width: 900px) and (max-width: 1099.98px) {
  .mi-strip__email {
    display: none;
  }
  .mi-nav {
    gap: 2px;
  }
  .mi-nav__link {
    padding: 10px 10px;
  }
}

@media (min-width: 1100px) {
  .mi-nav {
    gap: 4px;
  }
  .mi-nav__link {
    padding: 10px 13px;
  }
}
