/* Customer-facing fill experience. Inherits tokens + components.css from
   the marketing surface; this file just lays out the form and a few
   fill-specific affordances (download CTA, "done" state). */

.page-fill { background: var(--c-page); color: var(--c-ink); }

.fill-main { padding-block: var(--s-7); }

.fill-container {
  max-width: 560px;
  margin: 0 auto;
  padding-inline: var(--s-5);
}

.fill-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  color: var(--c-ink);
  font-size: var(--fs-14);
  font-weight: 700;
}

.fill-brand__logo,
.fill-brand__mark {
  width: 38px;
  height: 38px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-page);
}

.fill-brand__logo {
  display: block;
  object-fit: contain;
}

.fill-brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-navy);
  font-family: var(--font-display);
}

.fill-title {
  font-family: var(--font-display);
  font-size: var(--fs-30);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: var(--s-2) 0 var(--s-2);
}

.fill-sub { margin: 0 0 var(--s-6); }

.fill-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  margin-top: var(--s-5);
}

.fill-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.fill-label {
  font-size: var(--fs-14);
  color: var(--c-muted);
  font-weight: 500;
}

.fill-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-page);
  color: var(--c-ink);
  font: inherit;
  line-height: 1.4;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.fill-input:focus,
.fill-input:focus-visible {
  outline: none;
  border-color: var(--c-navy);
  box-shadow: var(--focus-shadow);
}
.fill-field.is-invalid .fill-input,
.fill-input.is-invalid {
  border-color: var(--c-danger);
  background: var(--c-danger-soft);
}
.fill-field.is-invalid .fill-input:focus,
.fill-input.is-invalid:focus {
  box-shadow: 0 0 0 3px var(--c-danger-line);
}
.fill-field__error {
  color: var(--c-danger);
  font-size: var(--fs-12);
  margin-top: var(--s-1);
}
.fill-input::placeholder { color: var(--c-muted); opacity: 0.5; }

/* ---------- input + fixed suffix ("local@" composite) ----------
 * Used by the "Use @domain.com address?" affordance on email fields whose
 * placeholder is a full email. The suffix is a sibling span that visually
 * sits inside the input chrome. Standard Stripe-style pattern. */
.fill-input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-page);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.fill-input-group:focus-within {
  border-color: var(--c-navy);
  box-shadow: var(--focus-shadow);
}
.fill-input-group.is-invalid {
  border-color: var(--c-danger);
  background: var(--c-danger-soft);
}
/* When the suffix is shown, the input loses its own border and rounding
   on the right so the two visually fuse into one control. */
.fill-input-group .fill-input--with-suffix {
  border: 0;
  background: transparent;
  border-radius: var(--r-md) 0 0 var(--r-md);
  flex: 1 1 auto;
  min-width: 0;
}
.fill-input-group .fill-input--with-suffix:focus,
.fill-input-group .fill-input--with-suffix:focus-visible {
  outline: none;
  box-shadow: none;
}
.fill-input__suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-left: 1px solid var(--c-border);
  color: var(--c-muted);
  background: transparent;
  font-size: var(--fs-14);
  white-space: nowrap;
  user-select: none;
}
/* In free-form mode the suffix is hidden; the input takes the full width. */
.fill-input-group:not(.is-suffixed) .fill-input__suffix { display: none; }
.fill-input-group:not(.is-suffixed) .fill-input--with-suffix {
  border-radius: var(--r-md);
}

/* ---------- domain toggle row ----------
 * Compact opt-out under the input. Checkbox + tiny label, all inline. */
.fill-email-with-toggle {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.fill-domain-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-12);
  color: var(--c-muted);
  margin-top: 2px;
}
.fill-domain-toggle .fill-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--c-navy);
  cursor: pointer;
}
.fill-domain-toggle .fill-checkbox-label {
  cursor: pointer;
  user-select: none;
}
.fill-domain-toggle .fill-checkbox-label strong {
  color: var(--c-ink);
  font-weight: 600;
}
.fill-select {
  min-height: 44px;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--c-muted) 50%),
    linear-gradient(135deg, var(--c-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.fill-divider {
  border: 0;
  border-top: 1px solid var(--c-border);
  margin: var(--s-3) 0 var(--s-2);
}

.fill-hint { font-size: var(--fs-12); margin-top: -2px; }

.fill-submit { margin-top: var(--s-3); align-self: flex-start; }

.fill-cta-row {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-5);
}

.fill-done .fill-cta-row .btn { padding-inline: var(--s-6); }

.inline-error {
  background: var(--c-danger-soft);
  border: 1px solid var(--c-danger-line);
  color: var(--c-danger);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--fs-14);
}

