/* Oral Health First — dark slate + gold/orange theme.
   This form is nested inside the OHF marketing site's dark "form insert" slot,
   so it renders NO brand header of its own and uses a flat dark SLATE surface
   where the inputs are the main visual elements (matching their designer's
   look). Only accent is gold/orange. All colors are design tokens for tuning.

   EMBED HOOK: the outer surface is `--page-bg` (default = the slate color).
   When embedding inside the site's dark slot, set `--page-bg: transparent`
   (on :root or the mount node) so the host slate shows through.

   LOGO SWAP (only if a standalone header is reintroduced later): re-add a
   `.brand` block in the markup, then set `--brand-logo: url("/logo.svg")` and
   add class `has-logo` to it. CSS for that hook is kept at the bottom. */
:root {
  /* Surfaces — flat neutral slate, minimal panel-in-panel contrast */
  --slate: #1a1c1e;            /* primary form surface */
  --slate-2: #22262a;          /* subtle raised: stepper chips */
  --section-bg: rgba(255, 255, 255, 0.02);   /* faint section grouping */
  --section-border: rgba(255, 255, 255, 0.05);
  --page-bg: var(--slate);     /* outer page (set transparent to embed) */

  /* Fields — the primary visual element on the slate */
  --field-bg: #1e2124;
  --field-border: #383e43;
  --field-border-focus: var(--brand-orange);
  --placeholder: #7f878e;

  /* Gold / orange accent (the only accent in the system) */
  --brand-orange: #f5a623;
  --brand-orange-hover: #e89616;
  --brand-orange-press: #d98a11;
  --accent-soft: rgba(245, 166, 35, 0.12);
  --accent-line: rgba(245, 166, 35, 0.34);
  --focus-ring: rgba(245, 166, 35, 0.40);

  /* Text */
  --text: #f2f4f5;
  --text-muted: #a9b1b7;
  --label: #9aa2a9;
  --hairline: rgba(255, 255, 255, 0.08);

  /* Surfaces that MUST stay light (PDF preview + signature pad) */
  --paper: #ffffff;

  /* Status */
  --danger: #ff8f8f;

  /* Shape + motion */
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-btn: 0 6px 16px rgba(245, 166, 35, 0.30);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

  --brand-logo: none;

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--page-bg);
  min-height: 100vh;
  line-height: 1.5;
}

.wrap { width: min(960px, 92vw); margin: 0 auto; }
main.wrap { padding-top: 28px; }

/* Stepper — a sticky progress bar: a connecting track with a gold fill up to
   the current step, plus numbered markers (upcoming = muted, current = gold
   ring, completed = filled gold check). */
.stepper {
  position: sticky;
  top: 0;
  z-index: 20;
  /* Concrete surface token (NOT --page-bg) so the bar stays opaque even when
     the page background is set to transparent for site embedding. */
  background: var(--slate);
  margin: 0 0 8px;
  padding: 14px 4px 12px;
  border-bottom: 1px solid var(--hairline);
}
.stepper ol {
  position: relative;
  display: flex;
  list-style: none; padding: 0; margin: 0;
}
/* Connecting track (muted) + gold fill. The line runs between the first and
   last marker centers (each item is 1/N wide with a centered marker, so the
   centers sit at 12.5% and 87.5% for 4 steps -> 75% span). `--fill` (0..1) is
   set from the step state in main.ts#setStep. */
.stepper ol::before,
.stepper ol::after {
  content: "";
  position: absolute;
  top: 15px;                 /* vertical center of the 30px markers */
  left: 12.5%;
  height: 3px;
  border-radius: 2px;
}
.stepper ol::before { width: 75%; background: var(--field-border); }
.stepper ol::after {
  width: calc(var(--fill, 0) * 75%);
  background: var(--brand-orange);
  transition: width 0.35s ease;
}
.stepper li {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}
.stepper .dot {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--slate-2);
  border: 2px solid var(--field-border);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.stepper .label { line-height: 1.2; }
/* Current step: gold ring highlight. */
.stepper li.active { color: var(--text); }
.stepper li.active .dot {
  background: var(--accent-soft);
  border-color: var(--brand-orange);
  color: var(--brand-orange);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
/* Completed steps: filled gold marker showing a check instead of the number. */
.stepper li.done { color: var(--text); }
.stepper li.done .dot {
  background: var(--brand-orange);
  border-color: var(--brand-orange);
  color: transparent;
  font-size: 0;
}
.stepper li.done .dot::after {
  content: "\2713";          /* ✓ */
  color: var(--slate);
  font-size: 0.95rem;
}
/* Narrow screens: keep markers + bar, drop the text labels to stay legible. */
@media (max-width: 480px) {
  .stepper .label { display: none; }
}
/* Keep programmatically scrolled sections clear of the sticky bar. */
#reviewSection, #signBlock, #successSection { scroll-margin-top: 84px; }

.intro { color: var(--text-muted); margin: 18px 2px 12px; font-weight: 500; }

/* Sections — kept as grouped fieldsets, but flattened onto the slate */
.card {
  background: var(--section-bg);
  border: 1px solid var(--section-border);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  margin: 14px 0;
}
fieldset.card { border: 1px solid var(--section-border); }
legend {
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--text);
  padding: 0 6px 0 0;
  margin-left: -2px;
}

