/* One-row editorial masthead. The navigation becomes an overlay menu below
   1800px so readable navigation, brand details, and controls fit on one row. */
:root { --header-height: 76px; }

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  width: 100%;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  box-shadow: 0 2px 18px rgb(0 0 0 / .12);
  backdrop-filter: blur(14px);
}

.site-header::after {
  left: var(--gutter);
  right: var(--gutter);
}

.masthead-main {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-content: initial;
  min-height: 72px;
  gap: clamp(6px, 1vw, 14px);
}

.brand {
  display: grid;
  grid-template-columns: 38px auto;
  grid-template-rows: auto auto;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  flex-shrink: 1;
  column-gap: 11px;
  transform: none;
  text-decoration: none;
}

.brand-mark {
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
}

.brand > span:nth-child(2) {
  font-size: 24px;
  line-height: 1;
  letter-spacing: .16em;
}

.brand small {
  align-self: start;
  font-size: 8px;
  line-height: 1.25;
  letter-spacing: .05em;
  white-space: nowrap;
}

.masthead-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, .8vw, 12px);
  padding: 0;
  border: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: clamp(8px, .68vw, 10px);
  font-weight: 700;
  letter-spacing: .09em;
  line-height: 1.35;
  text-transform: uppercase;
  white-space: nowrap;
}

.masthead-meta > * {
  flex: 0 0 auto;
}

.masthead-meta > * + * {
  padding-left: clamp(6px, .8vw, 12px);
  border-left: 1px solid var(--soft-line);
}

.masthead-issue,
.masthead-date,
.masthead-edition {
  color: var(--accent);
}

.masthead-issue {
  display: inline-flex;
  gap: 2px;
}

.masthead-date,
.masthead-edition {
  color: var(--muted);
}

.masthead-date__compact,
.masthead-edition__compact {
  display: none;
}

/* Outrank the legacy span:nth-child declarations in site.css. */
.masthead-meta span.masthead-date__compact,
.masthead-meta span.masthead-edition__compact { display: none; }

.header-actions {
  position: static;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.theme-toggle,
.menu-toggle {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 9px;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--mono);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}

.theme-toggle:hover,
.menu-toggle:hover {
  color: var(--accent);
  border-color: var(--line);
  background: var(--paper-deep);
}

.theme-label {
  font-size: 9px;
  text-transform: uppercase;
}

.theme-icon {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
}

.menu-toggle .header-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.menu-lines { width: 20px; }

.primary-nav {
  position: absolute;
  z-index: 1;
  top: 100%;
  right: 0;
  left: 0;
  display: grid;
  max-height: 0;
  grid-template-columns: 1fr;
  overflow: hidden;
  padding: 0 clamp(12px, 2vw, 28px);
  border: 0 solid var(--line);
  background: var(--paper);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: max-height .28s var(--ease), opacity .18s ease, padding .28s var(--ease), border-width .1s linear;
}

.primary-nav[data-open='true'] {
  max-height: calc(100dvh - var(--header-height));
  overflow-y: auto;
  padding-top: 8px;
  padding-bottom: 14px;
  border-bottom-width: 1px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  overscroll-behavior: contain;
}

.primary-nav a {
  display: flex;
  min-height: 48px;
  align-items: center;
  border-bottom: 1px solid var(--soft-line);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .07em;
  text-decoration: none;
  text-transform: uppercase;
}

.primary-nav a::before { display: none; }
.primary-nav a[aria-current='page'] { color: var(--accent); }

/* At compact widths, long labels are visually shortened while the complete
   issue/date/edition wording remains available to assistive technology. */
