/* Hospice Consent Generator — shared design system.
 * Style: "Warm Clinical" — inspired by the Censorium portal. Bone-paper ground,
 * white cards, espresso ink, forest-green confirm, terracotta accent, a warm
 * serif (Fraunces) for headings over a clean grotesque (Figtree) for text.
 * Calm, premium, trustworthy — for clinicians and grieving families alike.
 * Vanilla CSS custom properties — no framework. Class names are stable so the
 * sign, review, provider, and agency-signature pages all share one language. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Figtree:wght@400;500;600;700&display=swap');

:root {
  /* Warm earth palette */
  --primary: #2b2019;        /* espresso — primary buttons, brand tile, ink */
  --primary-dark: #1d1510;
  --primary-soft: #efe9df;   /* soft neutral chip / focus halo base */
  --cta: #2f6b3b;            /* forest green — confirm / download / success */
  --cta-dark: #265a31;
  --accent: #c0633b;         /* terracotta — sparingly, for accents/FAB */
  --gold: #c6973f;           /* agency monogram */

  --bg: #f4f2ec;             /* warm bone paper */
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #3a2e25;            /* body — ~9:1 on white */
  --ink-strong: #211a14;     /* headings */
  --ink-soft: #79695d;       /* secondary — ~4.7:1 on white */
  --border: #e8e2d7;
  --border-strong: #d7cdbd;

  --danger: #a23b2d;
  --danger-bg: #fbeee9;
  --danger-border: #eccec3;
  --ok: #2f6b3b;
  --ok-bg: #e9f1ea;
  --ok-border: #c4ddc7;
  --pending: #8a6a1c;
  --pending-bg: #f6edd6;
  --pending-border: #e8d6a8;
  --info-bg: #f1f0fa;
  --info-border: #d9d6ee;

  /* Type */
  --font-head: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Spacing */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem;
  --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem;

  --radius: 10px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(43, 33, 28, .05), 0 10px 30px rgba(43, 33, 28, .05);
  --shadow-lg: 0 18px 50px rgba(43, 33, 28, .12);
  --ring: 0 0 0 3px rgba(47, 107, 59, .18);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  /* faint warm grain/vignette so the ground has depth, not flat color */
  background-image:
    radial-gradient(120% 80% at 50% -10%, #fbfaf6 0%, rgba(251,250,246,0) 60%),
    radial-gradient(90% 60% at 100% 0%, #f7f1e8 0%, rgba(247,241,232,0) 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); color: var(--ink-strong); line-height: 1.15; margin: 0 0 var(--s-3); }
h1 { font-size: 2rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 var(--s-3); }
a { color: var(--cta-dark); text-underline-offset: 2px; }

.muted { color: var(--ink-soft); font-size: 0.875rem; }
.lead { color: var(--ink-soft); font-size: 1.02rem; margin-bottom: var(--s-5); }

/* Eyebrow — small uppercase kicker above titles (Censorium signature touch) */
.eyebrow {
  font: 600 0.72rem/1 var(--font-body);
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-soft); margin: 0 0 var(--s-2);
}

/* ---- Layout ---- */
.page { max-width: 640px; margin: 0 auto; padding: var(--s-6) var(--s-4) var(--s-7); }
.page--narrow { max-width: 560px; }

/* ---- Brand header ---- */
.brand {
  display: flex; align-items: center; gap: var(--s-3);
  padding-bottom: var(--s-4); margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--border);
}
.brand__mark {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 13px; background: var(--primary); color: var(--gold);
  box-shadow: var(--shadow);
}
.brand__mark svg { width: 22px; height: 22px; }
.brand__title { font-family: var(--font-head); font-weight: 600; font-size: 1.2rem; color: var(--ink-strong); letter-spacing: -.01em; }
.brand__sub { font-size: 0.8rem; color: var(--ink-soft); }

/* Agency monogram badge — espresso tile + gold serif initials (patient pages) */
.agency-badge {
  display: grid; place-items: center;
  width: 60px; height: 60px; margin: 0 auto var(--s-3);
  border-radius: 16px; background: var(--primary);
  color: var(--gold); font-family: var(--font-head); font-weight: 700; font-size: 1.25rem;
  letter-spacing: .02em; box-shadow: var(--shadow);
}

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-5) var(--s-5) var(--s-5);
  box-shadow: var(--shadow);
  margin-bottom: var(--s-4);
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.card:nth-of-type(2) { animation-delay: .06s; }
.card:nth-of-type(3) { animation-delay: .12s; }
.card:nth-of-type(4) { animation-delay: .18s; }
.card:nth-of-type(5) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---- Fieldset ---- */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-4) var(--s-4) var(--s-5);
  margin: 0 0 var(--s-4);
  background: var(--surface);
}
legend {
  padding: 0 var(--s-2);
  font: 600 0.72rem/1 var(--font-body);
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-soft);
}

