/* ==========================================================================
   GP Prep Companion — ND-Friendly, Trauma-Informed & Clean Clinical Print CSS
   ========================================================================== */

:root {
  --bg: #F5F3F6;
  --surface: #FFFFFF;
  --surface-soft: #ECE7EF;
  --text: #241B2B;
  --text-muted: #57495F;
  --border: #D6CEDB;
  --control-border: #7F708A;
  --accent: #4E2F63;
  --accent-hover: #3D234F;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6DDEC;
  --gold: #A97E2F;
  --gold-text: #7E5B1C;
  --gold-soft: #F2E6C9;
  --ground-bg: #F2E6C9;
  --ground-border: #A97E2F;
  --danger-bg: #F9EAE8;
  --danger-text: #7C2F2B;
  --focus: #A97E2F;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 10px 28px -20px rgba(40, 20, 50, 0.3);
  --font-display: "Young Serif", Georgia, "Times New Roman", serif;
  --font-sans: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", Verdana, system-ui, -apple-system, sans-serif;
  --base-size: 16px;
}

body[data-theme="dark"] {
  --bg: #18131C;
  --surface: #211A26;
  --surface-soft: #2A2231;
  --text: #EDE8F0;
  --text-muted: #B9AEC1;
  --border: #3A3042;
  --control-border: #9687A3;
  --accent: #CDB0E3;
  --accent-hover: #DFC9F0;
  --accent-ink: #1E1424;
  --accent-soft: #33263D;
  --gold: #D9A94F;
  --gold-text: #E8C073;
  --gold-soft: #3A3120;
  --ground-bg: #3A3120;
  --ground-border: #D9A94F;
  --danger-bg: #3D2528;
  --danger-text: #F2B1AC;
  --focus: #D9A94F;
}

body[data-theme="contrast"] {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-soft: #F3EFF5;
  --text: #111111;
  --text-muted: #2B2430;
  --border: #4A3D54;
  --control-border: #241B2B;
  --accent: #3B1E50;
  --accent-hover: #271236;
  --accent-ink: #FFFFFF;
  --accent-soft: #EAE0F2;
  --gold: #7E5B1C;
  --gold-text: #5A4300;
  --gold-soft: #FFF1B8;
  --ground-bg: #FFF1B8;
  --ground-border: #5A4300;
  --danger-bg: #FCE6E2;
  --danger-text: #7A1C0D;
  --focus: #000000;
  --shadow: none;
}

body[data-text="large"] { --base-size: 19px; }

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--base-size); line-height: 1.6; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: 0.6rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.container { width: 100%; max-width: 810px; margin: 0 auto; padding: 0 1.25rem; }

.top-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0.85rem 0; }
.top-bar-inner { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.brand { display: flex; flex-direction: column; }
.hub-link { display: inline-flex; align-items: center; min-height: 30px; font-size: 0.8rem; color: var(--accent); text-decoration: none; font-weight: 600; }
.hub-link:hover { text-decoration: underline; }
.brand-title { font-weight: 700; color: var(--text); line-height: 1.2; }

.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-btn {
  font: inherit; font-size: 0.82rem; min-height: 40px; padding: 0.4rem 0.82rem;
  border-radius: 999px; border: 1.5px solid var(--control-border);
  background: var(--surface-soft); color: var(--text); cursor: pointer;
}
.chip-ground { background: var(--ground-bg); border-color: var(--ground-border); font-weight: 600; }
.chip-privacy { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
body[data-theme="dark"] .chip-privacy { color: var(--text); }

.main-shell { flex: 1; padding: 1.7rem 0 2.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
}

.eyebrow, .step-tag {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; }
h1 { margin: 0 0 0.65rem; font-size: 1.9rem; line-height: 1.2; }
h2 { margin: 0 0 0.45rem; font-size: 1.32rem; line-height: 1.25; }
h3 { margin: 0 0 0.35rem; font-size: 1.06rem; }

.sandbox-pill {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.14rem 0.48rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold-text);
  border: 1px solid var(--gold);
  vertical-align: middle;
  margin-left: 0.4rem;
}
.lead { margin: 0 0 1.2rem; font-size: 1.03rem; color: var(--text-muted); }
.section-intro { margin: 0 0 1rem; font-size: 0.93rem; color: var(--text-muted); }
.fine-note { margin: 0.95rem 0 0; font-size: 0.85rem; color: var(--text-muted); }

.privacy-strip {
  display: flex; align-items: flex-start; gap: 0.65rem;
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.85rem 1rem; font-size: 0.9rem;
}
.dot-safe {
  flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); margin-top: 0.46rem;
}

