/* Hopeful and prepared: one stylesheet, mobile first (360 px), system fonts only. */

/* ---------- Colours (light, then dark) ---------- */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1d2125;
  --muted: #4f5761;
  --accent: #0e6655;       /* links and highlights, 6.7:1 on --bg */
  --accent-soft: #e2f0ec;
  --border: #d9d5cc;
  --weak: #9c2f2f;
  --weak-soft: #f8e9e7;
  --focus: #1a56db;
  --radius: 10px;
  --measure: 44rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191d;
    --surface: #1f2328;
    --text: #e9e7e3;
    --muted: #b3b8bf;
    --accent: #6fd6c0;
    --accent-soft: #1d3530;
    --border: #3a4047;
    --weak: #f0a39b;
    --weak-soft: #3a2424;
    --focus: #8ab4ff;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

main, .footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.125rem;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 2.25rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.125rem; margin: 1.5rem 0 0.5rem; }
h2 + h3 { margin-top: 0.75rem; }
p { margin: 0 0 0.75rem; }

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 0.5rem; top: -4rem; z-index: 20;
  background: var(--surface); color: var(--accent);
  padding: 0.5rem 0.75rem; border-radius: var(--radius);
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Sticky jump menu ---------- */
.jump {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.jump details { max-width: var(--measure); margin: 0 auto; position: relative; }
.jump summary {
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 1.125rem;
  font-weight: 600;
  min-height: 48px;
  display: flex; align-items: center; justify-content: space-between;
}
.jump summary::-webkit-details-marker { display: none; }
.jump summary::after {
  content: "";
  width: 0.55rem; height: 0.55rem;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-25%);
  transition: transform 0.15s;
}
.jump details[open] summary::after { transform: rotate(-135deg) translateY(-25%); }
.jump ol {
  position: absolute; left: 0; right: 0; top: 100%;
  margin: 0; padding: 0.25rem 0;
  list-style: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 20px rgb(0 0 0 / 0.12);
  max-height: calc(100vh - 4rem);
  max-height: calc(100dvh - 4rem);
  overflow-y: auto;
}
.jump li a {
  display: block;
  padding: 0.7rem 1.125rem;
  text-decoration: none;
  color: var(--text);
}
.jump li a:hover { background: var(--accent-soft); }

/* ---------- Sections ---------- */
.section {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 3.5rem; /* keeps headings clear of the sticky menu */
}
.intro { padding-top: 2.5rem; }
.lead { font-size: 1.2rem; margin-top: 0.75rem; }
.byline { color: var(--muted); margin: 0; }
.note { color: var(--muted); font-size: 0.95rem; }

ul, ol { padding-left: 1.25rem; margin: 0 0 0.75rem; }
li { margin-bottom: 0.4rem; }

/* Lists of links: roomy tap targets */
.links { list-style: none; padding: 0; }
.links li { padding: 0.55rem 0; border-bottom: 1px solid var(--border); margin: 0; }
.links li:last-child { border-bottom: 0; }

/* Placeholder for links not supplied yet */
.placeholder {
  display: inline-block;
  color: var(--muted);
  border: 1px dashed var(--muted);
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  font-style: italic;
}

/* Numbered cards for "Do this first" */
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 0.85rem 3.25rem;
  margin-bottom: 0.6rem;
  font-weight: 500;
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 0.9rem; top: 0.8rem;
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--bg);
  font-weight: 700; font-size: 0.95rem;
}

/* Selection stages: a simple wrapped chain */
.stages {
  list-style: none; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.stages li {
  margin: 0;
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.95rem;
}
.stages li:not(:last-child)::after { content: " \2192"; color: var(--muted); }

/* Timeline */
.timeline { list-style: none; padding: 0 0 0 1rem; border-left: 3px solid var(--border); }
.timeline li { position: relative; padding-left: 0.5rem; margin-bottom: 0.9rem; }
.timeline li::before {
  content: ""; position: absolute; left: -1.5rem; top: 0.45rem;
  width: 0.75rem; height: 0.75rem; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--muted);
}
.timeline li.now::before { background: var(--accent); border-color: var(--accent); }
.timeline strong { display: block; }

/* Formula and rule of thumb */
.formula, .rule {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.75rem 1rem;
}
.formula { font-size: 1.2rem; font-weight: 600; }

/* Copyable templates */
.copy-block { margin-bottom: 1rem; }
pre {
  margin: 0 0 0.5rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap; /* wraps on phones instead of scrolling sideways */
}

