/* pages.css — page-scoped styles extracted from per-template <style> blocks.
 *
 * Moved here by #385 so the CSP `style-src` directive can drop 'unsafe-inline'
 * (inline <style> elements are blocked once 'unsafe-inline' is gone, same as
 * inline style attributes). Every selector is namespaced to its page/feature,
 * so there are no cross-page collisions. Blocks that were byte-identical across
 * templates (the legal pages; login/reauth) are defined once here.
 *
 * Loaded globally after components.css in _base.html.
 */

/* ============================================================ Auth (login, reauth) */
.login-or {
  display: flex; align-items: center; text-align: center;
  color: var(--ink-3); font-size: 13px; margin: 18px 0;
}
.login-or::before, .login-or::after {
  content: ""; flex: 1; border-top: 1px solid var(--hairline);
}
.login-or span { padding: 0 12px; }
.passkey-status { font-size: 13px; color: var(--ink-3); margin: 8px 0 0; min-height: 1.2em; }
.passkey-status.alert { color: var(--alert); }
/* login/reauth center their status line (both render under .page-center);
 * settings reuses .passkey-status un-centered. */
.page-center .passkey-status { text-align: center; }

/* ============================================================ Signup consent (signup) */
/* Each consent is its own clearly separated unit — never bundled (MHMDA/OCPA/CPRA). */
.consent-group { border: 0; padding: 0; margin: 4px 0 8px; }
.consent-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px; margin-bottom: 12px;
  border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface-1);
}
.consent-item input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.consent-item input[type=checkbox]:focus-visible {
  outline: 2px solid var(--accent-tint); outline-offset: 2px;
}
.consent-item label { font-weight: 400; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; text-align: left; }
.consent-item .consent-title { display: block; font-weight: 600; color: var(--ink-1); margin-bottom: 3px; }
/* Equal-weight optional choice (#181): both options share identical styling —
   no dominant accept, no de-emphasized decline, no default selection. */
.consent-choices { display: flex; flex-wrap: wrap; gap: 8px; text-align: left; }
.consent-choices label {
  flex: 1 1 0; min-width: 140px; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r-md);
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.consent-choices input[type=radio] { width: 16px; height: 16px; flex: none; }
.consent-choices input[type=radio]:focus-visible { outline: 2px solid var(--accent-tint); outline-offset: 2px; }
/* Prominent, separate Consumer Health Data Privacy Policy link — visually
   distinct from the ToS and general Privacy Policy links. */
.chdpp-link {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--accent-rule, var(--rule)); border-radius: var(--r-md);
  background: var(--accent-tint, var(--surface-1));
  font-size: 12.5px; line-height: 1.4; text-align: left;
}
.chdpp-link a { font-weight: 600; }

/* ============================================================ Legal pages (privacy, terms, health_data_privacy) */
.legal-page h1 { margin-bottom: 4px; }
.legal-page .legal-updated { color: var(--ink-3); font-size: 13px; margin-bottom: 24px; }
.legal-page h2 { margin-top: 32px; margin-bottom: 8px; font-size: 18px; }
.legal-page p, .legal-page li { line-height: 1.6; color: var(--ink-2); }
.legal-page ul { margin: 8px 0 8px 20px; }
.legal-page li { margin-bottom: 6px; }
.legal-draft-banner {
  background: var(--alert-tint); border: 1px solid var(--alert-rule);
  color: var(--alert-2); padding: 10px 14px; border-radius: var(--r-md);
  font-size: 13px; margin-bottom: 24px;
}

/* ============================================================ TOTP setup (totp_setup) */
.totp-setup { max-width: 520px; }
.totp-steps { margin: 0 0 24px; padding-left: 20px; }
.totp-steps li { font-size: 14px; color: var(--ink-2); line-height: 1.7; margin-bottom: 8px; }
.totp-qr {
  display: inline-block; padding: 12px; background: #fff;
  border: 1px solid var(--hairline); border-radius: var(--r-md); line-height: 0;
}
.totp-qr svg { width: 180px; height: 180px; }
.totp-secret {
  font-family: var(--mono); font-size: 14px; letter-spacing: 1px;
  background: var(--bg-2); padding: 10px 14px; border-radius: var(--r-sm);
  word-break: break-all; margin: 8px 0 0; color: var(--ink);
}
.totp-confirm-field { margin: 20px 0 8px; max-width: 220px; }
.totp-confirm-field input {
  font: inherit; font-size: 18px; letter-spacing: 4px; text-align: center;
  width: 100%; padding: 10px; border: 1px solid var(--rule);
  border-radius: var(--r-sm); background: var(--card); color: var(--ink);
}