/* Selectable Chips */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.48rem 0.9rem;
  border-radius: 999px;
  border: 1.5px solid var(--control-border);
  background: var(--bg);
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
}

.toggle-chip input { position: absolute; opacity: 0; pointer-events: none; }

.toggle-chip:has(input:checked) {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.toggle-chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Pattern Groups */
.pattern-groups { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.pattern-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.95rem 1.05rem;
}
.pattern-group h3 { font-size: 0.96rem; margin-bottom: 0.6rem; }
.pattern-group .chip-grid { margin-bottom: 0; }

/* Check Stack */
.check-stack { display: flex; flex-direction: column; gap: 0.55rem; margin-bottom: 1rem; }
.check-item {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--control-border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.92rem;
}
.check-item input {
  margin-top: 0.15rem; min-width: 24px; min-height: 24px; width: 24px; height: 24px;
  accent-color: var(--accent); flex: 0 0 auto;
}

/* Form Inputs */
.field-label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.35rem; }
.text-input, .select-input {
  width: 100%;
  font: inherit;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--control-border);
  background: var(--bg);
  color: var(--text);
}
.inline-field { max-width: 420px; }

/* Buttons */
.actions-row { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  font: inherit; font-weight: 600; font-size: 0.93rem;
  padding: 0.68rem 1.25rem; border-radius: 999px;
  border: 1.5px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--control-border); }
.btn-danger-soft { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-text); }

.status-msg { min-height: 1.3em; margin: 0.7rem 0 0; font-size: 0.88rem; color: var(--accent); font-weight: 600; }

/* Printable GP Sheet */
.gp-sheet { border: 2px solid var(--border); }
.sheet-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  border-bottom: 2px solid var(--border); padding-bottom: 0.85rem; margin-bottom: 1.15rem;
  flex-wrap: wrap;
}
.sheet-title { font-size: 1.45rem; margin: 0 0 0.15rem; }
.sheet-sub { margin: 0; font-size: 0.86rem; color: var(--text-muted); }
.sheet-date { font-size: 0.88rem; font-weight: 600; color: var(--text-muted); }

.sheet-section { margin-bottom: 1.05rem; }
.sheet-section h3 {
  font-size: 0.92rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); margin: 0 0 0.4rem;
}
.sheet-section ul { margin: 0; padding-left: 1.2rem; }
.sheet-section li { margin-bottom: 0.25rem; font-size: 0.94rem; }
.sheet-section p { margin: 0.25rem 0 0; font-size: 0.94rem; }
.sheet-callout {
  background: var(--ground-bg);
  border-left: 4px solid var(--ground-border);
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 1.05rem;
}
.sheet-footer {
  margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted);
}

.support-card { background: var(--surface-soft); font-size: 0.9rem; }
.support-card p { margin: 0.4rem 0 0; color: var(--text-muted); }

/* Modals */
.modal {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  max-width: 560px; width: calc(100% - 2rem); padding: 0;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
}
.modal::backdrop { background: rgba(25, 30, 27, 0.55); }
.modal-inner { padding: 1.5rem; }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.ground-steps {
  background: var(--ground-bg); border: 1px solid var(--ground-border);
  border-radius: var(--radius-sm); padding: 0.9rem 1.05rem; margin: 0.9rem 0 1.2rem; font-size: 0.92rem;
}
.ground-steps ul, .privacy-list { margin: 0; padding-left: 1.2rem; }
.ground-steps li, .privacy-list li { margin-bottom: 0.45rem; font-size: 0.92rem; }
.privacy-list { margin: 0.85rem 0 1.2rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.65rem; flex-wrap: wrap; }
.modal-footer-split { justify-content: space-between; }

.site-footer { padding: 1.2rem 0 1.8rem; text-align: center; font-size: 0.84rem; color: var(--text-muted); }
.site-footer a { color: var(--accent); font-weight: 600; padding: 0.2rem; display: inline-block; }

h1, h2, h3 { scroll-margin-top: 1.5rem; }

@media (forced-colors: active) {
  .btn, .chip-btn, .toggle-chip, .check-item, .text-input, .select-input, .card { border: 2px solid ButtonText; }
  .toggle-chip:has(input:checked) { background: Highlight; color: HighlightText; border: 3px solid Highlight; }
  :focus-visible { outline: 3px solid Highlight; }
}

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

@media print {
  body { background: #ffffff !important; color: #111111 !important; font-size: 10.5pt; line-height: 1.45; }
  .no-print { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .gp-sheet { border: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
  .sheet-section { break-inside: avoid; margin-bottom: 0.75rem; }
  .sheet-callout { background: #f4f7f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