@media (max-width: 780px) {
  .masthead-meta { gap: 7px; }
  .masthead-meta > * + * { padding-left: 7px; }
  .masthead-date__full,
  .masthead-edition__full {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .masthead-date__compact,
  .masthead-edition__compact { display: inline; }
  /* Override the old masthead span:nth-child rule retained in site.css. */
  .masthead-meta span.masthead-issue__number,
  .masthead-meta span.masthead-date__compact,
  .masthead-meta span.masthead-edition__compact { display: inline; }
  .masthead-edition__compact { color: var(--accent); }
}

@media (max-width: 560px) {
  .site-header { padding-inline: 14px; }
  .masthead-main { min-height: 68px; gap: 8px; }
  .brand {
    grid-template-columns: 28px auto;
    column-gap: 7px;
  }
  .brand-mark { width: 28px; height: 28px; }
  .brand > span:nth-child(2) { font-size: 20px; letter-spacing: .12em; }
  .brand small { display: none; }
  .masthead-meta {
    justify-content: flex-end;
    gap: 5px;
    font-size: clamp(8px, 2.5vw, 9px);
    letter-spacing: .04em;
  }
  .masthead-meta > * + * { padding-left: 5px; }
  .header-actions { gap: 1px; }
  .theme-toggle,
  .menu-toggle {
    min-width: 40px;
    min-height: 40px;
    padding-inline: 5px;
  }
  .theme-label { display: none; }
}

@media (max-width: 380px) {
  .site-header { padding-inline: 8px; }
  .masthead-main { min-height: 64px; gap: 6px; }
  .brand { grid-template-columns: 26px auto; column-gap: 6px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand > span:nth-child(2) { font-size: 19px; letter-spacing: .1em; }
  .masthead-meta { gap: 3px; font-size: 7.5px; letter-spacing: .02em; }
  .masthead-meta > * + * { padding-left: 3px; }
  .theme-toggle,
  .menu-toggle { min-width: 38px; min-height: 40px; }
}

/* Desktop keeps the same information on the same baseline and reveals all
   destinations without adding a second navigation tier. Keep this in sync
   with the 1800px menu breakpoint in site.js. */
@media (min-width: 1800px) {
  :root { --header-height: 82px; }
  .masthead-main {
    min-height: 76px;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: clamp(8px, .9vw, 15px);
  }
  .brand { grid-template-columns: 36px auto; column-gap: 9px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand > span:nth-child(2) { font-size: 22px; letter-spacing: .14em; }
  .brand small { font-size: 7px; }
  .masthead-meta {
    justify-content: flex-start;
    gap: clamp(6px, .65vw, 10px);
    font-size: 9px;
    letter-spacing: .06em;
  }
  .masthead-meta > * + * { padding-left: clamp(6px, .65vw, 10px); }
  .header-actions { grid-column: 4; gap: 2px; }
  .menu-toggle { display: none; }
  .theme-toggle { min-width: 44px; }
  .primary-nav {
    /* Anchor to the masthead midpoint, independent of unequal side content. */
    position: absolute;
    top: 50%;
    left: 50%;
    right: auto;
    width: max-content;
    transform: translate(-50%, -50%);
    display: flex;
    max-height: none;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, .8vw, 18px);
    overflow: visible;
    padding: 4px 20px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper-deep);
    box-shadow: 0 4px 16px rgb(0 0 0 / .08);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .primary-nav a {
    min-height: 42px;
    border: 0;
    font-size: 12px;
    letter-spacing: .045em;
    white-space: nowrap;
  }
  /* Rounded interaction states follow the capsule without changing link size. */
  .primary-nav a:hover,
  .primary-nav a:focus-visible { color: var(--accent); }
  .primary-nav a:focus-visible { border-radius: 999px; outline-offset: 3px; }
}

@media (max-width: 1799px) {
  .primary-nav[data-open='true'] { overflow-y: auto; }
  body.menu-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .menu-toggle,
  .primary-nav { transition-duration: .01ms; }
}

@media print {
  :root { --header-height: 0; }
  .site-header { position: static; }
}
/* The longer wordmark uses a compact geometric treatment at every breakpoint.
   Theme-aware backing keeps the cyan mark legible on light and dark surfaces. */
.brand > span:nth-child(2) { font-family: var(--sans); font-size: 17px; font-weight: 800; letter-spacing: .035em; white-space: nowrap; }
.brand-mark, .footer-brand img { background: #071521; border-radius: 7px; padding: 3px; filter: none; }
.footer-brand { font-family: var(--sans); font-size: clamp(24px, 4vw, 44px); letter-spacing: .035em; flex-wrap: wrap; }
@media (max-width: 560px) {
  .brand > span:nth-child(2) { font-size: 13px; letter-spacing: .015em; }
}
@media (max-width: 380px) {
  .brand > span:nth-child(2) { font-size: 12px; }
}
