/* ============================================================
   DARKWOLF // LOW SIGNATURE: shared header and footer (tools/swap_chrome.py)
   Plan darkwolf-site-20261117-low-signature-overhaul, TKT-5 (P-REQ-2, P-REQ-6).
   Every page loads this after its own stylesheets. Colors come only from dw-tokens.css, so every display
   mode covers the chrome. Rules are scoped to header.tb and footer.site-footer so page styles aren't touched.
   ============================================================ */

/* The sticky header must never cover a focused element or an anchor target (WCAG 2.4.11). */
html { scroll-padding-top: calc(var(--nav-h, 65px) + 19px); }
/* --nav-h is the header's height (measured in Chrome): 65px on one row, 121px wrapped, 169px at 320px.
   Sticky section heads and scroll targets clear it. */
@media (max-width: 1000px) { :root { --nav-h: 121px; } }
@media (max-width: 360px) { :root { --nav-h: 169px; } }

/* ---- header ---- */
header.tb {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  font-family: var(--f-read);
}
header.tb .inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 10px;
}
header.tb .wm { display: flex; align-items: center; min-height: 44px; text-decoration: none; }
header.tb .wordmark { height: 22px; width: auto; display: block; }
/* The original wordmark, recolored by token. The slashes take the text color: no violet (D-6). */
.wordmark .wm-name, .wordmark .wm-slash { fill: var(--fg); }
.wordmark .wm-sub { fill: var(--fg-2); }
header.tb nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
header.tb nav a, header.tb .tg {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--fg-2); text-decoration: none; background: transparent; border: 0; cursor: pointer;
}
header.tb nav a:hover, header.tb .tg:hover, header.tb nav a[aria-current] { color: var(--fg); }
header.tb nav a[aria-current] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }
header.tb .hd-988 { letter-spacing: .06em; text-transform: none; }
header.tb .hd-988 b { color: var(--fg); font-weight: 500; }
header.tb .hd-988 .short { display: none; }
header.tb .tg { border: 1px solid var(--line-2); margin-left: 6px; gap: 8px; }
/* The Display menu (P-REQ-17): the button names the current mode; the caret turns when the panel is open. */
header.tb .dm { position: relative; display: flex; }
header.tb .dm-btn i { width: 6px; height: 6px; border: solid currentColor; border-width: 0 1px 1px 0; border-radius: 0;
  transform: translateY(-2px) rotate(45deg); }
header.tb .dm-btn[aria-expanded="true"] { color: var(--fg); border-color: var(--fg-2); }
header.tb .dm-btn[aria-expanded="true"] i { transform: translateY(1px) rotate(225deg); }
header.tb .dm-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: max-content; max-width: min(360px, calc(100vw - 32px));
  background: var(--bg); border: 1px solid var(--line-2); padding: var(--s3);
  display: flex; flex-direction: column; gap: var(--s3);
}
header.tb .dm-panel[hidden] { display: none; }
header.tb .dm-panel .display-control { align-self: flex-start; }
/* The note's source link is running text, not a nav item. */
header.tb .dm-panel .display-note a {
  display: inline; min-height: 0; padding: 0; font: inherit; letter-spacing: 0; text-transform: none;
  color: var(--fg-2); text-decoration: underline; text-underline-offset: .2em;
}
header.tb :focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
@media (max-width: 1100px) {
  header.tb .hd-988 .long { display: none; }
  header.tb .hd-988 .short { display: inline; }
}
@media (max-width: 760px) { header.tb nav a.hide-sm { display: none; } }
@media (max-width: 520px) {
  header.tb .wordmark { height: 15px; }
  header.tb nav a { padding: 0 7px; }
  header.tb .hd-988 .long, header.tb .tg-l { display: none; }
  header.tb .hd-988 .short { display: inline; }
  header.tb .tg { margin-left: 2px; padding: 0 8px; }
  /* The panel spans the header's width on a phone, so it never runs past the screen edge. */
  header.tb .dm { position: static; }
  header.tb .dm-panel { left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px));
    top: 100%; width: auto; max-width: none; }
}

