/* ==========================================================================
   quitOH.ca design system
   Calm, private, hopeful. Light and dark themes, text-size control,
   reduced-motion support. WCAG 2.2 AA contrast targets throughout.
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  /* Light theme (default) */
  --bg: #faf7f2;
  --bg-raised: #ffffff;
  --bg-soft: #f0ebe2;
  --bg-tint: #e6efeb;
  --ink: #22332e;
  --ink-soft: #465953;
  --ink-faint: #5f6f6a;
  --brand: #2c6e63;
  --brand-strong: #235850;
  --brand-soft: #dcebe6;
  --accent: #b97b34;
  --accent-soft: #f5e8d6;
  --line: #ddd6ca;
  --line-soft: #e8e2d7;
  --focus: #1f5a95;
  --care: #8a5a2b;        /* warm supportive notice text */
  --care-bg: #f7edda;     /* warm supportive notice background */
  --urgent: #8c3b2e;      /* calm but clear urgent text */
  --urgent-bg: #f6e4de;   /* urgent background, warm not alarming */
  --ok: #2f6b3f;
  --ok-bg: #e2efe2;
  --shadow: 0 1px 2px rgba(34, 51, 46, 0.06), 0 8px 24px rgba(34, 51, 46, 0.07);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 68rem;
  --maxw-text: 44rem;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #16211e;
  --bg-raised: #1d2b27;
  --bg-soft: #212f2b;
  --bg-tint: #223531;
  --ink: #e9e5dc;
  --ink-soft: #c2c9c4;
  --ink-faint: #a7b2ac;
  --brand: #86c4b4;
  --brand-strong: #a3d5c7;
  --brand-soft: #27403a;
  --accent: #d9a869;
  --accent-soft: #3a3122;
  --line: #33453f;
  --line-soft: #2b3b36;
  --focus: #8db8e8;
  --care: #e3bd82;
  --care-bg: #33301f;
  --urgent: #e2a191;
  --urgent-bg: #3a2721;
  --ok: #9fce9f;
  --ok-bg: #24352a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* Text size control: html[data-textsize] set by JS */
html { font-size: 100%; }
html[data-textsize="large"] { font-size: 112.5%; }
html[data-textsize="larger"] { font-size: 125%; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.22;
  color: var(--ink);
  margin: 0 0 0.6em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 4.2vw, 2.9rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.45rem, 2.8vw, 1.95rem); }
h3 { font-size: 1.22rem; }
h4 { font-size: 1.05rem; font-family: var(--font-sans); font-weight: 650; }

p, ul, ol { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.35em; }
li { margin-bottom: 0.4em; }

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

strong { font-weight: 650; }
small, .small { font-size: 0.9rem; color: var(--ink-soft); }

hr { border: none; border-top: 1px solid var(--line-soft); margin: 2.5rem 0; }

img, svg { max-width: 100%; height: auto; }

::selection { background: var(--brand-soft); }

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

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg-raised);
  color: var(--ink);
  padding: 0.7rem 1.1rem;
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
  box-shadow: var(--shadow);
}
.skip-link:focus { left: 0; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }
.wrap-text { max-width: var(--maxw-text); margin: 0 auto; padding: 0 1.25rem; }

main { display: block; }
section { padding: 3rem 0; }
section.tint { background: var(--bg-tint); }
section.soft { background: var(--bg-soft); }

.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 38em; }

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