/* ============================================================ Backup codes (totp_backup_codes) */
.backup-wrap { max-width: 520px; }
.backup-codes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px;
  font-family: var(--mono); font-size: 15px; letter-spacing: 1px;
  background: var(--bg-2); padding: 18px 22px; border-radius: var(--r-md);
  margin: 16px 0; color: var(--ink);
}
.backup-note {
  background: var(--watch-tint); border: 1px solid var(--watch-rule);
  color: var(--ink-2); padding: 12px 16px; border-radius: var(--r-md);
  font-size: 14px; line-height: 1.6; margin: 0 0 16px;
}
@media (max-width: 480px) { .backup-codes { grid-template-columns: 1fr; } }

/* ============================================================ Settings (settings) */
/* Jump links to the section containers — stack under the heading on mobile. */
.settings-jump {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 24px;
}
.settings-section { scroll-margin-top: 24px; }
.settings-section .placeholder {
  color: var(--ink-3); font-size: 14px; line-height: 1.6; margin: 0;
}
.settings-chdpp {
  margin-top: 8px; padding: 16px 20px;
  background: var(--accent-tint); border-radius: var(--r-md);
}
.settings-chdpp p { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.6; }

/* Result banner after a revoke. */
.settings-banner {
  padding: 12px 16px; border-radius: var(--r-md); font-size: 14px;
  line-height: 1.5; margin-bottom: 16px; border: 1px solid;
}
.settings-banner.ok    { background: var(--ok-tint);    border-color: var(--ok-rule);    color: var(--ink-2); }
.settings-banner.alert { background: var(--alert-tint); border-color: var(--alert-rule); color: var(--ink-2); }

/* Connection rows. */
.conn-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--hairline);
}
.conn-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.conn-row:first-of-type { padding-top: 4px; }
.conn-name { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.conn-name .badge { margin-left: 8px; vertical-align: middle; }
.conn-meta { font-size: 13px; color: var(--ink-3); line-height: 1.6; margin: 0; }
.conn-meta dt { display: inline; font-weight: 500; }
.conn-meta .scopes {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  word-break: break-word;
}
.conn-actions { flex-shrink: 0; }

/* Passkey rows — same row rhythm as connections. */
.passkey-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--hairline);
}
.passkey-row:last-of-type { border-bottom: none; }
.passkey-row:first-of-type { padding-top: 4px; }
.passkey-name { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.passkey-meta { font-size: 13px; color: var(--ink-3); line-height: 1.6; margin: 0; }
.passkey-actions { flex-shrink: 0; display: flex; gap: 8px; align-items: flex-start; }
.passkey-rename { display: flex; gap: 6px; }
.passkey-input {
  font: inherit; font-size: 13px; padding: 6px 10px;
  border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--card); color: var(--ink); max-width: 180px;
}
.passkey-add { margin-top: 16px; }
/* TOTP row — same rhythm. */
.totp-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 4px 0 0;
}
.totp-name { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.totp-name .badge { margin-left: 8px; vertical-align: middle; }
.totp-meta { font-size: 13px; color: var(--ink-3); line-height: 1.6; margin: 0; }
.totp-actions { flex-shrink: 0; }
@media (max-width: 640px) {
  .totp-row { flex-direction: column; gap: 12px; }
  .totp-actions { width: 100%; }
  .totp-actions .btn { width: 100%; }
}
@media (max-width: 640px) {
  .passkey-row { flex-direction: column; gap: 12px; }
  .passkey-actions { width: 100%; flex-wrap: wrap; }
  .passkey-rename { flex: 1; }
  .passkey-input { max-width: none; flex: 1; }
}

/* Consent rows — same row rhythm as connections. */
.consent-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--hairline);
}
.consent-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.consent-row:first-of-type { padding-top: 4px; }
.consent-name { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.consent-name .badge { margin-left: 8px; vertical-align: middle; }
.consent-desc { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin: 0 0 4px; }
.consent-effect { font-size: 12px; color: var(--ink-3); line-height: 1.6; margin: 0; }
.consent-ts { font-size: 12px; color: var(--ink-3); margin: 0 0 4px; }
.consent-actions { flex-shrink: 0; }
.consent-locked { color: var(--ink-3); white-space: nowrap; }

/* Data-rights rows — same rhythm as connections/consents. */
.data-right-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--hairline);
}
.data-right-row:first-of-type { padding-top: 4px; }
.data-right-name { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.data-right-desc { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin: 0; }
.data-right-actions { flex-shrink: 0; }
.data-right-chdpp { color: var(--ink-3); margin: 12px 0 0; }

/* Confirm dialog — mirrors the onboarding modal a11y pattern. */
.revoke-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.revoke-modal {
  background: var(--card); border-radius: var(--r-lg, 12px);
  max-width: 460px; width: 100%; padding: 28px; box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,0.2));
}
.revoke-modal h2 { font-size: 18px; margin: 0 0 12px; color: var(--ink); }
.revoke-modal p { font-size: 14px; line-height: 1.6; color: var(--ink-2); margin: 0 0 12px; }
.revoke-modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