/* ---- footer ---- */
footer.site-footer {
  background: var(--bg); color: var(--fg); border-top: 1px solid var(--line); font-family: var(--f-read);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
footer.site-footer .inner {
  max-width: calc(168px + 720px + 40px); margin: 0 auto;
  display: grid; grid-template-columns: 168px minmax(0, 720px); gap: 40px; padding-block: 44px 60px;
}
footer.site-footer .rl { display: flex; flex-direction: column; gap: 6px; }
footer.site-footer .emblem { display: block; width: 100%; max-width: 56px; height: auto; color: var(--fg-3); }
footer.site-footer .mono {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-3);
}
footer.site-footer .f-crisis { margin: 0 0 18px; font-size: .92rem; color: var(--fg-2); line-height: 1.6; max-width: 62ch; }
footer.site-footer .f-crisis strong { color: var(--fg); font-weight: 500; }
footer.site-footer .f-crisis a {
  display: inline-block; min-height: 24px; line-height: 24px; color: var(--fg);
  text-decoration: underline; text-underline-offset: 3px;
}
footer.site-footer .cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
footer.site-footer .cols div { display: flex; flex-direction: column; gap: 2px; }
footer.site-footer .cols a {
  text-decoration: none; color: var(--fg-2); font-size: .92rem; min-height: 44px; display: flex; align-items: center;
}
footer.site-footer .cols a:hover { color: var(--fg); }
footer.site-footer .disc {
  font-size: .84rem; color: var(--fg-3); line-height: 1.6; border-top: 1px solid var(--line); padding-top: 18px; margin: 8px 0 0;
}
footer.site-footer .base { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
footer.site-footer a:focus-visible, footer.site-footer button:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
@media (max-width: 820px) {
  footer.site-footer .inner { grid-template-columns: 1fr; gap: 16px; }
  footer.site-footer .rl { flex-direction: row; align-items: center; gap: 14px; }
  footer.site-footer .cols { grid-template-columns: 1fr 1fr; }
}

/* ---- Display control (in the header menu) and the shortcuts-off control (footer), dw-keys.js ---- */
.f-display { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin: 0 0 24px; }
.display-control { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--edge); }
.display-control [role="radio"] {
  appearance: none; background: transparent; color: var(--fg-2); border: 0; border-right: 1px solid var(--line-2);
  font-family: var(--f-mono); font-size: var(--t-mono); letter-spacing: var(--track-mono); text-transform: uppercase;
  min-height: 44px; padding: 0 var(--s3); cursor: pointer;
}
.display-control [role="radio"]:last-child { border-right: 0; }
.display-control [role="radio"][aria-checked="true"] { background: var(--sig); color: var(--on-sig); }
.display-control [role="radio"]:focus-visible, .keys-toggle:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.display-note { flex-basis: 100%; margin: 0; font-size: var(--t-xs); color: var(--fg-3); max-width: 62ch; }
.display-note a { color: var(--fg-2); text-decoration: underline; text-underline-offset: .2em; }
.keys-toggle {
  appearance: none; background: transparent; color: var(--fg-2); border: 1px solid var(--edge);
  font-family: var(--f-mono); font-size: var(--t-mono); letter-spacing: var(--track-mono); text-transform: uppercase;
  min-height: 44px; padding: 0 var(--s3); cursor: pointer;
}
.keys-toggle[aria-pressed="false"] { color: var(--fg-3); text-decoration: line-through; }

/* Focus mode: every band but the one at the reading line steps back. */
html.focus-mode [data-band] { opacity: .25; transition: opacity var(--slow) var(--ease); }
html.focus-mode [data-band].live { opacity: 1; }
@media (prefers-reduced-motion: reduce) { html.focus-mode [data-band] { transition: none; } }
