/* THBC Practice Hub — application styles. Requires tokens.css first.
   Calm, warm, practitioner-first. One primary action per screen. Not a SaaS dashboard. */

/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: var(--leading-body);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--color-primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--color-primary-hover); }
h1, h2, h3, h4, p, ul, ol { margin: 0; }
ul, ol { padding-left: 1.25rem; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ─── Typography ──────────────────────────────────────────────────────────── */
.h1, .h2, .h3, .h4 { font-weight: 700; line-height: var(--leading-tight); color: var(--green-900); letter-spacing: -0.01em; }
.h1 { font-size: var(--text-3xl); }
.h2 { font-size: var(--text-2xl); }
.h3 { font-size: var(--text-xl); }
.h4 { font-size: var(--text-lg); }
@media (min-width: 48rem) { .h1 { font-size: var(--text-4xl); } }
.lead { font-size: var(--text-lg); }
.eyebrow { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-accent); }
.script { font-family: var(--font-script); font-size: var(--text-2xl); line-height: 1.4; color: var(--green-900); }
.text-muted { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-small { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-center { text-align: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: var(--space-2); background: var(--white); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: var(--space-2); }

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--space-4); }
@media (min-width: 48rem) { .container { padding-inline: var(--space-6); } }
.page { padding-block: var(--space-6) var(--space-8); min-height: calc(100vh - var(--topbar-height)); }
.page--narrow .container { max-width: var(--container-narrow); }
.page-head { display: flex; flex-direction: column; gap: var(--space-1); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-6); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.row--between { justify-content: space-between; }
.grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 40rem) { .grid--2, .grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }
.inline { display: inline; }

/* ─── Top bar (member site) ───────────────────────────────────────────────── */
.topbar { background: var(--green-900); color: var(--white); position: sticky; top: 0; z-index: 50; }
.topbar__inner { display: flex; align-items: center; gap: var(--space-4); min-height: var(--topbar-height); }
.topbar__brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.topbar__nav { display: none; gap: var(--space-1); margin-left: var(--space-4); }
.topbar__link { color: rgba(255,255,255,0.82); text-decoration: none; font-size: var(--text-sm); font-weight: 600; padding: var(--space-2) var(--space-3); border-radius: var(--radius-pill); transition: background var(--transition), color var(--transition); }
.topbar__link:hover { color: var(--white); background: rgba(255,255,255,0.08); }
.topbar__link.is-active { color: var(--white); background: rgba(255,255,255,0.14); }
.topbar__user { margin-left: auto; display: flex; align-items: center; }
.topbar__toggle { margin-left: auto; background: none; border: 0; padding: var(--space-2); cursor: pointer; color: inherit; }
.topbar__burger, .topbar__burger::before, .topbar__burger::after { display: block; width: 22px; height: 2px; background: currentColor; border-radius: 2px; position: relative; content: ""; }
.topbar__burger::before { position: absolute; top: -7px; }
.topbar__burger::after { position: absolute; top: 7px; }
.topbar__back { color: rgba(255,255,255,0.9); text-decoration: none; font-weight: 600; font-size: var(--text-sm); }
.topbar--focus .topbar__brand { margin-left: auto; }
@media (min-width: 48rem) {
    .topbar__nav { display: flex; }
    .topbar__toggle { display: none; }
    .topbar__user { margin-left: auto; }
}
@media (max-width: 47.99rem) {
    .topbar__nav.is-open { display: flex; flex-direction: column; position: absolute; top: var(--topbar-height); left: 0; right: 0; background: var(--green-900); padding: var(--space-3) var(--space-4) var(--space-4); box-shadow: var(--shadow-lg); margin: 0; }
    .topbar__nav--guest { display: flex; margin-left: auto; }
    .topbar__user { display: none; }
}

/* ─── Logo ────────────────────────────────────────────────────────────────── */
.logo { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; letter-spacing: 0.12em; font-size: var(--text-lg); }
.logo--light { color: var(--white); }
.logo--dark { color: var(--green-900); }
.logo__mark { color: var(--green-700); }