/* ---------- Header ---------- */
.site-header {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  max-width: var(--maxw);
  margin: 0 auto;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.logo .oh { color: var(--brand); }
.logo svg { flex-shrink: 0; }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
@media (min-width: 960px) { .nav-toggle { display: none; } }

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.site-nav a {
  display: block;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
}
.site-nav a:hover { background: var(--bg-soft); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--brand-strong); font-weight: 650; }
.site-nav .nav-help a {
  color: var(--care);
  font-weight: 650;
}
.site-nav .nav-cta a {
  background: var(--brand);
  color: #ffffff;
  font-weight: 650;
}
[data-theme="dark"] .site-nav .nav-cta a { color: #10201c; }
.site-nav .nav-cta a:hover { background: var(--brand-strong); }

@media (max-width: 959px) {
  .site-nav {
    display: none;
    border-top: 1px solid var(--line-soft);
    padding: 0.6rem 1.25rem 1rem;
    background: var(--bg-raised);
  }
  .site-nav.open { display: block; }
}
@media (min-width: 960px) {
  .site-nav ul { flex-direction: row; align-items: center; }
}

/* Header utility buttons (theme, text size) */
.util-controls { display: flex; align-items: center; gap: 0.35rem; }
.util-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
}
.util-btn:hover { background: var(--bg-soft); color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  font-size: 1.02rem;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}
.btn-primary { background: var(--brand); color: #ffffff; }
[data-theme="dark"] .btn-primary { color: #10201c; }
.btn-primary:hover { background: var(--brand-strong); color: #ffffff; }
[data-theme="dark"] .btn-primary:hover { color: #10201c; }
.btn-secondary {
  background: transparent;
  color: var(--brand-strong);
  border-color: var(--brand);
}
.btn-secondary:hover { background: var(--brand-soft); }
.btn-quiet {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-quiet:hover { background: var(--bg-soft); color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }

/* ---------- Cards, steps, notices ---------- */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0.15rem; }
.card .icon { margin-bottom: 0.7rem; color: var(--brand); }

.step-list { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.step-list li {
  position: relative;
  padding: 0 0 1.6rem 3.4rem;
  counter-increment: step;
}
.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.05rem;
}
.step-list li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 1.12rem;
  top: 2.6rem;
  bottom: 0.2rem;
  width: 2px;
  background: var(--line-soft);
}
.step-list h3 { margin-bottom: 0.25em; }

.notice {
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin: 1.3rem 0;
  border: 1px solid transparent;
}
.notice p:last-child, .notice ul:last-child { margin-bottom: 0; }
.notice-info { background: var(--bg-tint); border-color: var(--line-soft); }
.notice-care { background: var(--care-bg); color: var(--ink); border-color: rgba(138, 90, 43, 0.3); }
.notice-care strong { color: var(--care); }
.notice-urgent { background: var(--urgent-bg); border-color: rgba(140, 59, 46, 0.35); }
.notice-urgent strong { color: var(--urgent); }
.notice-ok { background: var(--ok-bg); border-color: rgba(47, 107, 63, 0.3); }

.badge {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 0.8rem;
  font-weight: 650;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

/* Trust strip */
.trust-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 2rem;
  padding: 1.1rem 0;
  color: var(--ink-soft);
  font-size: 0.93rem;
}
.trust-strip span { display: inline-flex; align-items: center; gap: 0.45rem; }
.trust-strip svg { color: var(--brand); flex-shrink: 0; }

/* ---------- Hero ---------- */
.hero { padding: 4rem 0 3.2rem; position: relative; overflow: hidden; }
.hero .wrap { position: relative; z-index: 1; }
.hero h1 { max-width: 15em; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 0.9rem; margin: 1.6rem 0 0.8rem; align-items: center; }
.hero-art {
  position: absolute;
  right: -6rem;
  top: -4rem;
  width: 34rem;
  opacity: 0.5;
  pointer-events: none;
}
@media (max-width: 760px) { .hero-art { display: none; } }

/* ---------- FAQ (details/summary) ---------- */
.faq details {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-raised);
  margin-bottom: 0.8rem;
  padding: 0;
}
.faq summary {
  cursor: pointer;
  padding: 1rem 1.3rem;
  font-weight: 650;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-radius: var(--radius);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--brand);
  flex-shrink: 0;
  line-height: 1;
}
.faq details[open] summary::after { content: "\2212"; }
.faq .faq-body { padding: 0 1.3rem 1.1rem; color: var(--ink-soft); }
.faq .faq-body p:last-child { margin-bottom: 0; }

/* ---------- Forms and assessment flow ---------- */
.form-shell {
  max-width: 40rem;
  margin: 0 auto;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.6rem 2.2rem;
}
@media (min-width: 640px) { .form-shell { padding: 2.4rem 2.6rem 2.6rem; } }

.progress {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.8rem;
}
.progress .track {
  flex: 1;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress .fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  width: 0%;
  transition: width 300ms ease;
}
.progress .label { font-size: 0.88rem; color: var(--ink-soft); white-space: nowrap; }

fieldset { border: none; padding: 0; margin: 0 0 1.4rem; }
legend, .q-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  padding: 0;
  color: var(--ink);
}
.q-help { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: 1rem; }

label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.label-optional { font-weight: 400; color: var(--ink-faint); font-size: 0.88rem; }

input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}
textarea { min-height: 6.5rem; resize: vertical; }

.choice-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  cursor: pointer;
  background: var(--bg);
  font-weight: 500;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.choice:hover { border-color: var(--brand); }
.choice input { margin-top: 0.28rem; accent-color: var(--brand); flex-shrink: 0; width: 1.05rem; height: 1.05rem; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice .choice-note { display: block; font-weight: 400; font-size: 0.9rem; color: var(--ink-soft); margin-top: 0.15rem; }

.field-error {
  color: var(--urgent);
  font-size: 0.92rem;
  margin: -0.5rem 0 1rem;
}

.form-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line-soft);
}

.autosave-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  color: var(--ink-faint);
  margin-top: 1rem;
  justify-content: center;
}
.autosave-note svg { color: var(--brand); }

