/* =========================================================================
   Save SR-17018 — design system
   Serious civic / public-health aesthetic. WCAG AA contrast. Mobile-first.
   Hand-written (no framework) so it works offline with zero dependencies.
   ========================================================================= */

:root {
  /* Palette (all text pairings meet WCAG AA on their intended backgrounds) */
  --ink:        #0B2440;  /* body text / headings on white  (~14:1) */
  --navy-700:   #12395B;  /* section headers / dark bands */
  --navy-900:   #0A1F36;  /* footer */
  --slate-600:  #475569;  /* secondary text on white (~7.5:1) */
  --slate-400:  #94A3B8;
  --teal:       #0F6E68;  /* primary CTA (white text ~5.1:1) */
  --teal-dark:  #0B5A55;
  --amber:      #B45309;  /* sparing emphasis / stats (~5.2:1 on white) */
  --error:      #B42318;
  --success:    #0F6E68;

  --page:       #F8FAFC;
  --card:       #FFFFFF;
  --band:       #EEF2F6;
  --band-2:     #E2E8F0;
  --line:       #D6DEE8;

  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 2px rgba(11,36,64,.06), 0 4px 16px rgba(11,36,64,.06);
  --shadow-lg:  0 8px 30px rgba(11,36,64,.12);

  --container:  72rem;
  --measure:    42rem;   /* readable line length */

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

/* --------------------------------------------------------------- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  line-height: 1.6;
  font-size: 1.02rem;
}
h1, h2, h3, h4 { line-height: 1.2; color: var(--ink); margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); letter-spacing: -.01em; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1rem; }
a { color: var(--teal-dark); text-underline-offset: 2px; }
a:hover { color: var(--teal); }
img { max-width: 100%; height: auto; }
ul, ol { padding-left: 1.25rem; }
small { font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* Visible, high-contrast focus for keyboard users */
:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --------------------------------------------------------- skip link ---- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ---------------------------------------------------------- layout ------ */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 1.1rem; }
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section--band { background: var(--band); border-block: 1px solid var(--line); }
.section--dark { background: var(--navy-700); color: #E9F0F6; }
.section--dark h1, .section--dark h2, .section--dark h3 { color: #fff; }
.section__head { max-width: var(--measure); margin-bottom: 1.75rem; }
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: .9rem; }
.muted { color: var(--slate-600); }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }

.grid { display: grid; gap: 1.1rem; }
/* Grid/flex items default to min-width:auto, which can push a wide child past
   the viewport. Reset so tracks shrink and inner scrollers (.table-wrap) work. */
