/*
 * Contact form — structure and the press-and-hold check.
 * Colours come from custom properties so each site can theme it:
 *   --cf-text, --cf-muted, --cf-field-bg, --cf-border, --cf-border-focus,
 *   --cf-accent, --cf-accent-soft, --cf-error, --cf-radius
 */
.cf-form[hidden], [data-cf-success][hidden], [data-cf-review][hidden], [data-cf-ack][hidden] { display: none !important; }

.cf-form {
  --cf-text: #16181d;
  --cf-muted: #5f6672;
  --cf-field-bg: #fff;
  --cf-border: #c9ced6;
  --cf-border-focus: #2f6fdf;
  --cf-accent: #2f6fdf;
  --cf-accent-soft: rgba(47, 111, 223, .12);
  --cf-error: #c62828;
  --cf-radius: 12px;
  color: var(--cf-text);
  display: grid;
  gap: 24px;
}

.cf-field { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.cf-field > label, .cf-field > legend { font-weight: 700; font-size: .9375rem; padding: 0; }
.cf-optional { font-weight: 400; color: var(--cf-muted); margin-left: .4em; font-size: .875em; }
.cf-help { margin: 0; color: var(--cf-muted); font-size: .8125rem; }

.cf-form input[type="text"],
.cf-form input[type="email"],
.cf-form select,
.cf-form textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  font: inherit; font-size: 1rem; line-height: 1.5; color: var(--cf-text);
  background: var(--cf-field-bg); border: 1px solid var(--cf-border); border-radius: var(--cf-radius);
  transition: border-color .2s, box-shadow .2s;
}
.cf-form textarea { min-height: 168px; resize: vertical; }
.cf-form input:focus, .cf-form select:focus, .cf-form textarea:focus {
  outline: none; border-color: var(--cf-border-focus); box-shadow: 0 0 0 3px var(--cf-accent-soft);
}
.cf-form input[aria-invalid="true"], .cf-form select[aria-invalid="true"], .cf-form textarea[aria-invalid="true"] { border-color: var(--cf-error); }

/* Choices drawn as chips (radio buttons underneath) */
.cf-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.cf-choice { position: relative; }
.cf-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cf-choice > span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--cf-border); background: var(--cf-field-bg); font-size: .9375rem; cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.cf-choice input[aria-invalid="true"] + span { border-color: var(--cf-error); }
.cf-choice input:checked + span { border-color: var(--cf-accent); background: var(--cf-accent-soft); color: var(--cf-accent); font-weight: 700; }
.cf-choice input:focus-visible + span { box-shadow: 0 0 0 3px var(--cf-accent-soft); border-color: var(--cf-border-focus); }

.cf-error { margin: 0; color: var(--cf-error); font-size: .875rem; }
.cf-error:empty { display: none; }

/* Press-and-hold check */
.cf-check { display: grid; gap: 8px; justify-items: start; }
.cf-hold {
  --cf-p: 0;
  display: inline-flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 20px 8px 10px;
  border-radius: 999px; border: 1px solid var(--cf-border); background: var(--cf-field-bg); color: var(--cf-text);
  font: inherit; font-weight: 700; font-size: .9375rem; cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
  transition: border-color .2s, background .2s;
}
.cf-hold:focus-visible { outline: 2px solid var(--cf-border-focus); outline-offset: 3px; }
.cf-ring { width: 34px; height: 34px; flex: none; }
.cf-ring svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); }
.cf-ring circle { fill: none; stroke-width: 3; }
.cf-ring-track { stroke: var(--cf-border); }
.cf-ring-fill { stroke: var(--cf-accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--cf-p) * 100); }
.cf-ring-tick { fill: none; stroke: var(--cf-accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 22; stroke-dashoffset: 22; transform: rotate(90deg); transform-origin: 18px 18px; }
.cf-hold[data-state="holding"] { border-color: var(--cf-accent); }
.cf-hold[data-state="checking"] .cf-ring svg { animation: cf-spin 1s linear infinite; }
.cf-hold[data-state="checking"] .cf-ring-fill { stroke-dasharray: 30 70; stroke-dashoffset: 0; }
.cf-hold[data-state="done"] { border-color: var(--cf-accent); background: var(--cf-accent-soft); color: var(--cf-accent); cursor: default; }
.cf-hold[data-state="done"] .cf-ring-fill { stroke-dashoffset: 0; }
.cf-hold[data-state="done"] .cf-ring-tick { stroke-dashoffset: 0; transition: stroke-dashoffset .3s ease .05s; }
.cf-hint { margin: 0; color: var(--cf-muted); font-size: .8125rem; }
@keyframes cf-spin { to { transform: rotate(270deg); } }

.cf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.cf-status { margin: 0; font-size: .9375rem; color: var(--cf-muted); }
.cf-status:empty { display: none; }

/* Review step: the panel takes the place of the fields (the values stay in the form). */
.cf-form[data-step="review"] > :not([data-cf-review]):not(.cf-trap) { display: none !important; }
.cf-form :is(input, textarea, select, legend, [tabindex]) { scroll-margin-top: 96px; }
.cf-review { display: grid; gap: 20px; animation: cf-in .28s cubic-bezier(.2, .7, .2, 1); }
.cf-review > * { margin: 0; }
.cf-review-title { font-size: 1.125rem; }
.cf-review-title:focus { outline: none; }
.cf-summary {
  display: grid; grid-template-columns: minmax(6.5em, max-content) minmax(0, 1fr); gap: 14px 24px;
  padding: 18px 20px; border: 1px solid var(--cf-border); border-radius: var(--cf-radius);
  background: var(--cf-field-bg);
}
.cf-summary dt { font-weight: 700; font-size: .875rem; color: var(--cf-muted); }
.cf-summary dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.cf-summary .cf-summary-long { white-space: pre-wrap; }
.cf-summary .cf-summary-empty { color: var(--cf-muted); }
@media (max-width: 520px) {
  .cf-summary { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .cf-summary dd + dt { margin-top: 12px; }
}
.cf-back {
  appearance: none; background: none; border: 0; margin: 0; padding: 0 6px; min-height: 44px;
  font: inherit; font-weight: 600; color: var(--cf-text); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--cf-border);
}
.cf-back:hover { text-decoration-color: currentColor; }
.cf-back:focus-visible { outline: 2px solid var(--cf-border-focus); outline-offset: 2px; border-radius: 6px; }
.cf-back[disabled] { opacity: .5; cursor: default; }
@keyframes cf-in { from { opacity: 0; transform: translateY(6px); } }

/* Kept off screen for people; scripts that fill every input will fill this too. */
.cf-trap { position: absolute !important; left: -10000px !important; top: auto; width: 1px; height: 1px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .cf-hold[data-state="checking"] .cf-ring svg { animation: none; }
  .cf-review { animation: none; }
  .cf-form *, .cf-form *::before, .cf-form *::after { transition-duration: .01ms !important; }
}
