/* ── Demo Modal v2 ──
   Self-contained styles using tokens.css variables.
   Progressive staged form, social proof, abandoned capture.
   Include AFTER tokens.css and components.css. */

@keyframes demo-spin {
  to { transform: rotate(360deg); }
}
@keyframes demo-fade-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes demo-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Backdrop & Wrapper ── */
#demo-request-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.15s ease;
}
#demo-request-modal.hidden { display: none !important; }
#demo-request-modal.demo-modal-closing { opacity: 0; pointer-events: none; }

#demo-request-modal > div[data-demo-backdrop] {
  position: absolute;
  inset: 0;
  background: rgba(8,17,42,0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#demo-request-modal > div[data-demo-wrapper] {
  position: relative;
  z-index: 10;
  display: flex;
  min-height: 100%;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* ── Card ── */
.demo-modal-card {
  width: 100%;
  max-width: 34rem;
  background: var(--color-white, #fff);
  border-radius: 1.5rem;
  box-shadow:
    0 2px 6px rgba(8,17,42,0.06),
    0 12px 40px rgba(8,17,42,0.12),
    0 0 0 1px rgba(74,111,232,0.08);
  overflow: hidden;
  animation: demo-fade-in 0.25s ease;
}

/* ── Accent bar ── */
.demo-modal-card::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-primary, #4a6fe8), var(--accent-teal, #14b8a6));
}

/* ── Header ── */
.demo-modal-header {
  padding: calc(var(--space-6, 1.5rem) + 2px) var(--space-6, 1.5rem) var(--space-5, 1.25rem);
  position: relative;
}
.demo-modal-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3, 0.75rem);
  margin-bottom: var(--space-3, 0.75rem);
  color: var(--brand-primary, #4a6fe8);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.demo-modal-kicker::before {
  content: '';
  flex: 0 0 auto;
  width: 1.5rem;
  height: 2px;
  background: var(--brand-primary, #4a6fe8);
  border-radius: 1px;
}
.demo-modal-heading {
  margin: 0 0 var(--space-2, 0.5rem);
  color: var(--text-primary, #0a1628);
  font-family: var(--font-serif, 'Fraunces', serif);
  font-size: 1.75rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.demo-modal-sub {
  margin: 0;
  color: var(--text-secondary, #4B5563);
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* ── Social proof strip ── */
.demo-social-strip {
  margin: 0 var(--space-6, 1.5rem) var(--space-2, 0.5rem);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  background: rgba(74,111,232,0.04);
  border: 1px solid rgba(74,111,232,0.1);
  border-radius: var(--radius-sm, 0.75rem);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-secondary, #4B5563);
}
.demo-social-strip .demo-stars {
  color: #F59E0B;
  letter-spacing: 0.05em;
}

/* ── Smart routing copy ── */
.demo-route-hint {
  margin: 0 var(--space-6, 1.5rem);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  background: var(--brand-light, rgba(74,111,232,0.06));
  border-radius: var(--radius-sm, 0.75rem);
  font-size: 0.875rem;
  color: var(--brand-primary, #4a6fe8);
  line-height: 1.5;
  font-weight: 500;
  display: none;
}
.demo-route-hint.visible { display: block; }

/* ── Dismiss button ── */
.demo-dismiss {
  position: absolute;
  top: var(--space-4, 1rem);
  right: var(--space-4, 1rem);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--color-navy-900, #0a1628);
  border: none;
  border-radius: 50%;
  color: var(--color-white, #fff);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.demo-dismiss:hover {
  background: var(--color-navy-700, #1a2f5e);
  transform: scale(1.05);
}
.demo-dismiss svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* ── Form body ── */
.demo-modal-body {
  padding: 0 var(--space-6, 1.5rem) var(--space-6, 1.5rem);
}

/* ── Steps ── */
.demo-step { display: none; animation: demo-slide-up 0.25s ease; }
.demo-step.active { display: block; }

/* ── Step 1: Email-only ── */
.demo-step-1 {
  text-align: center;
  padding-top: var(--space-4, 1rem);
}
.demo-step-1 .input-el {
  text-align: center;
  font-size: 1.0625rem;
  padding: 0.875rem 1rem;
}

/* ── Form fields ── */
.demo-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.demo-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.demo-field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary, #0a1628);
  letter-spacing: 0.02em;
}
.demo-input {
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 0.9375rem;
  color: var(--text-primary, #0a1628);
  background: var(--color-white, #fff);
  border: 1px solid var(--border-default, #E5E7EB);
  border-radius: 0.625rem;
  padding: 0.75rem 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}
.demo-input::placeholder { color: var(--text-muted, #9CA3AF); }
.demo-input:focus {
  border-color: var(--brand-primary, #4a6fe8);
  box-shadow: 0 0 0 3px rgba(74,111,232,0.12);
}
.demo-input.error { border-color: #ef4444; }
.demo-input.error:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }

.demo-error-text {
  font-size: 0.75rem;
  color: #ef4444;
  margin-top: 0.25rem;
}

.demo-hint {
  font-size: 0.75rem;
  color: var(--text-muted, #9CA3AF);
}

/* Two-column row */
.demo-row-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 480px) {
  .demo-row-two { grid-template-columns: 1fr; }
}

/* ── Choice pills (interests/systems) ── */
.demo-choice-label {
  display: block;
  cursor: pointer;
}
.demo-choice-label input[type="checkbox"],
.demo-choice-label input[type="radio"] {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.demo-choice-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--border-default, #E5E7EB);
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary, #4B5563);
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.demo-choice-pill:hover {
  border-color: var(--brand-primary, #4a6fe8);
  background: rgba(74,111,232,0.04);
}
.demo-choice-label input:checked ~ .demo-choice-pill {
  border-color: var(--brand-primary, #4a6fe8);
  background: rgba(74,111,232,0.06);
  color: var(--brand-primary, #4a6fe8);
}
.demo-choice-check {
  width: 1rem;
  height: 1rem;
  color: var(--brand-primary, #4a6fe8);
  opacity: 0;
  flex-shrink: 0;
}
.demo-choice-label input:checked ~ .demo-choice-pill .demo-choice-check {
  opacity: 1;
}

/* ── Selected pills preview ── */
.demo-pills-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  min-height: 0;
}
.demo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-pill, 9999px);
  font-size: 0.75rem;
  font-weight: 500;
}
.demo-pill--selected {
  background: rgba(74,111,232,0.1);
  color: var(--brand-primary, #4a6fe8);
}
.demo-pill--empty {
  background: var(--color-gray-100, #F3F4F6);
  color: var(--text-muted, #9CA3AF);
}

/* ── Buttons ── */
.demo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8125rem 1.5rem;
  border: none;
  border-radius: var(--radius-pill, 9999px);
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
.demo-btn-primary {
  background: var(--brand-primary, #4a6fe8);
  color: var(--color-white, #fff);
}
.demo-btn-primary:hover {
  background: var(--brand-hover, #3658d4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74,111,232,0.25);
}
.demo-btn-primary:active { transform: translateY(0); }
.demo-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.demo-btn-secondary {
  background: transparent;
  color: var(--text-secondary, #4B5563);
  border: 1px solid var(--border-default, #E5E7EB);
}
.demo-btn-secondary:hover {
  background: var(--color-gray-50, #F9FAFB);
}

.demo-btn .demo-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: var(--color-white, #fff);
  border-radius: 50%;
  animation: demo-spin 0.7s linear infinite;
}

/* ── Step indicator dots ── */
.demo-step-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: var(--space-5, 1.25rem);
}
.demo-step-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-gray-200, #E5E7EB);
  transition: background 0.2s;
}
.demo-step-dot.active {
  background: var(--brand-primary, #4a6fe8);
}

/* ── Abandoned capture micro-modal ── */
.demo-abandon-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8,17,42,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 1.5rem;
  animation: demo-fade-in 0.2s ease;
}
.demo-abandon-card {
  width: 90%;
  max-width: 22rem;
  background: var(--color-white, #fff);
  border-radius: 1rem;
  padding: var(--space-5, 1.25rem);
  box-shadow: 0 8px 32px rgba(8,17,42,0.18);
  text-align: center;
}
.demo-abandon-card h3 {
  margin: 0 0 var(--space-2, 0.5rem);
  font-family: var(--font-serif, 'Fraunces', serif);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-primary, #0a1628);
}
.demo-abandon-card p {
  margin: 0 0 var(--space-4, 1rem);
  font-size: 0.875rem;
  color: var(--text-secondary, #4B5563);
  line-height: 1.6;
}
.demo-abandon-card .demo-abandon-input {
  margin-bottom: var(--space-3, 0.75rem);
}
.demo-abandon-card .demo-btn {
  width: 100%;
  margin-bottom: var(--space-2, 0.5rem);
}
.demo-abandon-skip {
  font-size: 0.8125rem;
  color: var(--text-muted, #9CA3AF);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.25rem;
}
.demo-abandon-skip:hover { color: var(--text-secondary, #4B5563); }
.demo-abandon-thanks {
  display: none;
  padding: var(--space-3, 0.75rem) 0;
  color: var(--brand-primary, #4a6fe8);
  font-weight: 600;
  font-size: 0.9375rem;
}

/* ── Chili loading bridge ── */
#demo-chili-loading-bridge {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(10,18,42,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--color-white, #fff);
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
}
#demo-chili-loading-bridge .demo-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: var(--color-white, #fff);
  border-radius: 50%;
  animation: demo-spin 0.7s linear infinite;
}
#demo-chili-loading-bridge p {
  font-size: 0.9375rem;
  opacity: 0.8;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  #demo-request-modal > div[data-demo-wrapper] { padding: 0.75rem; }
  .demo-modal-card { border-radius: 1.25rem; max-height: 95vh; overflow-y: auto; }
  .demo-modal-heading { font-size: 1.5rem; }
}
@media (max-width: 480px) {
  .demo-modal-header { padding: var(--space-5, 1.25rem) var(--space-4, 1rem) var(--space-4, 1rem); }
  .demo-modal-body { padding: 0 var(--space-4, 1rem) var(--space-5, 1.25rem); }
  .demo-social-strip { margin: 0 var(--space-4, 1rem) var(--space-2, 0.5rem); font-size: 0.75rem; }
  .demo-route-hint { margin: 0 var(--space-4, 1rem); font-size: 0.8125rem; }
}