.grid > * { min-width: 0; }
.card { overflow-wrap: break-word; }
@media (min-width: 640px) { .grid--2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 860px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---------------------------------------------------------- buttons ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; line-height: 1.1; text-decoration: none;
  padding: .7rem 1.15rem; border-radius: var(--radius-sm); border: 1.5px solid transparent;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .05s;
  min-height: 44px;  /* touch target */
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-dark); color: #fff; }
.btn--secondary { background: #fff; color: var(--navy-700); border-color: var(--line); }
.btn--secondary:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn--ghost { background: transparent; color: var(--navy-700); border-color: transparent; }
.btn--ghost:hover { background: var(--band); }
.btn--lg { padding: .95rem 1.6rem; font-size: 1.08rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

/* copied state (semantic class toggled by JS — NOT a utility, purge-safe) */
.btn.is-copied { background: var(--success); color: #fff; border-color: var(--success); }

/* --------------------------------------------------------- site header -- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.94); backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner { display: flex; align-items: center; gap: 1rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand__mark { font-size: 1.6rem; }
.brand__name { display: block; font-weight: 800; letter-spacing: -.01em; }
.brand__tagline { display: block; font-size: .72rem; color: var(--slate-600); text-transform: uppercase; letter-spacing: .06em; }
.site-header__cta { display: none; }
@media (min-width: 900px) { .site-header__cta { display: inline-flex; } }

/* Nav: native <details> disclosure — keyboard/AT friendly, no JS */
.nav__disclosure { position: relative; }
.nav__toggle {
  list-style: none; cursor: pointer; padding: .55rem .9rem; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); font-weight: 600; color: var(--navy-700); user-select: none;
}
.nav__toggle::-webkit-details-marker { display: none; }
.nav__list {
  position: absolute; right: 0; top: calc(100% + .5rem); z-index: 50;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .4rem; margin: 0; list-style: none; min-width: 220px;
}
.nav__list a { display: block; padding: .6rem .8rem; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; }
.nav__list a:hover { background: var(--band); color: var(--teal-dark); }

@media (min-width: 900px) {
  .nav__toggle { display: none; }
  .nav__disclosure { position: static; }
  .nav__list {
    position: static; display: flex; box-shadow: none; border: 0; background: transparent;
    padding: 0; min-width: 0; gap: .1rem;
  }
  .nav__list a { padding: .5rem .7rem; font-weight: 600; color: var(--navy-700); }
}
/* On desktop the disclosure is always "open" visually */
@media (min-width: 900px) { .nav__disclosure > .nav__list { display: flex; } }

/* ------------------------------------------------------------- hero ----- */
.hero { background: linear-gradient(180deg, #fff 0%, var(--band) 100%); border-bottom: 1px solid var(--line); }
.hero__inner { padding: clamp(2.5rem, 6vw, 4.5rem) 0; max-width: 52rem; }
.hero .eyebrow { color: var(--amber); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.hero h1 { margin-top: .5rem; }
.hero__sub { font-size: 1.15rem; color: var(--slate-600); max-width: 46rem; }
.hero .btn-row { margin-top: 1.5rem; }

/* ------------------------------------------------------------- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card--accent { border-left: 4px solid var(--teal); }
.card--warn { border-left: 4px solid var(--amber); background: #FFFBEB; }
.card__icon { font-size: 1.5rem; }

/* stat tiles */
.stat { text-align: center; }
.stat__num { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; color: var(--navy-700); font-variant-numeric: tabular-nums; }
.stat__label { color: var(--slate-600); font-size: .9rem; }

/* --------------------------------------------------------- accordions --- */
.accordion { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.accordion + .accordion { margin-top: .75rem; }
.accordion > summary {
  cursor: pointer; padding: 1rem 1.15rem; font-weight: 700; color: var(--navy-700);
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::after { content: "+"; font-size: 1.4rem; color: var(--teal); font-weight: 400; }
.accordion[open] > summary::after { content: "–"; }
.accordion > summary:hover { background: var(--band); }
.accordion__body { padding: 0 1.15rem 1.15rem; max-width: var(--measure); }
.accordion__body p { white-space: pre-line; }

/* ------------------------------------------------------------- lists ---- */
.checklist { list-style: none; padding: 0; }
.checklist li { padding-left: 1.8rem; position: relative; margin-bottom: .6rem; }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: var(--teal); font-weight: 800; }
.crosslist { list-style: none; padding: 0; }
.crosslist li { padding-left: 1.8rem; position: relative; margin-bottom: .5rem; }
.crosslist li::before { content: "✕"; position: absolute; left: 0; color: var(--error); font-weight: 800; }

/* ------------------------------------------------------------ banners --- */
.safety-banner { background: #FFF7ED; border-bottom: 1px solid #FED7AA; color: #7C2D12; }
.safety-banner .container { padding-block: .6rem; font-size: .9rem; }
.safety-banner strong { color: #7C2D12; }

.notice {
  border: 1px solid var(--line); border-left: 4px solid var(--amber);
  background: #FFFBEB; border-radius: var(--radius-sm); padding: .9rem 1.1rem; margin: 1rem 0;
}
.notice--info { border-left-color: var(--teal); background: #F0FBFA; }

.flash { padding: .9rem 1.1rem; border-radius: var(--radius-sm); margin: 1rem 0; border: 1px solid; }
.flash--success { background: #F0FDF4; border-color: #86EFAC; color: #14532D; }
.flash--error { background: #FEF2F2; border-color: #FCA5A5; color: #7F1D1D; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .2rem .5rem; border-radius: 999px; }
.badge--example { background: var(--band-2); color: var(--slate-600); }
.badge--verified { background: #DCFCE7; color: #14532D; }
.badge--pending { background: #FEF3C7; color: #78350F; }

/* ------------------------------------------------------------- forms ---- */
.field { margin-bottom: 1rem; }
.field > label, .field-label { display: block; font-weight: 600; margin-bottom: .3rem; color: var(--ink); }
.field .req { color: var(--error); }
.field .hint { display: block; font-weight: 400; color: var(--slate-600); font-size: .85rem; margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem;
}
textarea { min-height: 8rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline-offset: 0; }
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--error); background: #FEF2F2; }
.field__error { color: var(--error); font-size: .85rem; margin-top: .3rem; }
[aria-invalid="true"] { border-color: var(--error); }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .4rem; color: var(--navy-700); }

/* option cards (radio/checkbox that look like selectable cards) */
.options { display: grid; gap: .6rem; }
.option {
  display: flex; gap: .7rem; align-items: flex-start; padding: .8rem .9rem;
  border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer;
}
.option:hover { border-color: var(--teal); }
.option input { margin-top: .2rem; width: auto; accent-color: var(--teal); }
.option__title { font-weight: 600; }
.option__desc { color: var(--slate-600); font-size: .88rem; }
.option:has(input:checked) { border-color: var(--teal); background: #F0FBFA; box-shadow: inset 0 0 0 1px var(--teal); }

.form-grid { display: grid; gap: .3rem 1rem; }
@media (min-width: 620px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } }

.consent { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: .7rem; }
.consent input { margin-top: .25rem; width: auto; accent-color: var(--teal); }

/* ------------------------------------------------------------ wizard ---- */
.wizard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.wizard__steps { display: flex; flex-wrap: wrap; gap: .25rem; padding: .8rem 1rem; background: var(--band); border-bottom: 1px solid var(--line); font-size: .85rem; }
.wizard__step { display: flex; align-items: center; gap: .4rem; padding: .25rem .6rem; border-radius: 999px; color: var(--slate-600); }
.wizard__step[aria-current="step"] { background: var(--navy-700); color: #fff; font-weight: 600; }
.wizard__step .n { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 999px; background: #fff; color: var(--navy-700); font-size: .78rem; font-weight: 700; }
.wizard__step[aria-current="step"] .n { background: var(--teal); color: #fff; }
.wizard__panel { padding: 1.4rem; }
.wizard__panel[hidden] { display: none; }
.wizard__nav { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1.4rem; }

/* editable output */
.output-area textarea { min-height: 20rem; font-family: var(--serif); font-size: 1rem; line-height: 1.55; }
.recipient-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.recipient-list li { padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: .4rem; background: var(--band); }
.recipient-list a { font-weight: 600; }

/* error summary */
.error-summary { border: 1.5px solid var(--error); background: #FEF2F2; border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.error-summary h3 { color: var(--error); margin: 0 0 .5rem; }
.error-summary ul { margin: 0; }

/* --------------------------------------------------------- CTA blocks --- */
.cta-band { background: var(--navy-700); color: #fff; border-radius: var(--radius); padding: clamp(1.5rem,4vw,2.5rem); }
.cta-band h2 { color: #fff; }
.cta-band .btn--secondary { background: #fff; }

/* ------------------------------------------------------------- table ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
table.data th { background: var(--band); }

/* ---------------------------------------------------------- footer ------ */
.site-footer { background: var(--navy-900); color: #C7D3E0; margin-top: 3rem; padding: 2.5rem 0 2rem; }
.site-footer a { color: #fff; }
.site-footer__grid { display: grid; gap: 1.5rem; }
@media (min-width: 720px) { .site-footer__grid { grid-template-columns: 1fr 1fr; } }
.site-footer__brand { font-weight: 800; color: #fff; font-size: 1.1rem; margin: 0; }
.site-footer__links { list-style: none; padding: 0; margin: 0; columns: 2; }
.site-footer__links li { margin-bottom: .5rem; }
.site-footer__legal { border-top: 1px solid rgba(255,255,255,.15); margin-top: 1.75rem; padding-top: 1.25rem; font-size: .85rem; }
.site-footer__legal .muted { color: #94A3B8; }

/* --------------------------------------------------------- utilities ---- */
.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; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
[hidden] { display: none !important; }

/* copy status live region */
.copy-status { color: var(--success); font-weight: 600; font-size: .9rem; min-height: 1.2em; }

/* ============================================================ PRINT ====== */
/* On screen the letter node is hidden; it only appears when printing. */
.print-only { display: none; }
@media print {
  @page { margin: 0.9in; }
  html, body { background: #fff !important; color: #000 !important; }

  /* Print ONLY the generated letters. #printable-letter is a direct <body>
     child, so hiding every other top-level element leaves just the letters. */
  body > *:not(#printable-letter) { display: none !important; }

  #printable-letter {
    display: block !important;
    font-family: var(--serif);
    font-size: 11pt;
    line-height: 1.35;       /* tight enough that a standard letter fits one page */
    color: #000;
    white-space: pre-wrap;   /* preserve each letter's line breaks */
  }

  /* One letter per recipient, each starting on a fresh page. A very long letter
     (e.g. with a long personal story) may still flow onto a second page. */
  #printable-letter .printable-letter { break-after: page; page-break-after: always; }
  #printable-letter .printable-letter:last-child { break-after: auto; page-break-after: auto; }

  a[href]::after { content: ""; }  /* don't append raw URLs after links */
}

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