@media (max-width: 640px) {
  .conn-row, .consent-row, .data-right-row { flex-direction: column; gap: 12px; }
  .conn-actions, .consent-actions, .data-right-actions { width: 100%; }
  .conn-actions .btn, .consent-actions .btn-review,
  .data-right-actions .btn { width: 100%; text-align: center; }
  .revoke-modal .modal-actions { flex-direction: column-reverse; }
  .revoke-modal .modal-actions .btn { width: 100%; }
}

/* ============================================================ Dispute letter (#374)
 * The Cupcake "act on it" payoff: an audit finding rendered as a real, editable
 * piece of correspondence. Signature = the letter-sheet — warm paper lifted off
 * the desk, brand letterhead, a typed monospace body — so the abstract finding
 * becomes something the user can see themselves mailing. Everything else stays
 * quiet. Namespaced .dispute-* / .letter-* / .checklist-* per the file's rule. */
.dispute-page { max-width: 960px; margin: 0 auto; }
.dispute-head { margin: 4px 0 22px; }
.dispute-eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent);
  margin-bottom: 8px;
}
.dispute-title { font-family: var(--serif); font-size: 30px; line-height: 1.12; color: var(--ink); margin: 0 0 8px; }
.dispute-sub { font-size: 15px; line-height: 1.55; color: var(--ink-2); max-width: 62ch; margin: 0; }
.dispute-sub strong { color: var(--ink); font-weight: 600; }

.dispute-layout { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 28px; align-items: start; }
.dispute-main { min-width: 0; }

.dispute-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.dispute-status { font-size: 13px; color: var(--accent); font-weight: 600; }

/* The sheet — the one bold element. Elevated warm paper with a brand edge. */
.letter-sheet {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 0;
  overflow: hidden;
}
.letter-head {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 28px; border-bottom: 1px solid var(--hairline);
  background: linear-gradient(var(--bg-2), var(--card));
}
.letter-mark { color: var(--accent); font-size: 18px; line-height: 1; }
.letter-mark-label {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3);
}
/* Typed-letter body. Borderless so it reads as paper, not a form field. */
.letter-body {
  display: block; width: 100%; box-sizing: border-box;
  border: 0; background: transparent; resize: none; overflow: hidden;
  padding: 28px; margin: 0;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.7; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
}
.letter-body:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent-rule); }

.dispute-disclaimer {
  font-size: 12.5px; line-height: 1.55; color: var(--ink-3);
  margin: 14px 2px 0; max-width: 66ch;
}

/* Checklist rail — the softer elements a generator can't fill in. */
.dispute-aside { position: sticky; top: calc(var(--primary-nav-h) + 16px); }
.checklist-card {
  background: var(--bg-2); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 20px;
}
.checklist-title { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 14px; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.checklist-item { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.checklist-mark { flex: 0 0 auto; font-weight: 700; color: var(--ink-4); line-height: 1.45; }
.checklist-item.is-done .checklist-mark { color: var(--ok); }
.checklist-item.is-done .checklist-text { color: var(--ink-3); }
.checklist-tag {
  display: inline-block; font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; vertical-align: 1px;
  color: var(--ok); background: var(--ok-tint); border: 1px solid var(--ok-rule);
  border-radius: var(--r-sm); padding: 1px 5px;
}
.checklist-foot { font-size: 11.5px; line-height: 1.5; color: var(--ink-4); margin: 14px 0 0; }

/* CTA on each actionable finding card (eob_detail). */
.finding-action { margin-top: 12px; }

@media (max-width: 860px) {
  .dispute-layout { grid-template-columns: 1fr; }
  .dispute-aside { position: static; order: -1; }
  .dispute-title { font-size: 25px; }
}