/* ---------- done state ----------
 * Phase 5: success check above the title so the moment reads as
 * "complete" before the eye lands on the headline. Sage check on a
 * --c-success-soft round bg — matches the badge family. */
.fill-done .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.fill-done .eyebrow::before {
  content: '✓';
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--c-success-soft);
  color: var(--c-success);
  font-weight: 700;
  font-size: var(--fs-16);
}
.fill-done .fill-title { margin-top: var(--s-4); }

/* ---------- trust footer ----------
 * Renders below the form / done state, gives a quiet credibility signal.
 * Hidden when embedded (the parent page owns its own trust framing). */
.fill-trust {
  margin-top: var(--s-8);
  padding-top: var(--s-5);
  border-top: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: var(--fs-12);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}
.fill-trust__lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--c-ink);
}
.fill-trust__lock::before {
  content: '';
  width: 12px;
  height: 12px;
  background: var(--c-sage);
  border-radius: 2px;
  display: inline-block;
}
.fill-trust__chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  list-style: none;
  padding: 0;
  margin: 0;
}
.fill-trust__chips li {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  background: var(--c-page);
}
body.is-embedded .fill-trust { display: none; }

/* ---------- Live preview (next to the form) ----------
 * Stacks under the form ≤768px; side-by-side above. The "paper" panel
 * holds an SVG that re-renders text content as the customer types. This
 * is a visual orientation aid, NOT a press proof — the server-side
 * renderer is the source of truth for the final PDF. */
.fill-container--with-preview {
  /* Wider container when the preview is in play, but stop short of full
   * marketing-band width so a single-column phone view still feels calm. */
  max-width: min(960px, 100%);
}
.fill-split {
  display: grid;
  gap: var(--s-5);
  grid-template-columns: 1fr;
  margin-top: var(--s-5);
  align-items: start;
}
.fill-preview {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.fill-preview__paper {
  background: var(--c-page);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: var(--s-3);
  position: relative;
}
.fill-preview__svg {
  display: block;
  width: 100%;
  height: auto;
  /* Subtle paper drop so the rendered card sits visually on a page. */
  border-radius: var(--r-sm);
}
.fill-preview__hint {
  font-size: var(--fs-12);
  line-height: var(--lh-snug);
  margin: 0;
}

/* ---------- preview disclaimer ----------
 * Sits below the preview paper. More prominent than the old hint so a
 * customer scanning the card doesn't miss it before submitting. */
.fill-preview__disclaimer {
  font-size: var(--fs-13);
  line-height: 1.5;
  margin: 0;
  padding: var(--s-3) var(--s-4);
  background: var(--c-warning-soft);
  border: 1px solid var(--c-warning-line);
  color: var(--c-ink);
  border-radius: var(--r-md);
}
.fill-preview__disclaimer strong { color: var(--c-ink); }
.fill-preview__disclaimer em { font-style: normal; font-weight: 600; }

/* ---------- preview loading state ----------
 * Applied to .fill-preview__paper until the backdrop <image> and the
 * team FontFace promises have settled. Inner SVG gets blurred + dimmed
 * so the customer perceives "loading, not broken." A small ring spinner
 * sits centered above the blur. The transition out is short — once the
 * fonts swap in, we want the preview to feel snappy. */
.fill-preview__paper.is-loading .fill-preview__svg {
  filter: blur(4px) brightness(0.96);
  transition: filter var(--t-fast), opacity var(--t-fast);
  opacity: 0.85;
}
.fill-preview__paper.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border-radius: 50%;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-navy);
  animation: fill-preview-spin 0.9s linear infinite;
  pointer-events: none;
}
.fill-preview__paper .fill-preview__svg {
  filter: none;
  opacity: 1;
  transition: filter var(--t-fast), opacity var(--t-fast);
}
@keyframes fill-preview-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .fill-preview__paper.is-loading::after {
    animation: none;
    /* Replace the spin with a static pulse so the indicator is still
       perceptible without motion. */
    opacity: 0.6;
  }
}
@media (min-width: 768px) {
  .fill-split {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--s-6);
  }
  .fill-preview {
    position: sticky;
    top: 88px;
  }
}

/* Make the .fill-cta-row work with the new Edit button + download */
.fill-done .fill-cta-row { flex-wrap: wrap; }
