/**
 * Madison Equity Data — Shared Shell
 * ------------------------------------------------------------------
 * Wave 2 S1 (PIP-79). The site chrome every surface imports:
 * skip-link, header/wordmark bar, nav, language toggle, footer,
 * and the provenance-chip primitive (full T1–T5 styling lives in
 * tier.css — this file only lays out the chip shape/position so
 * header/footer contexts can use a bare chip without importing
 * the whole tier system).
 *
 * CONSUMPTION CONTRACT: see shared/components.md. Do not duplicate
 * these rules in a surface stylesheet — import this file relative
 * to the surface, then add ONLY surface-specific rules on top.
 *
 * Import order (every surface, every page):
 *   1. design/tokens.css   (source of truth for all custom properties)
 *   2. shared/shell.css    (this file)
 *   3. shared/tier.css     (if the surface renders tier chips/maps)
 *   4. <surface>.css       (page-specific rules only)
 *
 * This file assumes tokens.css is already loaded — it consumes
 * var(--*) tokens and defines NO raw color/font values itself.
 * ------------------------------------------------------------------ */

/* ==================================================================
   RESET + BASE
   Applied globally because every surface is a full HTML page, not
   a component mounted into a host page. If a future surface needs
   to embed shell chrome inside another app shell, scope these two
   rules behind a `.med-shell-root` wrapper at that time.
   ================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

img, svg { max-width: 100%; display: block; }

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}

/* Page shell — narrow reading-width container used by every surface's
   <main>. Surfaces needing more room (Atlas/map pages) can override
   max-width to var(--max-layout-wide) on their own <main>. */
.shell {
  max-width: var(--max-layout);
  margin: 0 auto;
  padding: 0 var(--sp-6);
  width: 100%;
}

.shell--wide { max-width: var(--max-layout-wide); }

/* ==================================================================
   SKIP LINK
   Required on every page (SHELL.md a11y standing constraint). Visually
   hidden until focused; jumps to #main-content, which every surface's
   <main> must carry as its id.
   ================================================================== */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  z-index: 100;
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  transition: top var(--motion-quick);
}

.skip-link:focus {
  top: var(--sp-3);
}

/* ==================================================================
   HEADER — wordmark bar + nav + language toggle.
   Same structure, same position, on EVERY page of EVERY surface
   (i18n/ARCHITECTURE.md §3 non-negotiable #1). Dark inverse band,
   matching design/style-tile.html.
   ================================================================== */
header.site {
  background: var(--ink);
  color: var(--ink-inverse-text);
  flex-shrink: 0;
}

.site-bar {
  max-width: var(--max-layout);
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.site-bar--wide { max-width: var(--max-layout-wide); }

.wordmark {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--rule-light);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.wordmark:hover { color: var(--rule-light); }
.wordmark strong { color: var(--ink-inverse-text-2); font-weight: var(--fw-medium); }
.wordmark-dot {
  display: inline-block; width: 4px; height: 4px;
  background: var(--accent-tint-2); border-radius: 50%;
  margin: 0 var(--sp-2); vertical-align: middle;
}

nav.site-nav { display: flex; gap: var(--sp-6); align-items: center; flex-wrap: wrap; }
nav.site-nav a {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rule-light);
  text-decoration: none;
  opacity: 0.75;
  transition: opacity var(--motion-quick);
}
nav.site-nav a:hover { opacity: 1; color: var(--ink-inverse-text-2); }
nav.site-nav a[aria-current="page"] {
  color: var(--ink-inverse-text-2);
  opacity: 1;
  border-bottom: 1px solid var(--accent-tint-2);
  padding-bottom: 2px;
}

/* Header-region cluster: nav + toggle grouped so they wrap together
   on narrow viewports rather than the toggle stranding alone. */
.site-bar-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex-wrap: wrap;
}

/* ==================================================================
   LANGUAGE TOGGLE — USWDS two-languages pattern.
   Label = TARGET language, in its own name. Never "ES"/"Spanish"/flag.
   Driven by shared/shell.js; markup contract in components.md.
   ================================================================== */
.lang-toggle {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper);
  border-radius: var(--radius-full);
  padding: var(--sp-1) var(--sp-4);
  cursor: pointer;
  transition: background var(--motion-quick);
}
.lang-toggle:hover { background: var(--parchment); }

/* ==================================================================
   MAIN — every surface's <main id="main-content"> lands here.
   flex: 1 pins the footer to the viewport bottom on short pages.
   ================================================================== */
main {
  flex: 1 0 auto;
}

/* ==================================================================
   INLINE "OTHER LANGUAGE" FLAG — "(en inglés)" / "(in Spanish)".
   i18n/ARCHITECTURE.md §3 non-negotiable #4. Always paired with its
   own lang attribute so screen readers pronounce it correctly.
   ================================================================== */
.lang-flag {
  font-family: var(--font-ui);
  font-style: italic;
  font-size: var(--fs-xs);
  color: var(--slate);
}
header .lang-flag,
footer .lang-flag {
  color: var(--rule-light);
}

/* ==================================================================
   PROVENANCE CHIP — bare positioning/shape only. Tier-specific
   colors (t1..t5) are defined in shared/tier.css — this rule exists
   so header/footer/card contexts can lay out a chip without pulling
   in the full tier system. See shared/tier.css for .tier-chip.t1–t5.
   ================================================================== */
.tier-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  border-radius: var(--radius-sm);
  padding: 2px var(--sp-2);
  white-space: nowrap;
}

/* ==================================================================
   FOOTER — "Built by TresPies" + footer link list + lang-flag slot.
   ================================================================== */
footer.site {
  margin-top: var(--sp-16);
  background: var(--ink);
  color: var(--ink-inverse-text);
  flex-shrink: 0;
}
.footer-inner {
  max-width: var(--max-layout);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-8);
  justify-content: space-between;
  align-items: baseline;
}
.footer-inner--wide { max-width: var(--max-layout-wide); }
.footer-built {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: var(--rule-light);
}
.footer-built a { color: var(--ink-inverse-text-2); }
.footer-links { display: flex; gap: var(--sp-6); flex-wrap: wrap; }
.footer-links a {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: var(--rule-light);
  text-decoration: none;
}
.footer-links a:hover { color: var(--ink-inverse-text-2); text-decoration: underline; }

/* ==================================================================
   RESPONSIVE — mobile 375 → desktop. Header/footer stack and center;
   nav wraps under the wordmark before the toggle strands alone.
   ================================================================== */
@media (max-width: 860px) {
  .site-bar { justify-content: center; text-align: center; }
  .site-bar-controls { justify-content: center; }
  .footer-inner { justify-content: center; text-align: center; }
}

@media (max-width: 480px) {
  .shell { padding: 0 var(--sp-4); }
  nav.site-nav { gap: var(--sp-4); }
}

/* ==================================================================
   PRINT — chrome collapses to plain black-on-white; toggle hidden.
   ================================================================== */
@media print {
  header.site, footer.site {
    background: none;
    color: var(--ink);
    border-bottom: 1px solid var(--ink);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .wordmark, .wordmark strong, nav.site-nav a,
  .footer-built, .footer-built a, .footer-links a, .lang-flag { color: var(--ink); }
  .lang-toggle, .skip-link { display: none; }
  a { text-decoration: none; color: inherit; }
}
