/* ==========================================================================
   COMPONENT: Header — focal deliverable
   Main bar · scroll-progress hairline · mega nav
   States: transparent over hero → compact and grounded on scroll
   --------------------------------------------------------------------------
   PINNED, ALWAYS. The bar does not hide on scroll-down. Taking the navigation
   and the Donate button away at the moment a reader is deepest in a page is a
   cost with no upside, and the bar sliding back in reads as a glitch rather
   than a flourish. What scroll changes instead is WEIGHT: the bar compacts,
   turns opaque, and gains a shadow, so the page beneath it slides under
   something solid.

   MOTION BUDGET. Every animation in this file is transform, opacity or colour
   — nothing that triggers layout on scroll. The one exception is the bar's own
   min-height, which is a single fixed element and cannot cascade.
   ========================================================================== */

.c-header {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: var(--z-header);
  transition:
    background-color var(--d-base) var(--e-out),
    border-color var(--d-base) var(--e-out),
    box-shadow var(--d-base) var(--e-out);
  border-block-end: 1px solid transparent;
}

/* Default (inner pages): solid from the first paint. */
.c-header {
  background-color: var(--c-plaster);
  border-block-end-color: var(--c-line);
}

/* Over-hero variant: transparent until scrolled. Set on Home only.
   A downward scrim keeps white nav text legible over a bright hero without
   painting a bar the reader has to look past. */
.c-header--over-hero {
  background-color: transparent;
  border-block-end-color: transparent;
  color: var(--c-text-inv);
}

.c-header--over-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  /* Solid token colour faded by opacity, so no raw colour value is needed. */
  background-image: linear-gradient(180deg, var(--c-ink) 0%, transparent 100%);
  opacity: 0.55;
  transition: opacity var(--d-base) var(--e-out);
  pointer-events: none;
}

/* Scrolled state. Opaque, not frosted: backdrop-filter forces the compositor
   to re-blur everything behind a sticky bar on every scroll frame, which is
   the single biggest cause of scroll jank on a long page. */
.c-header.is-stuck {
  background-color: var(--c-plaster);
  border-block-end-color: var(--c-line);
  color: var(--c-ink);
  box-shadow: var(--shadow-2);
}

/* Once the bar is solid the scrim has nothing left to do. */
.c-header--over-hero.is-stuck::before { opacity: 0; }

/* Helpline link — now only in the mobile nav footer, which is dark. */
.c-header__helpline {
  color: var(--c-text-inv);
  text-decoration: none;
  font-weight: var(--fw-medium);
}

.c-header__helpline:hover { text-decoration: underline; }

/* Language switcher — mobile nav footer only. */
.c-lang {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: var(--r-full);
  overflow: hidden;
}

.c-lang__btn {
  padding: 0.2rem var(--sp-3);
  font-family: var(--ff-utility);
  font-size: var(--fs-3xs);
  color: var(--c-text-muted-inv);
  background: transparent;
  transition: background-color var(--d-fast) var(--e-out), color var(--d-fast) var(--e-out);
}

.c-lang__btn[aria-pressed="true"] {
  background-color: var(--c-white);
  color: var(--c-ink);
}

/* --------------------------------------------------------------------------
   MAIN BAR
   -------------------------------------------------------------------------- */

.c-header__bar {
  position: relative;          /* sits above the over-hero scrim */
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  width: 100%;
  max-width: var(--w-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
  min-height: var(--header-h);
  transition: min-height var(--d-base) var(--e-out);
}

.c-header.is-stuck .c-header__bar { min-height: var(--header-h-compact); }

.c-header__logo {
  display: inline-flex;
  align-items: center;
  /* The mark is 30px tall once the header compacts, and "home" is the one link
     every page has. The box takes the floor; the artwork is untouched. */
  min-height: 44px;
  flex: none;
  color: inherit;
  text-decoration: none;
}

.c-header__logo svg {
  height: 40px;
  width: auto;
  transition:
    height var(--d-base) var(--e-out),
    transform var(--d-base) var(--e-spring);
}

.c-header.is-stuck .c-header__logo svg { height: 34px; }

/* A 1.5% swell on hover. Anything larger reflows the neighbouring nav; this
   reads as the mark acknowledging the pointer and nothing more. */
.c-header__logo:hover svg,
.c-header__logo:focus-visible svg { transform: scale(1.015); }

.c-header__right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: none;
}

/* Cart */
.c-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: inherit;
  border-radius: var(--r-full);
  transition: background-color var(--d-fast) var(--e-out);
}

.c-cart:hover { background-color: rgb(14 19 48 / 0.06); }
.c-header--over-hero:not(.is-stuck) .c-cart:hover { background-color: rgb(255 255 255 / 0.14); }

.c-cart svg {
  width: 20px;
  height: 20px;
  transition: transform var(--d-fast) var(--e-spring);
}

.c-cart:hover svg { transform: translateY(-1px) scale(1.06); }