button {
  font: inherit;
  font-size: 0.95rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.copy-btn { background: var(--accent); color: var(--bg); border: 2px solid var(--accent); font-weight: 600; }
.plain-btn { background: transparent; color: var(--text); border: 2px solid var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

/* 90-day checklist */
.checklist fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 0 0 0.75rem;
  padding: 0.5rem 1rem 0.75rem;
}
.checklist legend { font-weight: 700; padding: 0 0.35rem; }
.checklist label {
  display: flex; align-items: flex-start; gap: 0.65rem;
  padding: 0.45rem 0;
  cursor: pointer;
}
.checklist input {
  width: 1.3rem; height: 1.3rem; margin: 0.2rem 0 0; flex: none;
  accent-color: var(--accent);
}
.checklist label:has(input:checked) { color: var(--muted); text-decoration: line-through; }

/* AI loop: numbered chips */
.loop { list-style: none; padding: 0; counter-reset: loop; display: grid; gap: 0.4rem; }
.loop li {
  counter-increment: loop; margin: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.5rem 0.85rem; font-weight: 600;
}
.loop li::before { content: counter(loop) ". "; color: var(--accent); }

/* Weak vs strong prompt */
.prompts { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.prompt { margin: 0; border-radius: var(--radius); padding: 0.75rem 1rem; border: 1px solid var(--border); }
.prompt figcaption { font-weight: 700; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; }
.prompt blockquote { margin: 0.35rem 0 0; }
.prompt blockquote p { margin: 0; }
.prompt.weak { background: var(--weak-soft); }
.prompt.weak figcaption { color: var(--weak); }
.prompt.strong { background: var(--accent-soft); }
.prompt.strong figcaption { color: var(--accent); }

/* Rescue plan */
.rescue { padding-left: 1.5rem; }
.rescue strong { display: block; }

/* Evidence table: cards on phones, a table on wider screens */
.evidence { width: 100%; border-collapse: collapse; }
.evidence thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.evidence tr {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.evidence th[scope="row"] { display: block; text-align: left; font-size: 1.35rem; color: var(--accent); }
.evidence td { display: block; padding: 0.15rem 0; }
.evidence td[data-label="Date"] { color: var(--muted); font-size: 0.95rem; }

.footer { padding: 1.5rem 1.125rem 3rem; color: var(--muted); font-size: 0.95rem; }
.footer p { margin: 0 0 0.4rem; }

/* ---------- Wider screens ---------- */
@media (min-width: 40rem) {
  h1 { font-size: 3rem; }
  .prompts { grid-template-columns: 1fr 1fr; }
  .loop { grid-template-columns: repeat(5, 1fr); }
  .loop li { text-align: center; }

  .evidence thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .evidence tr { display: table-row; background: none; border: 0; padding: 0; }
  .evidence th, .evidence td {
    display: table-cell;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left; vertical-align: top;
  }
  .evidence thead th { font-size: 0.9rem; color: var(--muted); }
  .evidence th[scope="row"] { font-size: 1.05rem; white-space: nowrap; }
  .evidence td[data-label="Date"] { white-space: nowrap; }
}

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

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 1cm; }
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --accent: #000; --accent-soft: #fff; --weak-soft: #fff; --border: #bbb; }
  body { font-size: 8.5pt; line-height: 1.25; }
  .prompts { align-items: start; }
  .jump, .skip-link, button, .actions, .footer p:last-child, #ninety-days .note { display: none !important; }
  main, .footer { max-width: none; padding: 0; }
  .section { padding: 0.25rem 0; border: 0; }
  .intro { padding-top: 0; }
  .lead { font-size: 10pt; margin: 0.2rem 0; }
  h1 { font-size: 18pt; }
  h2 { font-size: 12pt; margin: 0.3rem 0 0.2rem; }
  h3 { font-size: 10pt; margin: 0.35rem 0 0.15rem; }
  p, ul, ol, li { margin-bottom: 0.15rem; }
  .steps li, .checklist fieldset, .prompt, .loop li, .evidence tr { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  .note, .stages li, .byline, .footer, .evidence thead th { font-size: 8pt; }
  .prompt figcaption { font-size: 8pt; }
  #readme-template { columns: 2; }
  .steps li { padding: 0.15rem 0.5rem 0.15rem 1.9rem; margin-bottom: 0.2rem; }
  .steps li::before { top: 0.15rem; left: 0.4rem; width: 1.1rem; height: 1.1rem; font-size: 8pt; color: #fff; }
  .links li { padding: 0.05rem 0; border: 0; }
  .links a::after, .evidence a::after { content: " (" attr(href) ")"; font-size: 7pt; word-break: break-all; }
  .stages li { padding: 0 0.3rem; }
  .timeline { border: 0; padding-left: 0; }
  .timeline li { padding: 0; margin-bottom: 0.1rem; }
  .timeline li::before { display: none; }
  .timeline strong, .rescue strong { display: inline; margin-right: 0.3rem; }
  .formula, .rule { padding: 0.2rem 0.6rem; font-size: 10pt; }
  pre { font-size: 7.5pt; line-height: 1.25; padding: 0.3rem 0.5rem; margin-bottom: 0.2rem; }
  .copy-block { margin-bottom: 0.2rem; }
  .checklist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
  .checklist fieldset { padding: 0.2rem 0.5rem; margin: 0; }
  .checklist label { padding: 0; gap: 0.35rem; }
  .checklist input { width: 0.9rem; height: 0.9rem; margin-top: 0.1rem; }
  .loop { grid-template-columns: repeat(5, 1fr); }
  .loop li { padding: 0.15rem 0.3rem; }
  .prompts { grid-template-columns: 1fr 1fr; margin-bottom: 0.2rem; gap: 0.4rem; }
  .prompt { padding: 0.25rem 0.5rem; }
  .evidence thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .evidence tr { display: table-row; border: 0; padding: 0; }
  .evidence th, .evidence td, .evidence td[data-label="Date"] { display: table-cell; padding: 0.15rem 0.3rem; border-bottom: 1px solid #bbb; text-align: left; vertical-align: top; font-size: 8pt; }
  .evidence th[scope="row"] { font-size: 8pt; }
  .footer { padding: 0.3rem 0 0; }
}
