/* NEWZSIP project site: single accessible stylesheet.
   Targets WCAG 2.1 AA (Section 508). No build step; plain CSS. */

:root {
  --color-primary: #0f4a66;      /* darkened from brand #156082 for AA body-link contrast */
  --color-primary-bright: #156082;
  --color-accent: #E97132;       /* brand orange, used as bars/borders, never as small text on white */
  --color-text: #1a1a1a;
  --color-text-muted: #4a4a4a;
  --color-bg: #ffffff;
  --color-bg-alt: #f4f6f8;
  --color-border: #d4dadf;
  --maxw: 70rem;
  --gap: 1.5rem;
  --measure: none;   /* prose fills the content column, matching full-width tables and charts */
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Arial, Helvetica, "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ---- Skip link (keyboard / screen-reader) ---- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

main { display: block; }

section { margin-block: 3rem; }

/* ---- Header / nav ---- */
.site-header {
  border-top: 4px solid var(--color-accent);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
}
.brand {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--color-primary);
}
.brand strong { font-size: 1.25rem; line-height: 1.2; }
.brand span { font-size: 0.8125rem; color: var(--color-text-muted); }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.site-nav a {
  display: inline-block;
  padding: 0.4rem 0.25rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover { text-decoration: underline; }
.site-nav a[aria-current="page"] { border-bottom-color: var(--color-accent); }

/* ---- Hero ---- */
.hero {
  background: var(--color-primary);
  color: #fff;
  padding-block: 3.5rem;
}
.hero h1 { margin-top: 0; color: #fff; font-size: clamp(1.75rem, 4vw, 2.5rem); }
.hero p { font-size: 1.125rem; max-width: 50ch; color: #eaf1f5; }

/* Buttons sit on the dark hero background, so they need inverted colors
   to stay visible. */
.hero .btn {
  background: #fff;
  color: var(--color-primary);
  border-color: #fff;
}
.hero .btn:hover { background: #d8e4ec; color: #0a3346; }
.hero .btn--ghost {
  background: transparent;
  color: #fff;
  border-color: #fff;
}
.hero .btn--ghost:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

/* ---- Typography ---- */
h1, h2, h3 { color: var(--color-primary); line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 4vw, 2.4rem); }
h2 { font-size: 1.5rem; margin-top: 2.5rem; border-left: 5px solid var(--color-accent); padding-left: 0.75rem; }
h3 { font-size: 1.15rem; }
p { max-width: var(--measure); }
/* Prose lists share the paragraph measure so body text wraps consistently.
   Layout lists (nav, bars, chips, gallery, etc.) are class-targeted and
   keep their own widths; the page table of contents is excluded below. */
main ul:not([class]), main ol:not([class]),
.belief-list, .comment-bullets { max-width: var(--measure); }
.page-toc ul { max-width: none; }

a { color: var(--color-primary); }
a:hover { color: #0a3346; }

/* ---- Focus visibility (keyboard) ---- */
a:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---- Buttons / CTAs ---- */
.btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 0.7rem 1.25rem;
  border: 2px solid var(--color-primary);
  border-radius: 4px;
}
.btn:hover { background: #0a3346; color: #fff; }
.btn--ghost {
  background: transparent;
  color: var(--color-primary);
}
.btn--ghost:hover { background: var(--color-bg-alt); color: var(--color-primary); }

/* ---- Cards / grids ---- */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.card {
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-accent);
  border-radius: 4px;
  padding: 1.25rem;
  background: var(--color-bg);
}
.card h3 { margin-top: 0; }

/* ---- Deliverable list ---- */
.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list li {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.doc-list h3 { margin: 0 0 0.35rem; }
.status {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.status--ready { background: #e3f0ea; color: #1d5c3e; border-color: #b9d8c8; }
.status--soon  { background: #fdeee3; color: #8a4112; border-color: #f0c9a8; }

/* ---- Callout ---- */
.callout {
  background: var(--color-bg-alt);
  border-left: 5px solid var(--color-accent);
  padding: 1.25rem 1.5rem;
  border-radius: 0 4px 4px 0;
}

/* ---- Tables ---- */
table { border-collapse: collapse; width: 100%; }
caption { text-align: left; font-weight: 700; margin-bottom: 0.5rem; }
th, td { border: 1px solid var(--color-border); padding: 0.6rem 0.75rem; text-align: left; }
th { background: var(--color-bg-alt); }

/* ---- Footer ---- */
.site-footer {
  margin-top: 4rem;
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}
.site-footer .container { padding-block: 2rem; }
.site-footer p { max-width: none; }
.site-footer h2 { font-size: 1rem; border: 0; padding: 0; margin: 0 0 0.5rem; color: var(--color-text); }
.site-footer a { color: var(--color-primary); }

/* ---- Utilities ---- */
.lede { font-size: 1.15rem; color: var(--color-text-muted); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- Motion preference ---- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Responsive ---- */
@media (max-width: 40rem) {
  .site-header .container { flex-direction: column; align-items: flex-start; }
  .site-nav ul { gap: 0.25rem 1rem; }
}

/* ---- State of the Practice explorer ---- */
.sop-controls { display: grid; gap: 1.25rem; margin-bottom: 2.5rem; }

.sop-fieldset {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1rem 1.25rem 1.25rem;
  margin: 0;
}
.sop-fieldset legend {
  font-weight: 700;
  color: var(--color-primary);
  padding: 0 0.4rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;       /* wraps instead of scrolling horizontally */
  gap: 0.5rem;
}

.chip {
  font: inherit;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  cursor: pointer;
}
.chip:hover { background: var(--color-bg-alt); }
.chip:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.chip[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.chip[aria-pressed="true"]::before { content: "\2713\00a0"; }

.sop-reset {
  background: transparent;
  border: 0;
  color: var(--color-primary);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem;
}
.sop-reset:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

#results { scroll-margin-top: 1rem; }
#results:focus { outline: none; }
.results-heading {
  margin-top: 0;
  border-left: 0;
  padding: 0 0 0.5rem;
  border-bottom: 3px solid var(--color-accent);
}
.results-intro { color: var(--color-text-muted); }

.result-state-group { margin-bottom: 2.5rem; }
.result-state-group > h3 {
  font-size: 1.25rem;
  border-left: 5px solid var(--color-accent);
  padding-left: 0.6rem;
}

.finding { margin: 0 0 1.5rem; }
.finding h3,
.finding h4 { margin: 0 0 0.3rem; color: var(--color-primary); }
.finding h4 { font-size: 1rem; }
.finding p { margin: 0; max-width: var(--measure); }

.finding-sources { margin-top: 0.6rem; }
.src-label {
  margin: 0 0 0.2rem;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.source-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.95rem;
}
.source-list li { margin: 0.15rem 0; }
.source-list a { font-weight: 700; }
.source-pub { color: var(--color-text-muted); font-weight: 400; }

/* ---- Welcome / snapshot banner ---- */
.welcome-banner {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-primary-bright);
  border-radius: 0 4px 4px 0;
  padding: 1.25rem 1.5rem;
  margin-top: 2rem;
}
.welcome-banner h2 { margin-top: 0; border: 0; padding: 0; font-size: 1.15rem; }
.welcome-banner p { margin-bottom: 0; }
.snapshot-note { font-style: italic; }

/* ---- Accessible bar lists (data + survey pages) ---- */
.bars { list-style: none; margin: 0.75rem 0 0; padding: 0; max-width: 46rem; }
.bars li {
  display: grid;
  grid-template-columns: 9rem 1fr 4.5rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0;
}
.bars .bar-label { font-size: 0.9375rem; }
.bars .bar-meter {
  display: block;
  height: 1.1rem;
  background: var(--color-bg-alt);
  border-radius: 3px;
  overflow: hidden;
}
.bars .bar-meter::before {
  content: "";
  display: block;
  height: 100%;
  width: var(--w, 0%);
  background: var(--color-accent);
  border-radius: 3px 0 0 3px;
}
.bars.bars--blue .bar-meter::before { background: var(--color-primary-bright); }
.bars .bar-num { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 40rem) {
  .bars li { grid-template-columns: 6.5rem 1fr 4rem; }
}

/* ---- Input form + submissions admin ---- */
.input-form { max-width: 42rem; }
.form-field { margin-bottom: 1.25rem; }
.form-field label { display: block; font-weight: 700; color: var(--color-primary); margin-bottom: 0.3rem; }
.form-field .optional { font-weight: 400; color: var(--color-text-muted); }
.form-field .required-mark { font-weight: 400; color: var(--color-text-muted); }
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field textarea {
  width: 100%;
  font: inherit;
  color: var(--color-text);
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
}
.form-field input:focus-visible,
.form-field textarea:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 1px;
}
.form-field textarea { resize: vertical; }
.field-hint { font-size: 0.875rem; color: var(--color-text-muted); margin: 0.3rem 0 0; }
.hp-field {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
#form-status:not(:empty) {
  background: var(--color-bg-alt);
  border-left: 5px solid var(--color-accent);
  padding: 0.75rem 1rem;
}

.submission-card { margin-bottom: 1rem; }
.submission-meta { font-weight: 700; color: var(--color-primary); margin-top: 0; }
.submission-message { white-space: pre-wrap; }
.submission-delete { color: #8a1116; }

/* ---- Survey page: TOC, media row, respondent map ---- */
.page-toc {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.75rem 1.25rem;
}
.page-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.page-toc a { font-weight: 700; }

.media-row { display: flex; flex-wrap: wrap; gap: 1.75rem; align-items: flex-start; }
.media-fig { flex: 0 0 360px; max-width: 100%; }
.media-fig img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--color-border); border-radius: 6px;
}
.fig-caption { font-size: 0.875rem; color: var(--color-text-muted); margin: 0.4rem 0 0; }
.media-body { flex: 1 1 22rem; }

.map-wrap { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; margin: 1.5rem 0; }
.map-figure { flex: 1 1 26rem; min-width: 0; }
.ne-map { width: 100%; height: auto; display: block; }
.ne-map .state {
  stroke: none; cursor: pointer;
  transition: filter 0.12s ease;
}
.ne-map .state:hover { filter: brightness(0.93); }
/* No browser bbox focus rectangle; selection is shown by darkening the fill. */
.ne-map .state:focus, .ne-map .state:focus-visible { outline: none; }
.ne-map .state.is-active { filter: brightness(0.86); }
.ne-map .map-borders { stroke: #fff; stroke-width: 1.4; stroke-linejoin: round; }
.ne-map .map-num {
  font-family: Arial, sans-serif; font-size: 17px; font-weight: 700;
  paint-order: stroke; stroke-width: 3.5px; stroke-linejoin: round;
}
.ne-map .map-num--dark { fill: #1a1a1a; stroke: #fff; }
.ne-map .map-num--light { fill: #fff; stroke: #5a2a08; }

.map-legend { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: 0.8125rem; color: var(--color-text-muted); }
.map-legend li { display: flex; align-items: center; gap: 0.35rem; }
.map-legend .swatch { width: 0.9rem; height: 0.9rem; border-radius: 2px; border: 1px solid var(--color-border); display: inline-block; }

.map-detail {
  flex: 1 1 14rem; min-width: 0;
  align-self: center;   /* vertically center the panel against the map */
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-accent);
  border-radius: 0 4px 4px 0;
  padding: 1rem 1.25rem;
}
.map-detail-hint { margin: 0; color: var(--color-text-muted); }
.map-detail-name { margin: 0 0 0.25rem; }
.map-detail-count { margin: 0 0 0.5rem; }
.map-detail-ages { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; }
.map-detail-ages li { padding: 0.1rem 0; border-top: 1px solid var(--color-border); }

/* ---- Information sources: per-state toggle + rest-of-region marker ---- */
.info-control { margin: 0 0 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.info-control label { font-weight: 700; color: var(--color-primary); }
.info-control select {
  font: inherit; padding: 0.4rem 0.6rem;
  border: 2px solid var(--color-border); border-radius: 4px; background: #fff;
}
.info-control select:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 1px; }
.bars--info li { grid-template-columns: 11rem 1fr 9rem; }
.bars--info .bar-meter { position: relative; overflow: visible; }
.bars--info .bar-meter::before { content: none; }
.bars--info .bar-fill {
  display: block; height: 100%;
  background: var(--color-primary-bright); border-radius: 3px 0 0 3px;
}
.bars--info .bar-ref {
  position: absolute; top: -3px; bottom: -3px; width: 3px;
  background: #c0392b; border-radius: 1px;
}
.bars--info .bar-ref-note { display: block; font-weight: 400; font-size: 0.8125rem; color: var(--color-text-muted); }
.ref-key { color: #c0392b; font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* ---- Per-state comments ---- */
.comment-bullets { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.comment-bullets li { margin: 0.3rem 0; }
.comment-bullets strong { color: var(--color-primary); }

/* ---- Countermeasure image gallery ---- */
.cm-gallery {
  list-style: none; margin: 1rem 0 0; padding: 0;
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}
.cm-gallery figure { margin: 0; }
.cm-gallery img {
  width: 100%; height: 9rem; object-fit: cover; display: block;
  border: 1px solid var(--color-border); border-radius: 6px;
}
.cm-gallery figcaption {
  margin-top: 0.35rem; font-size: 0.9375rem; font-weight: 700;
  color: var(--color-primary);
}

/* ---- Belief heatmap ---- */
.heat-table th[scope="col"] { text-align: center; }
.heat-table th[scope="row"] { font-weight: 700; min-width: 13rem; }
.heat-table td.heat { text-align: center; font-weight: 700; font-size: 1rem; }
.heat--up { background: #e3f0ea; color: #1d5c3e; }
.heat--down { background: #fdeee3; color: #8a4112; }
.heat--none { color: #b8bec4; }
.heat-key { display: inline-block; width: 1.3rem; text-align: center; font-weight: 700; }
.heat-key.heat--up { background: none; color: #1d5c3e; }
.heat-key.heat--down { background: none; color: #8a4112; }
.heat-key.heat--none { background: none; color: #b8bec4; }
.belief-list li { margin-bottom: 0.6rem; }
.belief-list strong { color: var(--color-primary); }
@media (max-width: 40rem) {
  .bars--info li { grid-template-columns: 7rem 1fr 6rem; }
}

/* ---- Theme accordions (improvement plan) ---- */
details {
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-accent);
  border-radius: 0 4px 4px 0;
  padding: 0.9rem 1.25rem;
  margin-bottom: 0.85rem;
  background: var(--color-bg);
}
details summary {
  cursor: pointer;
  color: var(--color-primary);
  font-size: 1.05rem;
  padding: 0.15rem 0;
}
details summary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}
details[open] summary { margin-bottom: 0.5rem; }
details p { max-width: var(--measure); }

/* ---- State data panels ---- */
.state-panel { margin-bottom: 2.5rem; }
.state-panel > h3,
.state-panel > h4 {
  font-size: 1.25rem;
  color: var(--color-primary);
  border-left: 5px solid var(--color-accent);
  padding-left: 0.6rem;
}
.metric { margin: 1.25rem 0; }
.metric h4,
.metric h5 { margin: 0 0 0.2rem; color: var(--color-primary); font-size: 1.05rem; }
.metric .metric-src { font-size: 0.875rem; color: var(--color-text-muted); margin: 0.35rem 0 0; }
.availability { font-size: 0.9375rem; }

/* ---- Print ---- */
@media print {
  .site-nav, .skip-link, .hero .btn, .sop-controls { display: none; }
  body { color: #000; font-size: 12pt; }
  a { color: #000; text-decoration: underline; }
}
