/* ==========================================================================
   MASTHEAD
   ==========================================================================
   Two treatments, one component.

     .masthead--standard   white bar from the start
     .masthead--overlay    transparent over the first section, solid on scroll

   State classes are set by assets/js/navigation.js:
     .is-scrolled    past the threshold, always solid
     .is-menu-open   the overlay menu is open, so the bar sits on paper

   The overlay variant borrows .surface--over-media tokens, which is why the
   logo, button and toggle need no colour rules of their own.
   ========================================================================== */

.masthead {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: var(--z-masthead);
  height: var(--masthead-h);
  display: flex;
  align-items: center;
  transition: background-color var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out),
              color var(--dur) var(--ease-out);
}

/* Standard pages reserve the space; overlay pages run underneath. */
body.masthead-is-standard { padding-top: var(--masthead-h); }

/* Match the body offset while the scroll lock is on, so the bar holds still. */
body.is-locked .masthead { padding-right: var(--scrollbar-w, 0px); }

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  width: 100%;
}

/* -- Solid state ---------------------------------------------------------- */

.masthead--standard,
.masthead.is-scrolled,
.masthead.is-menu-open {
  background-color: var(--ss-white);
  box-shadow: inset 0 -1px 0 var(--ss-ink-15);
}

/* The bar has to stay above the menu sheet, or the close button is buried. */
.masthead.is-menu-open { z-index: calc(var(--z-menu) + 1); }

/* -- Overlay state -------------------------------------------------------- */

.masthead--overlay {
  --text:        var(--ss-white);
  --text-strong: var(--ss-white);
  --text-muted:  var(--text-over);
  --btn-line:       var(--line-over-strong);
  --btn-line-hover: var(--ss-white);
  --btn-solid-bg:   var(--ss-white);
  --btn-solid-text: var(--ss-ink);
  color: var(--ss-white);
}

/* A whisper of shade so a white logo survives a bright sky. */
.masthead--overlay::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: calc(var(--masthead-h) * 2);
  pointer-events: none;
  background: var(--gradient-bar);
  opacity: 1;
  transition: opacity var(--dur) var(--ease-out);
}

/* Once solid, the overlay variant drops back to the paper token set. */
.masthead--overlay.is-scrolled,
.masthead--overlay.is-menu-open {
  --text:        var(--ss-ink);
  --text-strong: var(--ss-black);
  --text-muted:  var(--ss-ink-70);
  --btn-line:       var(--ss-ink-40);
  --btn-line-hover: var(--ss-ink);
  --btn-solid-bg:   var(--ss-ink);
  --btn-solid-text: var(--ss-white);
  color: var(--ss-ink);
}

.masthead--overlay.is-scrolled::before,
.masthead--overlay.is-menu-open::before { opacity: 0; }

/* -- Logo ----------------------------------------------------------------- */

.masthead__logo {
  display: block;
  flex-shrink: 0;
  color: inherit;
  line-height: 0;
}

.masthead__logo .logo {
  height: 26px;
  width: auto;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.masthead__logo:hover .logo { opacity: 0.7; }

@media (max-width: 900px) {
  .masthead__logo .logo { height: 20px; }
}

/* -- Actions -------------------------------------------------------------- */

.masthead__actions {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 1.6vw, 1.5rem);
}

.masthead__cta { flex-shrink: 0; }

@media (max-width: 620px) {
  .masthead__cta { display: none; }
}

/* -- Menu toggle ---------------------------------------------------------- */
/* Label plus two rules. The rules cross on open rather than collapsing, which
   reads more deliberate than the usual three-into-X.                        */

.menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xs) 0 var(--space-2xs) var(--space-2xs);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semi);
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: inherit;
}

.menu-toggle__label {
  display: inline-block;
  min-width: 3.4em;
  text-align: right;
}

@media (max-width: 520px) {
  .menu-toggle__label { display: none; }
}

.menu-toggle__bars {
  position: relative;
  display: block;
  width: 28px;
  height: 12px;
  flex-shrink: 0;
}

.menu-toggle__bars i {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: currentColor;
  transition: transform var(--dur) var(--ease-out),
              width var(--dur) var(--ease-out);
}

.menu-toggle__bars i:first-child { top: 3px; }
.menu-toggle__bars i:last-child  { top: 9px; width: 68%; }

.menu-toggle:hover .menu-toggle__bars i:last-child { width: 100%; }

.menu-toggle[aria-expanded="true"] .menu-toggle__bars i:first-child {
  transform: translateY(3px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars i:last-child {
  width: 100%;
  transform: translateY(-3px) rotate(-45deg);
}