.c-cart__count {
  position: absolute;
  inset-block-start: 4px;
  inset-inline-end: 2px;
  min-width: 18px;
  height: 18px;
  padding-inline: 4px;
  display: grid;
  place-items: center;
  font-family: var(--ff-utility);
  font-size: 10px;
  line-height: 1;
  color: var(--c-text-inv);
  background-color: var(--c-verdigris);
  border-radius: var(--r-full);
}

/* --------------------------------------------------------------------------
   DONATE — the one marigold surface in the bar. Colours are NOT touched here;
   the sheen is a header-scoped overlay so the reserved variant keeps its
   single definition in button.css. The magnetic pull owns `transform`, so the
   lift is done with box-shadow instead of translate — the two would otherwise
   fight over the same property.
   -------------------------------------------------------------------------- */

.c-header .c-btn--donate {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition:
    background-color var(--d-fast) var(--e-out),
    border-color var(--d-fast) var(--e-out),
    box-shadow var(--d-base) var(--e-out);
}

.c-header .c-btn--donate::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: -60%;
  inline-size: 45%;
  background-image: linear-gradient(
    100deg,
    transparent 0%,
    var(--c-white) 50%,
    transparent 100%
  );
  opacity: 0;
  transform: translateX(0) skewX(-18deg);
  pointer-events: none;
  z-index: -1;
}

.c-header .c-btn--donate:hover {
  box-shadow: 0 8px 20px -8px var(--c-marigold-deep);
}

.c-header .c-btn--donate:hover::after {
  animation: c-donate-sheen var(--d-slow) var(--e-out) forwards;
}

@keyframes c-donate-sheen {
  from { opacity: 0.55; transform: translateX(0) skewX(-18deg); }
  to   { opacity: 0;    transform: translateX(360%) skewX(-18deg); }
}

/* --------------------------------------------------------------------------
   SCROLL-PROGRESS HAIRLINE — beneath the bar, verdigris (data colour).
   Width driven by --progress, set by navigation.js. transform only.
   -------------------------------------------------------------------------- */

.c-header__progress {
  position: absolute;
  inset-block-end: -1px;
  inset-inline-start: 0;
  width: 100%;
  height: 2px;
  z-index: 2;
  transform-origin: left center;
  transform: scaleX(var(--progress, 0));
  /* Deepening rather than flat: the line reads as filling, not merely growing. */
  background-image: linear-gradient(90deg, var(--c-verdigris), var(--c-verdigris-lt));
  pointer-events: none;
}

.c-header--over-hero:not(.is-stuck) .c-header__progress {
  background-image: linear-gradient(90deg, var(--c-verdigris-lt), var(--c-white));
}

/* --------------------------------------------------------------------------
   HAMBURGER — animated to close. Two bars, transform only.
   -------------------------------------------------------------------------- */

.c-burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 44px;
  height: 44px;
  padding: 12px 10px;
  color: inherit;
}

.c-burger__bar {
  display: block;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  border-radius: var(--r-full);
  transition: transform var(--d-fast) var(--e-out), opacity var(--d-instant) linear;
}

.c-burger[aria-expanded="true"] .c-burger__bar:first-child {
  transform: translateY(4px) rotate(45deg);
}

.c-burger[aria-expanded="true"] .c-burger__bar:last-child {
  transform: translateY(-4px) rotate(-45deg);
}

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */

@media (min-width: 1180px) {
  .c-burger { display: none; }
}

/* Phones. The bar had no small-screen sizing at all, so at 390px the logo
   (40px tall, wordmark and all), the cart, a full-size Donate button and the
   burger came to more than the viewport: Donate was clipped at the right edge
   and THE BURGER WAS PUSHED OFF SCREEN ENTIRELY — the whole navigation was
   unreachable on a phone.

   Everything here is about buying that width back. The 44px touch-target
   floor on .c-btn is deliberately left alone; only the horizontal padding and
   the label size come down. */
@media (max-width: 560px) {
  .c-header__bar { gap: var(--sp-2); }

  .c-header__logo svg,
  .c-header.is-stuck .c-header__logo svg { height: 30px; }

  /* The logo is the one element that can afford to shrink further if the
     wordmark is long; min-width: 0 lets flexbox actually do it. */
  .c-header__logo { min-width: 0; flex: 0 1 auto; overflow: hidden; }

  .c-header__right { gap: var(--sp-1); }

  .c-header__right .c-btn--donate {
    --btn-pad-i: var(--sp-4);
    font-size: var(--fs-xs);
  }
}

/* Very narrow phones. Nothing is dropped here: the header cart is the ONLY
   route to the basket anywhere on the page — it is not repeated in the mobile
   nav panel or the footer — so hiding it would strand a donor who already has
   something in their basket. The logo gives up the last of the width instead. */
@media (max-width: 380px) {
  .c-header__logo svg,
  .c-header.is-stuck .c-header__logo svg { height: 26px; }

  .c-header__right .c-btn--donate { --btn-pad-i: var(--sp-3); }
}

/* --------------------------------------------------------------------------
   BODY OFFSET — the header is fixed, so content needs the height back.
   Home opts out because its hero sits under the transparent header.
   -------------------------------------------------------------------------- */

.l-main { padding-block-start: var(--header-h); }

.has-hero .l-main { padding-block-start: 0; }