/* ─── Auth layout ─────────────────────────────────────────────────────────── */
.body--auth { background: var(--color-bg); }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth__panel { padding: var(--space-6) var(--space-4); max-width: 30rem; width: 100%; margin-inline: auto; display: flex; flex-direction: column; gap: var(--space-6); justify-content: center; }
.auth__brand { display: flex; }
.auth__side { display: none; }
@media (min-width: 60rem) {
    .auth { grid-template-columns: 1fr 1fr; }
    .auth__panel { padding: var(--space-8) var(--space-7); max-width: 34rem; }
    .auth__side { display: flex; align-items: flex-end; padding: var(--space-8); background: linear-gradient(160deg, var(--green-100) 0%, var(--terracotta-50) 55%, var(--amber-50) 100%); position: relative; overflow: hidden; }
    .auth__side::before { content: ""; position: absolute; inset: auto -20% -30% auto; width: 70%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(23,62,52,0.10), transparent 70%); }
    .auth__side .script { max-width: 18ch; position: relative; }
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.card--tint { background: var(--color-surface-tint); border-color: transparent; }
.card--warm { background: var(--color-surface-warm); border-color: transparent; }
.card--info { background: var(--color-surface-info); border-color: transparent; }
.card--selected { border: 2px solid var(--color-primary); }
.card--action { border-left: 4px solid var(--color-accent); }
.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat__label { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 600; }
.stat__value { font-size: var(--text-3xl); font-weight: 700; color: var(--green-900); line-height: 1; }
.stat__hint { font-size: var(--text-xs); color: var(--color-text-subtle); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: 0.7rem 1.25rem; border-radius: var(--radius-pill); border: 1px solid transparent; font-weight: 600; font-size: var(--text-md); text-decoration: none; cursor: pointer; transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn--primary:hover { background: var(--color-primary-hover); color: var(--color-on-primary); }
.btn--accent { background: var(--color-accent); color: var(--white); }
.btn--accent:hover { background: var(--color-accent-hover); color: var(--white); }
.btn--secondary { background: var(--white); color: var(--green-900); border-color: var(--color-border-strong); }
.btn--secondary:hover { border-color: var(--green-700); }
.btn--ghost { background: transparent; color: var(--green-900); }
.btn--ghost:hover { background: var(--green-100); }
.btn--link { background: none; border: 0; padding: 0; color: var(--color-primary); text-decoration: underline; font-weight: 500; border-radius: 0; }
.btn--block { width: 100%; }
.btn--sm { padding: 0.45rem 0.9rem; font-size: var(--text-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form { width: 100%; }
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.label { font-weight: 600; font-size: var(--text-sm); color: var(--ink-soft); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.help { font-size: var(--text-sm); color: var(--color-text-muted); }
.input, .select, .textarea { width: 100%; padding: 0.7rem 0.9rem; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--white); transition: border-color var(--transition), box-shadow var(--transition); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(53, 93, 80, 0.18); }
.textarea { min-height: 7rem; resize: vertical; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--color-danger); }
.field__error { font-size: var(--text-sm); color: var(--color-danger); }
.checkbox, .radio { display: flex; align-items: flex-start; gap: var(--space-3); cursor: pointer; }
.checkbox input, .radio input { width: 1.1rem; height: 1.1rem; margin-top: 0.2rem; accent-color: var(--green-900); flex: none; }
.choice { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--white); cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.choice:hover { border-color: var(--green-700); }
.choice:has(input:checked) { border-color: var(--green-900); border-width: 2px; background: var(--green-50); }
.choice input { accent-color: var(--green-900); }

/* ─── Progress ────────────────────────────────────────────────────────────── */
.progress { height: 0.5rem; background: var(--grey-200); border-radius: var(--radius-pill); overflow: hidden; }
.progress__bar { height: 100%; background: var(--green-900); border-radius: inherit; transition: width 400ms ease; }
.ring { --ring-size: 4.5rem; --ring-value: 0; width: var(--ring-size); height: var(--ring-size); border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green-900) calc(var(--ring-value) * 1%), var(--grey-200) 0); position: relative; font-weight: 700; color: var(--green-900); }
.ring::before { content: ""; position: absolute; inset: 0.45rem; border-radius: 50%; background: var(--white); }
.ring > span { position: relative; font-size: var(--text-sm); }

