/**
 * Arbor (K5) — Patient E-Screener Styles
 * Neurodivergent-optimised: calm palette, large targets, generous spacing.
 *
 * Colour and type come from ../shared/brand.css (Brandbook §3/§4). No hex
 * literals live in this file — the previous palette (#1F6F6B teal) was the
 * archived CohortTrials brand and shared no colour with Arbor.
 *
 * WCAG AA: contrast >= 4.5:1, targets >= 44px.
 * Mobile-first: 18px base, 16px from 640px up.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--chalk);
  color: var(--bark);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* The question heading receives programmatic focus on every step; a ring there
   would read as an error rather than as navigation. Every other focusable
   element keeps the shared :focus-visible ring from brand.css. */
.question-text:focus,
.question-text:focus-visible { outline: none; }

/* ---- Brand mark ---- */
.brand-mark-branch { fill: none; stroke: var(--grove); stroke-linecap: round; }
.brand-mark-leaf { fill: var(--canopy); }
.brand-mark-leaf-soft { fill: var(--lichen); }

/* ---- Offline banner ---- */
.offline-banner {
  background: var(--flint-surface); color: var(--flint-text);
  border-bottom: 1px solid var(--flint);
  padding: 10px 20px; font-size: var(--fs-small); font-weight: 500;
  text-align: center;
}

/* ---- Native dialogs ---- */
dialog {
  border: none; border-radius: 12px;
  padding: 24px; max-width: 480px; width: calc(100% - 32px);
  background: var(--paper); color: var(--bark);
  font-family: var(--font-body);
  box-shadow: 0 12px 32px rgba(42, 42, 42, 0.28);
}
dialog::backdrop { background: rgba(42, 42, 42, 0.45); }
dialog h2 { margin-bottom: 12px; font-size: var(--fs-h3); }
dialog input {
  width: 100%; padding: 12px; border: 1.5px solid var(--border-input);
  border-radius: var(--radius); background: var(--paper); color: var(--bark);
  margin: 12px 0; font-family: inherit; font-size: 0.95rem;
}
dialog .dialog-error {
  color: var(--danger); font-size: var(--fs-small); min-height: 1.2em;
}
dialog .dialog-actions {
  display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px;
}
dialog .dialog-actions button {
  min-height: 44px; padding: 0 20px; border-radius: var(--radius);
  border: 1.5px solid var(--grove); background: var(--grove); color: var(--paper);
  font-family: inherit; font-weight: 600; cursor: pointer; font-size: 0.95rem;
}
dialog .dialog-actions button + button {
  background: var(--paper); color: var(--grove);
}

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--paper); border-bottom: 1px solid var(--border);
  padding: 0 20px; min-height: 56px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-title {
  font-family: var(--font-heading);
  font-size: 1rem; font-weight: 600; color: var(--grove);
}
.save-later-btn {
  background: none; border: 1.5px solid var(--canopy); border-radius: 8px;
  color: var(--grove); padding: 8px 16px;
  font-family: var(--font-body); font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
  min-height: 44px;
}
.save-later-btn:hover { background: var(--mist); }

/* ---- Progress ---- */
.progress-wrap { padding: 16px 20px 0; }
.progress-bar {
  width: 100%; height: 8px; background: var(--mist); border-radius: 4px;
  border: 1px solid var(--lichen); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--canopy); border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-text {
  text-align: center; font-size: 0.78rem; color: var(--stone-on-mist);
  margin-top: 6px; font-weight: 600;
}

/* ---- Main Layout ---- */
.screener-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.screen { width: 100%; max-width: 560px; display: none; }
.active-screen { display: block; }

/* ---- Cards ---- */
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 28px;
  box-shadow: 0 2px 12px rgba(42, 42, 42, 0.05);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 10px; cursor: pointer;
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 600; padding: 14px 28px;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  min-height: 48px; min-width: 48px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { cursor: progress; opacity: 0.65; transform: none; }
.btn-primary { background: var(--grove); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: var(--canopy); }
.btn-outline-dark {
  background: var(--paper); color: var(--grove);
  border: 2px solid var(--border-input);
}
.btn-outline-dark:hover:not(:disabled) { background: var(--mist); border-color: var(--canopy); }
.btn-large { width: 100%; padding: 16px; font-size: 1.05rem; }
.btn-small { min-height: 44px; padding: 8px 16px; font-size: 0.85rem; }
.btn-full { width: 100%; }