.review-block {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.review-block h4 { margin: 0 0 0.4rem; display: flex; justify-content: space-between; align-items: baseline; }
.review-block .edit-link { font-size: 0.88rem; font-weight: 500; }
.review-block dl { margin: 0; }
.review-block dt { font-size: 0.85rem; color: var(--ink-faint); margin-top: 0.5rem; }
.review-block dd { margin: 0; }

/* Consent block */
.consent-item {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
  font-weight: 400;
}
.consent-item input { margin-top: 0.3rem; accent-color: var(--brand); flex-shrink: 0; width: 1.1rem; height: 1.1rem; }
.consent-item strong { display: block; margin-bottom: 0.15rem; }

/* Dashboard */
.dash-card { margin-bottom: 1.2rem; }
.dash-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 650;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
}
.dash-status.pending { background: var(--accent-soft); color: var(--care); }
.dash-status.done { background: var(--ok-bg); color: var(--ok); }

/* ---------- Tables ---------- */
table { border-collapse: collapse; width: 100%; margin: 1.2rem 0 1.6rem; font-size: 0.98rem; }
caption { text-align: left; font-weight: 650; margin-bottom: 0.5rem; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 650; background: var(--bg-soft); }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--bg-tint);
  border-top: 1px solid var(--line-soft);
  padding: 3rem 0 2rem;
  margin-top: 3rem;
  font-size: 0.94rem;
  color: var(--ink-soft);
}
.site-footer h4 { margin-bottom: 0.6rem; color: var(--ink); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.45rem; }
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--brand-strong); }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: 1fr; margin-bottom: 2rem; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.3fr 1fr 1fr 1fr; } }
.footer-legal { border-top: 1px solid var(--line-soft); padding-top: 1.4rem; font-size: 0.85rem; color: var(--ink-faint); }
.footer-crisis {
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 2rem;
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
}
html { scroll-behavior: smooth; }

.fade-in { animation: fadeIn 420ms ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .util-controls, .nav-toggle { display: none; }
}

/* ---------- Imagery ---------- */
.hero-grid { display: grid; gap: 2.2rem; align-items: center; grid-template-columns: 1fr; }
@media (min-width: 860px) { .hero-grid { grid-template-columns: 1.15fr 0.85fr; } }
.hero-photo {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
  width: 100%;
  height: auto;
}
[data-theme="dark"] .hero-photo, [data-theme="dark"] .photo { opacity: 0.88; }
.photo {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
  width: 100%;
  height: auto;
  margin: 1.4rem 0 1.8rem;
}
.motif { margin: 0 auto; max-width: 30rem; text-align: center; }
.motif img { display: block; width: 100%; height: auto; border-radius: var(--radius); mix-blend-mode: multiply; }
[data-theme="dark"] .motif img { mix-blend-mode: normal; opacity: 0.75; border-radius: var(--radius); }
.textured { background-image: url("../assets/texture-waves.jpg"); background-size: 640px; background-repeat: repeat; }
[data-theme="dark"] .textured { background-image: none; }
.people-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; margin: 1.5rem 0; }
@media (min-width: 620px) { .people-grid { grid-template-columns: 1fr 1fr; } }
.person-card { text-align: center; }
.person-card img { width: 100%; max-width: 15rem; border-radius: var(--radius); margin: 0 auto 0.8rem; display: block; }
.person-card h3 { margin-bottom: 0.15rem; }

.file-chip { display: inline-block; background: var(--brand-soft); color: var(--brand-strong); border-radius: 999px; padding: 0.1rem 0.6rem; margin: 0.15rem 0.2rem 0 0; font-size: 0.85rem; }
input[type="file"] { width: 100%; padding: 0.7rem; border: 1px dashed var(--brand); border-radius: var(--radius-sm); background: var(--bg); margin-bottom: 1rem; font: inherit; }

/* ---------- Staff portal ---------- */
.queue-list { display: grid; gap: 0.9rem; }
.queue-item { text-decoration: none; color: inherit; border-left: 5px solid var(--line); padding: 1.1rem 1.3rem; }
.queue-item:hover { border-color: var(--brand); }
.queue-item.prio-urgent { border-left-color: var(--urgent); }
.queue-item.prio-priority { border-left-color: var(--accent); }
.queue-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.2rem; }
.queue-flags { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.queue-flags .badge { background: var(--accent-soft); color: var(--care); }
.queue-flags .badge.flag-urgentWithdrawal, .queue-flags .badge.flag-urgentMentalHealth, .queue-flags .badge.flag-withdrawalNow { background: var(--urgent-bg); color: var(--urgent); }
.staff-toolbar { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- Utility ---------- */
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 2rem; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
