/*
 * Site header (shared/_header): a frosted bar that stays at the top as the page scrolls, in the
 * footer's palette. Phones: the logo, Search, Cart and a menu button that opens Home, Shop and
 * Sign in under the bar. 768px: the logo, the menu in the middle, then the actions.
 */

/* The header keeps the bar's height in the page; the surface grows over the page as the menu opens. */
.mx-header {
  --bar-height: 64px;
  position: sticky;
  top: 10px;
  z-index: 10;
  width: min(1180px, 100%);
  height: calc(var(--bar-height) + 2px);
}

.mx-header__surface {
  position: absolute;
  inset: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--mx-color-surface) 75%, transparent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--mx-color-surface) 62%, transparent);
  box-shadow: 0 18px 36px -28px color-mix(in srgb, var(--mx-color-navy) 35%, transparent);
  backdrop-filter: blur(20px) saturate(1.15);
  transition: background-color 360ms ease, box-shadow 360ms ease;
}

/* Open over the page, the menu needs a near-solid surface so the card's edge doesn't show through. */
.mx-header--open .mx-header__surface {
  background: color-mix(in srgb, var(--mx-color-surface) 94%, transparent);
  box-shadow: 0 28px 48px -24px color-mix(in srgb, var(--mx-color-navy) 40%, transparent);
}

.mx-header__bar {
  display: flex;
  align-items: center;
  gap: var(--mx-space-sm);
  height: var(--bar-height);
  padding: 0 8px 0 calc(var(--site-inset) - 1px);
}

/* The emblem with a navy wordmark, as in the footer. The brand line joins it from 420px. */
.mx-header__logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-right: auto;
  color: var(--mx-color-navy);
  text-decoration: none;
}

.mx-header__emblem {
  width: 34px;
}

.mx-header__name {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mx-header__wordmark {
  font-family: var(--mx-font-display);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mx-header__name .mx-identity {
  display: none;
}

/* The main menu shows from 768px; phones use the menu under the bar. */
.mx-header__nav {
  display: none;
}

.mx-header__links {
  display: flex;
  gap: var(--mx-space-xl);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 44px tall targets; the gold underline arrives on hover and marks the current page. */
.mx-header__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--mx-color-navy);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 6px;
  transition: text-decoration-color 160ms ease;
}

a.mx-header__link:hover,
a.mx-header__link:focus-visible,
.mx-header__link[aria-current="page"] {
  text-decoration-color: var(--mx-color-gold-deep);
}

.mx-header__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Round 44px icon buttons, with the footer's white rim. */
.mx-header__icon-button,
.mx-header__toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--mx-rounded-pill);
  background: transparent;
  color: var(--mx-color-navy);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

a.mx-header__icon-button:hover,
a.mx-header__icon-button:focus-visible,
.mx-header__toggle:hover,
.mx-header--open .mx-header__toggle {
  border-color: var(--mx-color-surface);
  background: var(--mx-color-surface);
}

.mx-header__icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sign in: a navy outlined pill from 768px; on phones it is in the menu. */
.mx-header__account {
  display: none;
  align-items: center;
  min-height: 44px;
  margin-left: var(--mx-space-sm);
  padding: 0 20px;
  border: 1px solid var(--mx-color-navy);
  border-radius: var(--mx-rounded-pill);
  color: var(--mx-color-navy);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}

a.mx-header__account:hover,
a.mx-header__account:focus-visible {
  background: var(--mx-color-navy);
  color: var(--mx-color-on-navy);
}

/* Not built yet: looks the same, but nothing happens on hover or tap. */
.mx-header [aria-disabled="true"] {
  cursor: default;
}

/* The menu button: two lines that turn into a cross. */
.mx-header__toggle-lines {
  position: relative;
  width: 18px;
  height: 10px;
}

.mx-header__toggle-lines::before,
.mx-header__toggle-lines::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.6px;
  border-radius: 1px;
  background: currentColor;
  transition: translate 280ms cubic-bezier(0.22, 1, 0.36, 1), rotate 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mx-header__toggle-lines::before {
  top: 0;
}

.mx-header__toggle-lines::after {
  bottom: 0;
}

.mx-header--open .mx-header__toggle-lines::before {
  translate: 0 4.2px;
  rotate: 45deg;
}

.mx-header--open .mx-header__toggle-lines::after {
  translate: 0 -4.2px;
  rotate: -45deg;
}

/*
 * The phone menu folds open under the bar: its height grows from nothing while the links ease
 * down into place, then it folds away the same way. Hidden from screen readers when closed.
 */
.mx-header__menu {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition:
    grid-template-rows 360ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 360ms;
}

.mx-header--open .mx-header__menu {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mx-header__menu-inner {
  min-height: 0;
  overflow: hidden;
}

.mx-header__menu-links {
  margin: 0 14px;
  padding: 4px 0 14px;
  border-top: 1px solid var(--mx-color-line);
  list-style: none;
  opacity: 0;
  translate: 0 -8px;
  transition: opacity 200ms ease, translate 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mx-header--open .mx-header__menu-links {
  opacity: 1;
  translate: 0 0;
  transition: opacity 320ms ease 80ms, translate 420ms cubic-bezier(0.22, 1, 0.36, 1) 40ms;
}

.mx-header__menu-links li + li {
  border-top: 1px solid color-mix(in srgb, var(--mx-color-line) 60%, transparent);
}

.mx-header__menu-links :is(a, span) {
  display: flex;
  align-items: center;
  min-height: 52px;
  color: var(--mx-color-navy);
  font-family: var(--mx-font-display);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
}

.mx-header__menu-links [aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--mx-color-gold-deep);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 6px;
}

@media (min-width: 420px) {
  .mx-header__name .mx-identity {
    display: flex;
  }
}

@media (min-width: 768px) {
  .mx-header {
    --bar-height: 76px;
    top: 16px;
  }

  .mx-header__surface {
    border-radius: 28px;
  }

  .mx-header__bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--mx-space-lg);
    padding: 0 calc(var(--site-inset) - 1px);
  }

  .mx-header__emblem {
    width: 40px;
  }

  .mx-header__logo {
    gap: 10px;
    margin-right: 0;
  }

  .mx-header__wordmark {
    font-size: 1.25rem;
  }

  .mx-header__nav {
    display: block;
  }

  .mx-header__actions {
    justify-self: end;
  }

  .mx-header__account {
    display: inline-flex;
  }

  .mx-header__toggle,
  .mx-header__menu {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mx-header__menu,
  .mx-header--open .mx-header__menu,
  .mx-header__menu-links,
  .mx-header--open .mx-header__menu-links,
  .mx-header__toggle-lines::before,
  .mx-header__toggle-lines::after {
    transition: none;
  }
}