/* Busy affordance for in-flight requests. */
.btn.is-busy::before {
  content: '';
  width: 0.9em; height: 0.9em; margin-right: 0.5em;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: arbor-spin 0.7s linear infinite;
}
@keyframes arbor-spin { to { transform: rotate(360deg); } }

/* ---- Inline alerts ---- */
.inline-alert {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 20px;
  font-size: 0.9rem; font-weight: 500;
}
.inline-alert .btn { margin-top: 12px; }

/* ---- Welcome ---- */
.welcome-card h1 {
  font-size: var(--fs-h2); margin-bottom: 16px;
}
.welcome-body { font-size: 1rem; color: var(--bark); margin-bottom: 12px; }
.welcome-note {
  font-size: 0.85rem; color: var(--flint-text); margin-bottom: 24px;
  background: var(--flint-surface); padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--flint);
}
.welcome-resume {
  text-align: center; margin-top: 16px; font-size: 0.85rem; color: var(--stone);
}
.welcome-resume a { color: var(--grove); font-weight: 600; text-decoration: underline; }

/* ---- Question ---- */
.question-card { text-align: center; }
.question-text {
  font-family: var(--font-heading);
  font-size: 1.3rem; font-weight: 600; color: var(--grove);
  margin-bottom: 28px; line-height: 1.4;
}
.question-status {
  margin-top: 14px; min-height: 1.2em;
  font-size: 0.8rem; color: var(--stone);
}
.options-container { display: flex; flex-direction: column; gap: 12px; }
.option-btn {
  width: 100%; padding: 16px 20px;
  background: var(--mist); border: 2px solid var(--lichen);
  border-radius: 12px;
  font-family: var(--font-body); font-size: 1rem; font-weight: 600;
  color: var(--bark); cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  min-height: 52px;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--canopy); background: var(--paper);
}
.option-btn:active { transform: scale(0.98); }
.option-btn:disabled { cursor: progress; opacity: 0.7; transform: none; }
.option-btn.selected {
  background: var(--grove); color: var(--paper); border-color: var(--grove);
}

/* ---- Result ---- */
.result-card { text-align: center; }
.result-card h2 { font-size: var(--fs-h3); margin-bottom: 12px; }
.result-card p { font-size: 1rem; color: var(--bark); margin-bottom: 12px; }
.result-caveat { font-size: 0.9rem; color: var(--stone); }
.result-note {
  font-size: 0.85rem; color: var(--flint-text); margin-top: 16px;
  background: var(--flint-surface); padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--flint); text-align: left;
}
.result-match {
  background: var(--ok-bg); border: 2px solid var(--ok);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.result-match h2 { color: var(--ok); }
.result-match p { margin-bottom: 0; }

/* ---- Consent ---- */
.consent-card h2 { font-size: var(--fs-h3); margin-bottom: 8px; }
.consent-card h2:focus-visible { outline: none; }
.consent-body { font-size: 0.95rem; color: var(--bark); margin-bottom: 24px; }
.consent-item {
  margin-bottom: 24px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.consent-item h3 { font-size: 1.05rem; margin-bottom: 8px; }
.consent-item h3:focus-visible { outline: none; }
.consent-item p { font-size: 0.9rem; color: var(--bark); margin-bottom: 14px; }
.consent-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.consent-buttons .btn { flex: 1; min-width: 160px; }
.consent-note {
  font-size: 0.82rem; color: var(--stone); margin-top: 8px;
  font-style: italic;
}

/* ---- Exit ---- */
.exit-card h2 { font-size: var(--fs-h3); margin-bottom: 12px; }
.exit-card p { font-size: 0.95rem; color: var(--bark); margin-bottom: 12px; }
.exit-note {
  font-size: 0.82rem; color: var(--flint-text); margin-top: 12px;
  background: var(--flint-surface); padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--flint);
}

/* ---- Portfolio badge (Brandbook §7) ---- */
.portfolio-badge {
  padding: 20px 16px 28px;
  text-align: center;
}
.portfolio-badge p {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--stone-on-mist);
  margin: 0 auto;
  max-width: 560px;
}

/* ---- Responsive ---- */
@media (min-width: 640px) {
  html { font-size: 16px; }
  .screener-main { padding: 40px 24px; }
  .card { padding: 48px 40px; }
}
