/* ============================================
   GEO intake form (/form)
   Light, single-card layout. Tokens copied from the logged-out auth pages
   (static/auth.css on development-james) so the public pages read as one
   product, with the GeoRank purple in place of indigo. Self-contained: this
   page does not extend base.html or read the app theme.
   ============================================ */

:root {
  /* Surfaces */
  --page-bg: #f3f4f6;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --card-shadow: 0 10px 30px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --subtle-bg: #f9fafb;

  /* Text */
  --text: #0f172a;
  --text-label: #334155;
  --text-muted: #64748b;
  --placeholder: #9ca3af;

  /* Inputs */
  --input-border: #d1d5db;
  --input-border-hover: #9ca3af;

  /* GeoRank brand, read from static/brand/georank-logo.svg. The primary is a
     deeper step of the brand purple so white text on it reaches 4.9:1. */
  --brand-purple: #a05fff;
  --brand-yellow: #f9b123;
  --primary: #8b45f5;
  --primary-hover: #7a35e6;
  --primary-text: #7a35e6;
  --primary-soft: #f5efff;
  --focus-ring: 0 0 0 3px rgba(160, 95, 255, 0.2);

  /* Status */
  --success: #15803d;
  --success-bg: #f0fdf4;
  --error: #b91c1c;
  --error-border: #f87171;
  --error-bg: #fef2f2;

  --radius-card: 16px;
  --radius-input: 8px;
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
}

/* ---- Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Layout: logo, then one centred card ---- */
.intake-shell {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px;
}

.brand-logo {
  display: block;
  width: 180px;
  height: auto;
  margin: 0 auto 24px;
}

.intake-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 36px 32px 32px;
  box-shadow: var(--card-shadow);
}

.intake-head h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.intake-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ---- Step indicator ---- */
.form-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-step .step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--input-border);
  background: var(--card-bg);
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.progress-step.active {
  color: var(--text);
  font-weight: 600;
}

.progress-step.active .step-number {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.progress-step.completed {
  color: var(--primary-text);
}

.progress-step.completed .step-number {
  border-color: var(--brand-purple);
  background: var(--primary-soft);
  color: var(--primary-text);
}

.progress-connector {
  flex: 1;
  min-width: 12px;
  height: 1px;
  background: var(--card-border);
}

.progress-connector.completed {
  background: var(--brand-purple);
}

/* ---- Sections (one per step) ---- */
.form-section + .form-section {
  border-top: 1px solid var(--card-border);
  margin-top: 28px;
  padding-top: 28px;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
}

/* Headings take focus on a step change (and the confirmation on success) so
   screen readers land on them. */
.section-header h2:focus,
.success-card h2:focus {
  outline: none;
}

.section-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- Fields ---- */
.field-group {
  margin-bottom: 18px;
}

fieldset.field-group {
  border: 0;
  padding: 0;
  margin-inline: 0;
  min-width: 0;
}

legend.field-label {
  padding: 0;
  width: 100%;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-label);
  margin-bottom: 6px;
}

.field-label .required {
  color: var(--primary-text);
  margin-left: 2px;
}

.field-label .optional {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
  margin-left: 4px;
}

.selection-count {
  color: var(--primary-text);
  font-weight: 500;
  font-size: 0.75rem;
  margin-left: 6px;
}

.selection-count:empty {
  display: none;
}

.field-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: -2px 0 8px;
}

.field-hint-below {
  margin: 6px 0 0;
}

input[type="text"],
input[type="email"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--input-border-hover);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-purple);
  box-shadow: var(--focus-ring);
}

select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 2.5rem;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.conditional-field {
  margin-top: 10px;
}

/* ---- Choice chips: checkboxes and radios ---- */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.audience-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-group {
  display: flex;
  gap: 8px;
}

.radio-item {
  flex: 1;
}

.checkbox-item,
.radio-item {
  position: relative;
}

.checkbox-item input[type="checkbox"],
.radio-item input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-item label,
.radio-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 9px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  background: var(--card-bg);
  color: var(--text-label);
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.radio-item label {
  justify-content: center;
  white-space: nowrap;
}

.checkbox-item label::before {
  content: '';
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--input-border);
  border-radius: 4px;
  background: var(--card-bg);
}

.checkbox-item label:hover,
.radio-item label:hover {
  border-color: var(--input-border-hover);
}