/* Grid + fields */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 16px;
  margin-top: 6px;
}
.field { grid-column: span 2; display: flex; flex-direction: column; gap: 7px; }
.field-wide { grid-column: 1 / -1; }
.field-small { grid-column: span 1; }
.field > span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
/* Gold required asterisk, mirroring the target form's "LABEL *" style */
.field:has(:required) > span::after {
  content: " *";
  color: var(--brand-orange);
  font-weight: 800;
}
.field input, .field select {
  padding: 13px 14px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--field-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder { color: var(--placeholder); }
/* Closed select shows the chosen value in light text on the field surface. */
.field select { color: var(--text); }
/* Opened option list: on Windows/Chrome/Firefox the popup honors option
   color/background, so theme them to the slate for readable contrast (the
   previous hardcoded dark text was invisible on the dark popup). */
.field select option {
  color: var(--text);
  background-color: var(--field-bg);
}
/* Highlighted / selected item keeps light text on a gold-tinted background. */
.field select option:checked,
.field select option:hover,
.field select option:focus {
  color: var(--text);
  background-color: var(--slate-2);
}
/* Disabled placeholder ("Select…"): legible but visibly muted. */
.field select option[value=""],
.field select option:disabled {
  color: var(--placeholder);
  background-color: var(--field-bg);
}
/* When the placeholder is the current value, mute the closed control too. */
.field select:has(option[value=""]:checked) { color: var(--placeholder); }
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--field-border-focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.hint { color: var(--text-muted); font-size: 0.75rem; }
.optional { color: var(--text-muted); font-weight: 500; letter-spacing: 0; text-transform: none; }
.err { color: var(--danger); font-size: 0.75rem; min-height: 0.9em; font-style: normal; }
.field.invalid input, .field.invalid select { border-color: var(--danger); }

/* Buttons */
.actions { display: flex; align-items: center; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 26px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.05s, background 0.15s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--brand-orange); outline-offset: 2px; }
.btn-primary { background: var(--brand-orange); color: #ffffff; box-shadow: var(--shadow-btn); }
.btn-primary:hover { background: var(--brand-orange-hover); }
.btn-primary:active { background: var(--brand-orange-press); }
.btn-primary:disabled {
  background: #565b60;
  color: rgba(255, 255, 255, 0.75);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--field-border);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.form-error { color: var(--danger); font-size: 0.88rem; font-weight: 600; }

/* Review */
h2 { color: var(--text); margin-top: 0; }
h3 { color: var(--text); }
.muted { color: var(--text-muted); }
.pdf-frame {
  width: 100%;
  height: 620px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  background: var(--paper); /* PDF stays white — do not invert */
}
.consent-block { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--hairline); }
.consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--field-bg);
  color: var(--text-muted);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--field-border);
  cursor: pointer;
}
.consent input {
  margin-top: 4px;
  width: 18px; height: 18px;
  flex: none;
  accent-color: var(--brand-orange);
}

/* Signature — pad MUST stay light so the dark pen ink is visible */
.sign-block { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--hairline); }
.sig-wrap {
  border: 2px dashed var(--accent-line);
  border-radius: 12px;
  background: var(--paper);
  overflow: hidden;
}
.sig-pad { width: 100%; height: 200px; display: block; touch-action: none; cursor: crosshair; }
.sig-actions { margin: 10px 0 8px; }

/* Success */
.summary { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 16px 0 22px; }
.summary dt { font-weight: 700; color: var(--label); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; align-self: center; }
.summary dd { margin: 0; color: var(--text); }
.mono, .summary dd.mono { font-family: "Cascadia Code", Consolas, monospace; word-break: break-all; }

/* Footer */
.site-footer {
  margin-top: 44px;
  padding: 22px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--hairline);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-legal { flex: 1 1 auto; }
/* Brand logo rendered as a subtle solid-white silhouette in the bottom-right.
   Fallback path (no mask support): tint the <img>-like element white via filter.
   Default path (mask support): the alpha of the webp masks a white fill, so the
   original colors are irrelevant. Guarded by @supports so we never double-apply. */
.footer-logo {
  flex: 0 0 auto;
  display: block;
  width: 140px;
  max-width: 40vw;
  height: 40px;
  opacity: 0.55;
  /* Fallback: draw the image and force it white. */
  background-image: url("./oralhealthfirst-logo.webp");
  background-repeat: no-repeat;
  background-position: right center;
  background-size: contain;
  filter: brightness(0) invert(1);
}
@supports ((-webkit-mask-image: url("#")) or (mask-image: url("#"))) {
  .footer-logo {
    /* Mask path: replace the background+filter approach with a masked white fill. */
    background: #fff;
    filter: none;
    -webkit-mask-image: url("./oralhealthfirst-logo.webp");
    mask-image: url("./oralhealthfirst-logo.webp");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: right center;
    mask-position: right center;
    -webkit-mask-size: contain;
    mask-size: contain;
  }
}
@media (max-width: 520px) {
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 12px; }
  .footer-logo { width: 120px; height: 34px; align-self: flex-end; }
}

.hidden { display: none !important; }

/* Debug autofill indicator (only present when loaded with ?mock) */
.mock-badge {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--brand-orange);
  border: 1px solid var(--brand-orange);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  pointer-events: none;
}

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .field, .field-small { grid-column: span 2; }
}

/* --- Optional standalone header / logo-swap hook (not rendered by default) ---
   If a standalone brand header is reintroduced, add the `.brand` markup back
   and these rules will style it; set `--brand-logo` + class `has-logo` to swap
   in a real asset.

   .brand { display: flex; align-items: center; gap: 12px; }
   .brand-mark { width: 40px; height: 40px; color: var(--brand-orange); }
   .brand-name { font-weight: 800; font-size: 1.35rem; color: var(--brand-orange); }
   .brand.has-logo .brand-mark, .brand.has-logo .brand-name { display: none; }
   .brand.has-logo::before {
     content: ""; display: block; width: 200px; height: 44px;
     background: var(--brand-logo) left center / contain no-repeat;
   }
*/
