.header, .footer { background: var(--deep); }
.header { border-bottom: 1px solid var(--rule); }
.footer { border-top: 1px solid var(--rule); }
.masthead {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(.75rem, 2.2vw, 2.2rem);
  min-height: 4.25rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  width: fit-content; min-height: 44px; color: var(--paper);
}
.brand img { display: block; width: 3rem; height: 3rem; image-rendering: pixelated; }
.brand span { display: block; font-size: 1.25rem; line-height: 1; white-space: nowrap; }
.brand small { display: block; margin-bottom: .28rem; font-size: .75rem; color: var(--gold); }
.main-nav {
  display: flex;
  justify-self: center;
  align-self: stretch;
  align-items: stretch;
  column-gap: clamp(.55rem, 2.2vw, 2.2rem);
}
.main-nav a { min-width: 44px; padding-inline: .18rem; font-size: 1rem; }
.service-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: clamp(.9rem, 3vw, 2.5rem);
  padding-block: .15rem .4rem;
  border-top: 1px solid var(--rule);
  font-size: .875rem;
}

:is(.main-nav a, .service-nav a, .army-picker button) {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; color: var(--muted);
  box-shadow: inset 0 -2px transparent;
}
:is(.main-nav a, .service-nav a, .army-picker button):is([aria-current="page"], [aria-pressed="true"]) {
  color: var(--army-accent, var(--gold));
  box-shadow: inset 0 -2px currentColor;
}
:is(.main-nav a, .service-nav a, .army-picker button):focus-visible {
  outline-offset: -2px;
}
@media (hover: hover) {
  :is(.main-nav a, .service-nav a, .army-picker button):hover { color: var(--army-accent, var(--gold)); }
}
@media (prefers-reduced-motion: no-preference) {
  body[data-motion="on"]:not([data-background="true"]) :is(.main-nav a, .service-nav a, .army-picker button) {
    transition: color .16s ease-out;
  }
  body[data-motion="on"]:not([data-background="true"]) :is(.main-nav a, .service-nav a, .army-picker button):is([aria-current="page"], [aria-pressed="true"]) {
    transition-property: color, box-shadow;
  }
}
.header-tools {
  --tool-height: max(44px, 2.75rem);
  display: flex; align-items: center; justify-self: end; gap: .5rem;
  max-width: 100%; min-width: 0;
  font: .94rem/1 var(--font-ui);
}
.motion-control, .login-link { height: var(--tool-height); border-radius: var(--control-radius); }
.motion-control {
  display: inline-flex; align-items: center; justify-content: center; flex: none; gap: .5rem;
  padding: 0 .3rem; color: var(--muted); background: transparent; border: 0;
}
.motion-switch {
  position: relative; width: 1.5rem; height: .875rem; border: 1px solid var(--control-edge);
  background: var(--deep); border-radius: 2px;
}
.motion-switch::before {
  content: ''; position: absolute; inset: 2px auto 2px 2px; aspect-ratio: 1;
  background: var(--muted);
}
.motion-control[aria-pressed="true"] .motion-switch { background: #314642; border-color: var(--mint); }
.motion-control[aria-pressed="true"] .motion-switch::before {
  transform: translateX(.625rem); background: var(--mint);
}
.motion-control:disabled { opacity: .55; }
.motion-control:not(:disabled):is(:hover, :focus-visible) { color: var(--paper); }
.login-link {
  display: block; min-width: 44px; max-width: 10rem; padding-inline: .85rem;
  border: 1px solid var(--brass); background: var(--gold); color: var(--deep);
  box-shadow: inset 0 -2px var(--brass); line-height: calc(var(--tool-height) - 2px);
  text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.login-link:is(:hover, :focus-visible) { background: #f8e7bd; }
.login-link:active { box-shadow: inset 0 2px var(--brass); }
.login-link[aria-current="page"] { text-decoration: underline; text-underline-offset: .24em; }
@media (prefers-reduced-motion: no-preference) {
  body[data-motion="on"] .motion-switch::before { transition: transform .14s ease-out; }
}

@media (max-width: 58rem) {
  .masthead { grid-template-columns: auto minmax(0, 1fr); gap: 0 .7rem; padding-top: .35rem; }
  .brand img { width: 2.5rem; height: 2.5rem; }
  .brand span { font-size: 1.1rem; }
  .brand small { margin-bottom: .18rem; font-size: .7rem; }
  .header-tools { grid-column: 2; grid-row: 1; }
  .main-nav { grid-row: 2; grid-column: 1 / -1; width: 100%; justify-content: space-between; gap: .15rem; flex-wrap: wrap; }
  .main-nav a { font-size: .9rem; padding-inline: 0; }
  .service-nav { justify-content: start; }
}
@media (max-width: 30rem) {
  .main-nav { display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; gap: .1rem; }
  .main-nav a { padding-inline: .15rem; }
  .header-tools { gap: .35rem; font-size: .875rem; }
  .motion-control { gap: .3rem; padding-inline: .1rem; }
  .login-link { padding-inline: .65rem; }
}
@media (max-width: 23rem) {
  .masthead, .service-nav { width: calc(100% - 1.25rem); }
  .masthead { column-gap: .35rem; }
  .brand { gap: .35rem; }
  .brand img { width: 2rem; height: 2rem; }
  .brand span { font-size: 1rem; }
  .main-nav a { font-size: .84rem; }
}
@media (min-width: 42rem) and (max-width: 58rem) and (max-height: 30rem) {
  .masthead {
    width: calc(100% - 2rem); min-height: 3.2rem; padding: 0;
    grid-template-columns: auto minmax(0, 1fr) auto; gap: .7rem;
  }
  .main-nav { grid-area: 1 / 2; justify-content: center; column-gap: clamp(.4rem, 1.4vw, 1rem); }
  .header-tools { grid-column: 3; }
}
@media (forced-colors: active) {
  :is(.main-nav a, .service-nav a, .army-picker button):is([aria-current="page"], [aria-pressed="true"]) { text-decoration: underline; }
  .motion-switch, .motion-switch::before { forced-color-adjust: none; }
  .motion-switch, .motion-control[aria-pressed="true"] .motion-switch { background: Canvas; border-color: ButtonText; }
  .motion-switch::before, .motion-control[aria-pressed="true"] .motion-switch::before { background: ButtonText; }
}
