/*
  Public Brain Health Intake. Visual design follows the ops team's prototype
  (reference/ops-apps-script/index.html): full-bleed screens, centred wordmark,
  thin progress thread, ink pill + round back button at the foot, in Preview
  Health's ink/violet palette. Deliberately single-themed — a branded product
  surface.

  Choice options are real radio/checkbox inputs inside a label, styled with
  :has(), so everything works without JavaScript; intake.js only adds the
  extras (follow-ups appearing, scroll wheels, "add another").
*/
:root {
  --ink: #272b40;
  --bg: #ffffff;
  --tint: #f6f5fa;
  --accent: #a85aff;
  --accent-ink: #2b00c3;
  --accent-mid: #6648eb;
  --lilac: #d5d4f0;
  --success-fg: #027a48;
  --success-bg: #ecfdf3;
  --error-fg: #b42318;
  --error-bg: #fef3f2;
  --border: #e3e1f0;
  --muted: #6b6f87;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--tint); }
body.intake {
  background: var(--tint);
  color: var(--ink);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen { width: 100%; max-width: 460px; flex: 1; display: flex; flex-direction: column; }
body.is-welcome .screen { max-width: 560px; }
body.is-booking .screen, body.is-booking .footerbar { max-width: 640px; }

/* ---------- progress + wordmark ---------- */
.progress-top { width: 100%; margin-bottom: 16px; }
.progress-track { width: 100%; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); }
.progress-labels { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 8px; font-size: 11.5px; }
.pl-current { font-weight: 600; }
.pl-next { color: var(--muted); }
body.is-welcome .progress-top { visibility: hidden; }

.brandmark { display: flex; align-items: center; justify-content: center; height: 26px; margin-bottom: 22px; }
.brandmark img { height: 26px; width: auto; display: block; }

/* ---------- content ---------- */
.content { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-block: 6px; animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .content { animation: none; } }

body.is-welcome .content { flex: 0 0 auto; margin-top: auto; text-align: center; align-items: center; gap: 20px; }
body.is-welcome h1 { font-size: clamp(26px, 7vw, 34px); }
body.is-welcome .lede { max-width: 480px; text-wrap: balance; }
body.is-welcome footer.nav { margin-bottom: auto; margin-top: 32px; width: 100%; }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--accent-ink); margin: 0; }
h1 { font-weight: 600; font-size: clamp(23px, 6vw, 29px); line-height: 1.3; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
.subtitle { font-size: 14px; color: var(--muted); line-height: 1.5; margin: -6px 0 0; }
.lede { font-size: 15px; line-height: 1.65; margin: 0; color: var(--muted); }
.meta-line { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }

/* ---------- questions ---------- */
.date-parts { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: 8px; }
select {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px;
  padding: 12px 10px; outline: none;
}
select:focus { border-color: var(--accent); }
input[type="tel"] {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px; padding: 12px 14px; outline: none;
}
input[type="tel"]:focus { border-color: var(--accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.question { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; min-inline-size: 0; }
.question + .question { margin-top: 8px; }
.question[hidden] { display: none; }
.q-label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .01em; padding: 0; }
.q-help { font-size: 12px; color: var(--muted); margin: -4px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }

.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: block; position: relative; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--muted);
  font-size: 14.5px; padding: 12px 14px; border-radius: 8px;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:hover { border-color: #cfc6ef; }
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt:has(input:checked) { border-color: var(--accent); background: rgba(168, 90, 255, .1); color: var(--accent-ink); font-weight: 600; }
.opt .hint { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 3px; }
.opt:has(input:checked) .hint { color: var(--accent-ink); opacity: .85; }
.options.bold-labels .opt-label { font-weight: 600; color: var(--ink); }
.options.bold-labels .opt:has(input:checked) .opt-label { color: var(--accent-ink); }

.specify { display: none; margin-top: -2px; }
.opt:has(input:checked) + .specify, .specify.has-error { display: block; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], textarea {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px;
  padding: 12px 14px; outline: none; transition: border-color .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
.invalid input, .invalid textarea, input.invalid { border-color: var(--error-fg); }
.error-text { color: var(--error-fg); font-size: 12.5px; font-weight: 500; margin: 0; }
.error-box { background: var(--error-bg); color: var(--error-fg); border: 1px solid #f4c7c3; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 0; }

.num-field { display: flex; align-items: center; gap: 12px; }
.num-field input { width: 140px; font-size: 20px; padding: 14px 16px; }
.num-unit { font-size: 18px; color: var(--muted); font-weight: 500; }
/* Once intake.js has turned it into a wheel, stack wheel, toggle and hint. */
.num-field.has-wheel { flex-direction: column; align-items: stretch; gap: 10px; }

.list-rows { display: flex; flex-direction: column; gap: 10px; }
.list-row { display: flex; gap: 10px; align-items: center; }
.list-row input { flex: 1; }
.rm { background: var(--bg); border: 1.5px solid var(--border); border-radius: 8px; width: 38px; height: 38px; cursor: pointer; color: var(--muted); font-size: 16px; flex: 0 0 auto; }
.addrow { background: none; border: 1.5px dashed #c7c2e4; color: var(--accent-ink); font-family: inherit; font-weight: 600; font-size: 13px; border-radius: 8px; padding: 10px 14px; cursor: pointer; width: 100%; }
.addrow:hover { border-color: var(--accent); }

/* ---------- scroll-wheel picker (intake.js) ---------- */
.wheel-wrap { --row: 44px; display: flex; flex-direction: column; align-items: stretch; }
.wheel-label { text-align: center; font-size: 14.5px; font-weight: 600; margin: 0 0 6px; }
.wheel { position: relative; flex: 1; }
.wheel-row { display: flex; align-items: center; gap: 14px; }
.step {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--ink);
  font-family: inherit; font-size: 26px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; touch-action: manipulation;
}
.step:hover { border-color: #cfc6ef; }
.step:active { background: var(--tint); }
.wheel-pair .step { width: 40px; height: 40px; font-size: 22px; }
.wheel-pair .wheel-row { gap: 6px; }
.wheel-band { position: absolute; left: 0; right: 0; top: calc(var(--row) * 2); height: var(--row); background: rgba(39, 43, 64, .12); border-radius: 12px; pointer-events: none; }
.wheel-scroll {
  position: relative; height: calc(var(--row) * 5); overflow: hidden; padding-top: calc(var(--row) * 2);
  outline: none; touch-action: none; cursor: grab; user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 32%, #000 68%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 32%, #000 68%, transparent 100%);
}
.wheel-scroll:active { cursor: grabbing; }
.wheel-scroll:focus-visible { box-shadow: 0 0 0 2px var(--accent) inset; border-radius: 12px; }
.wheel-item { height: var(--row); display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; }
.wheel-item.on { font-weight: 600; }
.wheel-unset .wheel-item { color: var(--muted); }
.wheel-hint { text-align: center; font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.wheel-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.unit-toggle { display: inline-flex; align-self: flex-start; border: 1.5px solid var(--border); background: var(--bg); border-radius: 8px; padding: 3px; gap: 3px; }
.unit-btn { font-family: inherit; font-size: 14.5px; color: var(--muted); background: none; border: none; border-radius: 6px; padding: 7px 16px; cursor: pointer; }
.unit-btn.selected { background: rgba(168, 90, 255, .1); color: var(--accent-ink); font-weight: 600; }

/* ---------- footer nav ---------- */
footer.nav { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.btn { font-family: inherit; font-weight: 600; font-size: 14.5px; cursor: pointer; border: none; text-decoration: none; text-align: center; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: #fff; flex: 1; border-radius: 999px; padding: 15px 22px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:disabled { background: #b9bccb; color: #fff; cursor: not-allowed; transform: none; }
.btn-back { width: 50px; height: 50px; flex: 0 0 auto; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; }
.link-btn { background: none; border: none; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--accent-ink); cursor: pointer; padding: 6px; }
.link-btn:disabled { color: var(--muted); cursor: default; }

/* ---------- booking ---------- */
.bk-card { background: var(--bg); border-radius: 16px; box-shadow: 0 1px 2px rgba(39, 43, 64, .05), 0 8px 28px rgba(39, 43, 64, .07); padding: 28px 24px 22px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 480px) { .bk-card { padding: 20px 14px 16px; border-radius: 12px; } }
.bk-head { text-align: center; padding-bottom: 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.bk-head h1 { font-weight: 500; font-size: clamp(22px, 5vw, 27px); }
.bk-head .subtitle { margin: 0; }
.bk-section { font-size: 16px; font-weight: 500; margin: 2px 0 -2px; }
.appt-info { background: #f3f6f8; border: 1.5px solid #dbe4ea; border-radius: 10px; padding: 14px 16px; font-size: 13px; }
.appt-info-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.appt-info-head svg { width: 16px; height: 16px; flex: 0 0 auto; }
.appt-info ul { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.55; }
.appt-info li + li { margin-top: 4px; }

.month { border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); padding: 14px 16px 12px; }
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.month-title { font-weight: 600; font-size: 15px; }
.mnav { width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--bg); color: var(--ink); display: flex; align-items: center; justify-content: center; }
.mnav.disabled { opacity: .35; pointer-events: none; }
.mnav svg { width: 14px; height: 14px; }
.dow, .dgrid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.dow span { font-size: 11.5px; color: var(--muted); padding: 6px 0; }
.dgrid { row-gap: 4px; }
.dcell { justify-self: center; width: 44px; height: 44px; border-radius: 8px; border: 1.5px solid transparent; font-size: 14px; font-weight: 500; color: var(--ink); display: flex; align-items: center; justify-content: center; text-decoration: none; }
a.dcell:hover { background: #f3f3f7; border-color: #cfd0dc; }
span.dcell { color: #c4c3d3; font-weight: 400; }
.dcell.today { border-color: var(--border); }
.dcell.selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; font-weight: 600; }
@media (max-width: 480px) { .dcell { width: 36px; height: 36px; font-size: 13px; } }

.sec-label { font-size: 15px; font-weight: 600; margin: 6px 0 -4px; }
.sec-label small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.times { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip { border: 1.5px solid var(--border); background: var(--bg); color: var(--ink); font-size: 13.5px; font-weight: 500; border-radius: 8px; padding: 10px 14px; white-space: nowrap; text-decoration: none; }
.tchip:hover { background: #f3f3f7; border-color: #cfd0dc; }
.tchip.selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; font-weight: 600; }
.hint-line { font-size: 13px; color: var(--muted); margin: 0; }

.docs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .docs { grid-template-columns: 1fr; } }
.doc { display: flex; align-items: center; gap: 10px; cursor: pointer; border: 1.5px solid var(--border); background: var(--bg); border-radius: 10px; padding: 12px; box-shadow: 0 1px 3px rgba(39, 43, 64, .08); position: relative; }
.doc input { position: absolute; opacity: 0; pointer-events: none; }
.doc:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.doc:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.gp-av { width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12.5px; color: #fff; background: var(--ink); }
.gp-av.alt { background: var(--accent-mid); }
.gp-name { font-weight: 600; font-size: 14.5px; display: block; }
.gp-sub { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.field-group { display: flex; flex-direction: column; gap: 14px; }

.done-ring { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, var(--success-fg), #04a768); display: flex; align-items: center; justify-content: center; }
.done-ring svg { width: 28px; height: 28px; stroke: #fff; }
.meet-link { display: flex; align-items: center; gap: 10px; border-radius: 8px; padding: 12px 14px; background: var(--bg); font-size: 13px; font-weight: 600; color: var(--accent-ink); word-break: break-all; }
.meet-link svg { width: 16px; height: 16px; flex: 0 0 auto; }

.footerbar { width: 100%; max-width: 460px; text-align: center; color: var(--muted); font-size: 11.5px; padding-top: 22px; }

/* ---------- loading state (loading.js) ---------- */
.page-loading { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; overflow: hidden; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.page-loading.on { opacity: 1; }
.page-loading span { position: absolute; top: 0; bottom: 0; width: 40%; border-radius: 3px; background: var(--accent, #a85aff); animation: page-loading 1.1s ease-in-out infinite; }
@keyframes page-loading { 0% { left: -40%; } 100% { left: 100%; } }

button.is-busy, .btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
button.is-busy[data-busy-label], .btn.is-busy[data-busy-label] { color: inherit !important; padding-left: 44px; }
button.is-busy::after, .btn.is-busy::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: busy-spin .7s linear infinite;
}
button.is-busy[data-busy-label]::after, .btn.is-busy[data-busy-label]::after { left: 22px; }
.btn-secondary.is-busy::after, button.btn-secondary.is-busy::after, .link-btn.is-busy::after, .link-danger.is-busy::after {
  border-color: rgba(39, 43, 64, .2); border-top-color: var(--ink, #272b40);
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .page-loading span { animation-duration: 2.5s; }
  button.is-busy::after, .btn.is-busy::after { animation-duration: 1.6s; }
}