/* ─── Chips & badges ──────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.65rem; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; background: var(--grey-100); color: var(--grey-700); white-space: nowrap; }
.chip::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.chip--complete { background: var(--green-100); color: var(--color-success); }
.chip--progress { background: var(--terracotta-50); color: var(--terracotta); }
.chip--locked { background: var(--grey-100); color: var(--grey-500); }
.chip--stage { background: var(--green-900); color: var(--white); }
.chip--stage::before { display: none; }
.avatar { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--terracotta-50); color: var(--terracotta-dark); font-weight: 700; font-size: var(--text-sm); }
.avatar--sm { width: 2rem; height: 2rem; font-size: var(--text-xs); }

/* ─── Flash ───────────────────────────────────────────────────────────────── */
.flash { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); border: 1px solid transparent; font-size: var(--text-sm); }
.flash--success { background: var(--green-100); color: var(--color-success); border-color: #CFE3D8; }
.flash--error { background: var(--terracotta-50); color: var(--terracotta-dark); border-color: #EFD3CB; }
.flash--warning, .flash--info { background: var(--amber-50); color: #7A4F12; border-color: #F3DDBE; }
.flash__text { flex: 1; }
.flash__close { background: none; border: 0; cursor: pointer; font-size: var(--text-lg); line-height: 1; color: inherit; opacity: 0.7; }
.flash__close:hover { opacity: 1; }

/* ─── Lists ───────────────────────────────────────────────────────────────── */
.promise { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.promise li { display: flex; flex-direction: column; gap: 0.15rem; padding: var(--space-3) var(--space-4); background: var(--white); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.promise strong { color: var(--green-900); }
.promise span { font-size: var(--text-sm); color: var(--color-text-muted); }
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.list__item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); }
.list__item:last-child { border-bottom: 0; }
.step-badge { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--green-900); color: var(--white); font-weight: 700; font-size: var(--text-sm); flex: none; }
.step-badge--done { background: var(--color-success); }
.step-badge--muted { background: var(--grey-200); color: var(--grey-600); }

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--color-border); padding-block: var(--space-5); font-size: var(--text-sm); color: var(--color-text-muted); background: var(--white); }
.footer__inner { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; }
.footer nav { display: flex; gap: var(--space-4); }
.footer a { color: inherit; }

/* ─── Error page ──────────────────────────────────────────────────────────── */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
.error-page__card { max-width: 28rem; text-align: center; display: flex; flex-direction: column; gap: var(--space-3); }

/* ─── Connect (staff) ─────────────────────────────────────────────────────── */
.body--connect { background: var(--surface); }
.connect { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.connect__sidebar { background: var(--green-900); color: var(--white); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-5); }
.connect__brand { color: inherit; text-decoration: none; display: flex; align-items: baseline; gap: var(--space-2); }
.connect__brand-sub { font-size: var(--text-sm); opacity: 0.75; letter-spacing: 0.04em; }
.connect__nav { display: flex; flex-direction: column; gap: 2px; }
.connect__link { color: rgba(255,255,255,0.82); text-decoration: none; font-size: var(--text-sm); font-weight: 600; padding: 0.55rem var(--space-3); border-radius: var(--radius-sm); }
.connect__link:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.connect__link.is-active { background: rgba(255,255,255,0.14); color: var(--white); }
.connect__user { margin-top: auto; display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.connect__user .btn--link { color: rgba(255,255,255,0.85); margin-left: auto; }
.connect__user-name { opacity: 0.9; }
.connect__main { padding: var(--space-6) var(--space-4) var(--space-8); }
@media (min-width: 64rem) {
    .connect { grid-template-columns: var(--sidebar-width) 1fr; }
    .connect__sidebar { position: sticky; top: 0; height: 100vh; }
    .connect__main { padding: var(--space-7) var(--space-7) var(--space-8); max-width: 80rem; }
}

/* ─── Tables (Connect) ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); vertical-align: top; }
.table th { font-weight: 700; color: var(--grey-700); background: var(--green-50); }
.table tr:last-child td { border-bottom: 0; }

/* ─── Prose (markdown output) ─────────────────────────────────────────────── */
.prose > * + * { margin-top: var(--space-3); }
.prose h2, .prose h3, .prose h4 { color: var(--green-900); line-height: var(--leading-tight); }
.prose h2 { font-size: var(--text-xl); }
.prose h3 { font-size: var(--text-lg); }
.prose code { font-family: var(--font-mono); font-size: 0.9em; background: var(--grey-100); padding: 0.1em 0.35em; border-radius: 4px; }
