/* Language choices and the independent appearance switch. */
.mast .tools { gap: 10px; }
.mast .languages {
  display: grid; grid-template-columns: repeat(3, 1fr); width: auto; order: initial;
  gap: 0; padding: 3px; border: 1px solid var(--line); border-radius: 100px;
  background: var(--wash);
}
.mast .languages > * {
  display: grid; place-items: center; min-height: 32px; min-width: 66px;
  padding: 0 8px; border-radius: 100px; color: var(--sub); font-size: 13px; font-weight: 600;
}
.mast .languages [aria-current="page"] { color: #fffdf7; background: #244b41; font-weight: 700; }
html[data-theme="dark"] .languages [aria-current="page"] { color: #142b24; background: #cde3d7; }
.languages [aria-disabled="true"] { font-weight: 400; cursor: default; }
.mast .theme {
  width: 40px; height: 40px; flex: none; padding: 0; border-radius: 50%;
  border: 1px solid #193a35; background: #193a35; color: #fffdf7;
  display: inline-grid; place-items: center;
}
.mast .theme[hidden], .theme .sun, html[data-theme="dark"] .theme .moon { display: none; }
html[data-theme="dark"] .theme { color: #193a35; background: #f8f6f0; border-color: #f8f6f0; }
html[data-theme="dark"] .theme .sun { display: block; }
.theme svg { width: 24px; height: 24px; fill: none; stroke: currentColor; }
.theme .moon path, .theme .sun circle { fill: currentColor; stroke: none; }
.theme .sun path { stroke-width: 2; stroke-linecap: round; }
@media (max-width: 1000px) {
  .mast-inner { flex-wrap: wrap; padding-block: 12px; gap: 10px; }
  .mast-inner > nav { order: 3; width: 100%; flex-wrap: wrap; }
  .mast .tools { margin-left: auto; }
}
@media (max-width: 540px) {
  .mast-inner { display: grid; grid-template-columns: minmax(0,1fr) auto; }
  .mast .brand { grid-area: 1/1; }
  .mast .tools { display: contents; }
  .mast .theme { grid-area: 1/2; width: 44px; height: 44px; }
  .mast .languages { grid-area: 2/1/3/-1; min-width: 0; }
  .mast .languages > * { min-height: 40px; min-width: 0; }
  .mast-inner > nav { grid-area: 3/1/4/-1; }
}

/* Paint the highlight behind the existing links without changing the header layout. */
.mast {
  --service-highlight: #dce7da;
  --language-highlight: #244c41;
  --theme-ring: #d6e0cb;
}
html[data-theme="dark"] .mast {
  --service-highlight: #335447;
  --language-highlight: #356659;
  --theme-ring: #355046;
}
.mast nav a:is(.active, :hover, :focus-visible) { text-decoration: none; }
.mast nav[data-track] {
  position: relative;
  isolation: isolate;
}
.mast nav[data-track]::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  width: var(--mark-width, 0);
  height: var(--mark-height, 0);
  transform: translate(var(--mark-x, 0), var(--mark-y, 0));
  border-radius: 999px;
  background: var(--service-highlight);
  opacity: 0;
  pointer-events: none;
}
.mast nav[data-track].languages::before { background: var(--language-highlight); }
.mast nav[data-mark]::before { opacity: 1; }
.mast nav[data-motion]::before {
  transition: transform 185ms cubic-bezier(.22,.72,.25,1), width 185ms, height 185ms, opacity 90ms;
}
.mast nav[data-track] a[data-lit] { color: var(--fg); }
html .mast .languages[data-track] a[aria-current="page"] {
  background: transparent;
  color: var(--sub);
}
html .mast .languages[data-track] a[data-lit] { color: #fffdf7; }
.mast .theme { position: relative; }
.mast .theme::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid var(--theme-ring);
  border-radius: 50%;
  opacity: .55;
  pointer-events: none;
  transition: inset 185ms, border-width 185ms, opacity 185ms;
}
.mast .theme:is(:hover, :focus-visible)::after { inset: 4px; opacity: 1; border-width: 2px; }
@media (prefers-reduced-motion: reduce) {
  .mast nav[data-motion]::before, .mast .theme::after { transition: none; }
}

/* The wordmark uses the approved forest green and its light dark-theme companion. */
.mast .brand { color: #204936; }
html[data-theme="dark"] .mast .brand { color: #bcd3c4; }