.checkbox-item input:checked + label,
.radio-item input:checked + label {
  border-color: var(--brand-purple);
  background: var(--primary-soft);
  color: var(--text);
}

.checkbox-item input:checked + label::before {
  border-color: var(--primary);
  background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
}

.checkbox-item input:focus-visible + label,
.radio-item input:focus-visible + label {
  border-color: var(--brand-purple);
  box-shadow: var(--focus-ring);
}

/* ---- Per-segment follow-ups ---- */
#segment-followups:not(:empty) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.segment-followup {
  background: var(--subtle-bg);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--brand-purple);
  border-radius: var(--radius-input);
  padding: 16px;
}

.segment-followup h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.segment-followup .field-group:last-child {
  margin-bottom: 0;
}

/* ---- Validation ---- */
.field-group.error input,
.field-group.error select,
.field-group.error textarea,
.field-group.error .checkbox-item label {
  border-color: var(--error-border);
}

.field-group.error input:focus,
.field-group.error select:focus,
.field-group.error textarea:focus {
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.field-group.error .field-label {
  color: var(--error);
}

.field-error {
  display: none;
  font-size: 0.8125rem;
  color: var(--error);
  margin-top: 6px;
}

.field-group.error .field-error {
  display: block;
}

/* ---- Buttons ---- */
.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--primary);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn-submit:hover {
  background: var(--primary-hover);
}

.btn-submit:active {
  transform: translateY(1px);
}

.btn-prev {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  background: var(--card-bg);
  color: var(--text-label);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.btn-prev:hover {
  border-color: var(--input-border-hover);
}

.btn-submit:focus-visible,
.btn-prev:focus-visible,
.btn-back:focus-visible {
  outline: 2px solid var(--brand-purple);
  outline-offset: 2px;
}

/* Loading state */
.btn-submit.loading {
  pointer-events: none;
  opacity: 0.85;
}

.btn-submit.loading .btn-text,
.btn-submit.loading .btn-arrow {
  visibility: hidden;
}

.btn-submit.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Step navigation and submit ---- */
.step-nav,
.js-only {
  display: none;
}

.submit-section {
  margin-top: 28px;
}

.submit-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.submit-row .btn-submit {
  flex: 1;
}

.submit-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 12px;
  text-align: center;
}

/* ---- One step at a time ----
   intake.js adds .js-steps to the form. Until it does, every section and the
   Submit button show and no step buttons do. */
.js-steps .form-section:not(.is-current) {
  display: none;
}

.js-steps .form-section.is-current {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.js-steps .step-nav {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
}

.js-steps .js-only {
  display: inline-flex;
}

.js-steps .step-nav .btn-next,
.js-steps .submit-row .btn-submit {
  flex: 0 1 auto;
  min-width: 140px;
}

/* Back sits on the left, the forward action on the right. */
.js-steps .step-nav .btn-prev,
.js-steps .submit-row .btn-prev {
  margin-right: auto;
}

.js-steps .submit-section {
  display: none;
}

.js-steps.on-last-step .submit-section {
  display: block;
}

.js-steps.on-last-step .submit-note {
  text-align: left;
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--primary-text);
  font-weight: 600;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ---- Success (modal on the same light card) ---- */
.success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(243, 244, 246, 0.92);
}

.success-overlay.visible {
  display: flex;
}

.success-card {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 36px 32px 32px;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 1.25rem;
  font-weight: 700;
}

.success-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.success-card p {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.success-card p strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.btn-back {
  padding: 10px 16px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  background: var(--card-bg);
  color: var(--text-label);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-back:hover {
  border-color: var(--input-border-hover);
}

/* ---- Error toast ---- */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-input);
  background: var(--error-bg);
  color: var(--error);
  font-size: 0.875rem;
  box-shadow: var(--card-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.error-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Utility ----
   input.visually-hidden outranks the text-input rule above, so the honeypot
   field stays 1px instead of stretching the page. */
.visually-hidden,
input.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Small screens ---- */
@media (max-width: 560px) {
  .intake-shell {
    padding: 24px 12px;
  }

  .intake-card {
    padding: 28px 20px 24px;
  }

  .field-row,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    gap: 0;
  }

  .progress-step:not(.active) .step-label {
    display: none;
  }

  .js-steps .step-nav .btn-next,
  .js-steps .submit-row .btn-submit {
    flex: 1;
    min-width: 0;
  }
}
