/* ── Masthead: wordmark and tagline, grouped tabs, search — one row ──── */
.masthead {
  --masthead-pad: 1.5rem;
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: var(--z-nav);
  display: flex; align-items: flex-end; gap: 1.75rem;
  padding: 1.25rem var(--masthead-pad) 0;
  background: var(--surface-chrome);
  border-bottom: 1px solid var(--rule-on-dark-strong);
}
.masthead__brand { flex: 0 0 16.64rem; width: 16.64rem; min-width: 0; padding-bottom: 1rem; }
.masthead__wordmark {
  display: block;
  font-family: var(--font-serif); font-weight: 700;
  font-size: var(--size-subheading); line-height: var(--leading-heading);
  text-transform: uppercase; text-decoration: none;
  color: var(--text-on-dark);
}
.masthead__wordmark:hover { color: var(--accent-on-dark); }
.masthead__tagline { display: block; margin-top: 0.375rem; font-size: var(--size-small); line-height: var(--leading-heading); color: var(--text-on-dark); }

.masthead__nav { flex: 1 1 auto; }
.masthead__groups { display: flex; justify-content: center; list-style: none; margin: 0; padding: 0; }
.masthead__group { position: relative; }
.masthead__tab {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.875rem 1rem; border: 0; border-bottom: 3px solid transparent;
  background: transparent; color: var(--text-on-dark); cursor: pointer;
  font-family: var(--font-serif); font-size: var(--size-body-card);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}
.masthead__tab::after { content: "\25BE"; font-size: var(--size-micro); color: var(--text-on-dark-muted); }
/* An open tab becomes paper, and its menu continues it downward. */
.masthead__group:is(:hover, :focus-within, .is-open) > .masthead__tab {
  background: var(--surface-paper); color: var(--accent); border-bottom-color: var(--accent);
}
.masthead__group:is(:hover, :focus-within, .is-open) > .masthead__tab::after { color: var(--accent); }
.masthead__menu {
  display: none; position: absolute; left: 0; top: 100%; z-index: 1;
  min-width: 15rem; margin: 0; padding: 0.375rem 0; list-style: none;
  background: var(--surface-paper);
  border: 1px solid var(--rule-on-paper); border-top: 0;
  box-shadow: var(--shadow-overlay);
}
.masthead__group:is(:hover, :focus-within, .is-open) > .masthead__menu { display: block; }
.masthead__menu a {
  display: block; padding: 0.625rem 1rem;
  font-family: var(--font-serif); font-size: var(--size-caption);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; text-decoration: none;
  color: var(--accent);
}
.masthead__menu a:hover { background: color-mix(in srgb, var(--text-on-paper) 5%, transparent); color: var(--accent-hover); }
.masthead__menu a:focus-visible, .masthead__group:is(:hover, :focus-within, .is-open) > .masthead__tab:focus-visible { outline-color: var(--accent); outline-offset: -3px; }

.masthead__search {
  flex: 0 0 auto; display: flex; align-items: center; gap: 0.5rem;
  width: 11rem; margin-bottom: 0.75rem; padding: 0.4375rem 0.75rem;
  border: 1px solid var(--rule-on-dark); background: var(--ground-hover);
  color: var(--text-on-dark-muted);
  transition: width 220ms ease, border-color 150ms ease;
}
.masthead__search:focus-within { width: 15rem; border-color: var(--accent-on-dark); color: var(--text-on-dark); }
.masthead__search svg { width: 14px; height: 14px; flex: 0 0 auto; }
.masthead__search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-family: var(--font-serif); font-size: var(--size-small);
  color: var(--text-on-dark); caret-color: var(--text-on-dark);
}
.masthead__search input::placeholder { color: var(--text-on-dark-muted); letter-spacing: var(--tracking-caps); text-transform: uppercase; font-size: var(--size-caption); }

.masthead__menu-button {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 2.5rem; height: 2.5rem; margin: 0 0 0.75rem auto; padding: 0 0.5rem;
  border: 1px solid var(--rule-on-dark); background: transparent; cursor: pointer;
}
.masthead__menu-button span { display: block; height: 2px; background: var(--text-on-dark); }

/* ≤980px: the groups become one panel under the bar, every link listed. */
@media (max-width: 980px) {
  .masthead { --masthead-pad: 1rem; flex-wrap: wrap; align-items: center; gap: 0 1rem; padding-top: 0.75rem; }
  .masthead__brand { flex: 1 1 0; width: auto; padding-bottom: 0.75rem; }
  .masthead__menu-button { display: flex; margin-left: 0; }
  .masthead__search { order: 3; flex: 1 1 100%; width: auto; margin-bottom: 0.75rem; }
  .masthead__search:focus-within { width: auto; }
  .masthead__nav {
    display: none; order: 4; flex: 1 1 100%;
    margin: 0 calc(-1 * var(--masthead-pad)); padding: 0.5rem var(--masthead-pad) 1rem;
    border-top: 1px solid var(--rule-on-dark);
    max-height: calc(100vh - 9rem); overflow-y: auto;
  }
  .masthead.is-menu-open .masthead__nav { display: block; }
  .masthead__groups { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; }
  .masthead__tab, .masthead__group:is(:hover, :focus-within, .is-open) > .masthead__tab {
    padding: 0.5rem 0 0.25rem; border-bottom: 0; background: transparent; cursor: default;
    font-size: var(--size-label); color: var(--text-on-dark-muted);
  }
  .masthead__tab::after { content: none; }
  .masthead__menu, .masthead__group:is(:hover, :focus-within, .is-open) > .masthead__menu {
    display: block; position: static; min-width: 0; padding: 0;
    background: transparent; border: 0; box-shadow: none;
  }
  .masthead__menu a { padding: 0.5rem 0; color: var(--text-on-dark); }
  .masthead__menu a:hover { background: transparent; color: var(--accent-on-dark); }
  .masthead__menu a:focus-visible { outline-color: var(--accent-on-dark); outline-offset: 2px; }
}
@media (max-width: 520px) {
  .masthead__tagline { font-size: var(--size-caption); }
}