/* ---- Forms ---- */
label { display: block; margin: var(--s-4) 0 var(--s-1); font-weight: 600; font-size: 0.9rem; color: var(--ink-strong); }
label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  padding: 0.7rem 0.85rem;
  min-height: 46px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: #b3a899; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-soft); }
input:focus-visible, select:focus-visible, textarea:focus-visible,
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: none;
  border-color: var(--cta);
  box-shadow: var(--ring);
}

.checkbox-row { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3); }
.checkbox-row input { width: auto; min-height: 0; }
.checkbox-row label { margin: 0; font-weight: 400; font-size: 0.92rem; color: var(--ink); }

/* ---- Buttons ---- */
.btn, button {
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 46px; padding: 0.7rem 1.3rem;
  border: 1.5px solid transparent; border-radius: var(--radius);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .08s ease;
}
.btn:active, button:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-cta { background: var(--cta); color: #fff; }
.btn-cta:hover { background: var(--cta-dark); }
.btn-ghost { background: var(--surface); color: var(--ink-strong); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-soft); }
.btn-lg { min-height: 54px; padding: 0.9rem 1.75rem; font-size: 1.05rem; width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-4); }

/* ---- Banners ---- */
.banner { padding: var(--s-3) var(--s-4); border-radius: var(--radius); border: 1px solid; font-size: 0.92rem; margin-top: var(--s-4); }
.banner.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.banner.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.banner.info { background: var(--info-bg); border-color: var(--info-border); color: var(--ink); }

/* ---- Status pills ---- */
.pill {
  display: inline-block; padding: 0.2rem 0.65rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; letter-spacing: .02em;
  background: var(--primary-soft); color: var(--ink-strong);
}
.pill--ok { background: var(--ok-bg); color: var(--ok); }
.pill--pending { background: var(--pending-bg); color: var(--pending); }
.pill--expired { background: #efeae2; color: var(--ink-soft); }

/* ---- Signature pad ---- */
.sig-pad-wrap { margin-top: var(--s-3); border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 4px; background: var(--surface-2); }
.sig-pad-wrap canvas { display: block; width: 100%; height: 220px; border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; }

/* P5 — the signer is elderly, on a phone, mid-crisis, with one shot at this.
 *
 * Minimum 44x44 CSS-px touch targets (WCAG 2.5.5 / Apple HIG), 16px+ base text
 * on the signing page so iOS does not zoom on focus, and inputs big enough to
 * hit with a shaking hand. There are NO client-side timeouts anywhere in this
 * flow — nothing expires the page while somebody is reading. */
.page--narrow input[type="text"],
.page--narrow input[type="email"],
.page--narrow input[type="tel"] {
  font-size: 16px;
  min-height: 44px;
  padding: .55rem .7rem;
  border: 1px solid var(--border-strong, #94a3b8);
  border-radius: 8px;
  width: 100%;
}
.page--narrow .btn-cta,
.page--narrow .btn-ghost { min-height: 48px; font-size: 1.02rem; }
.signer-opt:hover, .auth-opt:hover { background: rgba(0, 0, 0, .03); border-radius: 8px; }
/* Keyboard focus must be obvious for anyone not using a finger. */
.page--narrow input:focus-visible,
.page--narrow button:focus-visible,
.page--narrow a:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

/* The `hidden` attribute must always win.
 *
 * Author rules like `.btn-row { display: flex }` beat the UA stylesheet's
 * `[hidden] { display: none }`, so setting el.hidden = true silently did
 * NOTHING on any element carrying a display class. That left the "Text or email
 * me the current link" button visible on the already-signed and cancelled
 * dead-link pages, inviting a family to re-request a link for a consent that
 * was finished or withdrawn. Caught in a real browser 2026-08-14. */
[hidden] { display: none !important; }

/* ---- Accessibility helpers ---- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
  .page { padding: var(--s-5) var(--s-3) var(--s-6); }
  h1 { font-size: 1.65rem; }
  .card, fieldset { padding: var(--s-4); }
}
