/* === RD Popup — shared styles for engagement, post-render, and promo === */

/* --- Backdrop (used by promo modal; engagement/post-render do not dim) --- */
.rdp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 10, 13, 0.65);
  z-index: 9994;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.rdp-backdrop.is-open { opacity: 1; pointer-events: auto; }

/* --- Base popup container (chat bubble) --- */
.rdp {
  position: fixed;
  bottom: 100px;
  right: 22px;
  width: 340px;
  max-width: calc(100vw - 28px);
  max-height: calc(100dvh - 32px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  z-index: 9995;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, Arial, Helvetica, sans-serif;
  color: #131313;
}
.rdp.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* --- Modal variant (used by promo + engagement chat) --- */
.rdp.rdp--modal {
  bottom: 50%;
  right: 50%;
  transform: translate(50%, 50%) scale(0.96);
  width: 640px;
  max-width: calc(100vw - 32px);
  transform-origin: center;
  border-radius: 22px;
}
.rdp.rdp--modal.is-open { transform: translate(50%, 50%) scale(1); }

/* Chat-style centered modal (Madison engagement) — narrower than promo */
.rdp.rdp--modal-chat {
  width: 400px;
}

/* --- Header --- */
.rdp-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: #fff;
  border-bottom: 1px solid #f0f1f4;
}
.rdp-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #d61f26;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
  flex-shrink: 0;
}
.rdp-persona-name { font-weight: 700; font-size: 0.98rem; line-height: 1.1; }
.rdp-persona-sub { font-size: 0.78rem; color: #667085; margin-top: 2px; }
.rdp-close {
  margin-left: auto;
  background: none; border: none;
  font-size: 22px; line-height: 1;
  color: #667085; cursor: pointer;
  padding: 4px 8px; border-radius: 6px;
}
.rdp-close:hover { background: #f5f6f8; color: #131313; }

/* --- Body --- */
.rdp-body { padding: 16px 18px 18px; }
.rdp-message { font-size: 0.95rem; line-height: 1.45; margin: 0 0 14px; }
.rdp-message strong { color: #d61f26; }

/* "Typing…" pre-message */
.rdp-typing {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.85rem; color: #667085;
  margin: 0 0 14px;
}
.rdp-typing-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #c7c7cc;
  animation: rdpTyping 1s infinite ease-in-out;
}
.rdp-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.rdp-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes rdpTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* --- Form --- */
.rdp-field { display: block; margin-bottom: 10px; }
.rdp-field label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: #475467; margin-bottom: 4px;
}
.rdp-field input,
.rdp-field textarea {
  width: 100%; box-sizing: border-box;
  border: 1px solid #d0d5dd; border-radius: 8px;
  padding: 9px 11px; font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rdp-field input:focus,
.rdp-field textarea:focus {
  outline: none;
  border-color: #d61f26;
  box-shadow: 0 0 0 3px rgba(214, 31, 38, 0.15);
}
.rdp-field textarea { resize: vertical; min-height: 64px; }
.rdp-field-error {
  font-size: 0.75rem; color: #d61f26; margin-top: 4px; display: none;
}
.rdp-field.has-error .rdp-field-error { display: block; }
.rdp-field.has-error input,
.rdp-field.has-error textarea { border-color: #d61f26; }

.rdp-submit {
  width: 100%;
  background: #d61f26; color: #fff;
  border: none; border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  margin-top: 4px;
}
.rdp-submit:hover { background: #a31319; }
.rdp-submit:disabled { background: #c7c7cc; cursor: not-allowed; }
.rdp-submit-error {
  margin-top: 8px; padding: 8px 10px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
  font-size: 0.82rem; color: #a31319;
}

/* --- Success state --- */
.rdp-success {
  text-align: center; padding: 8px 0 4px;
}
.rdp-success-check {
  width: 44px; height: 44px; border-radius: 50%;
  background: #ecfdf5; color: #0f766e;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 10px;
}
.rdp-success-text { font-size: 0.95rem; line-height: 1.45; }

/* --- Countdown (promo modal only) --- */
.rdp-countdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 18px;
}
.rdp-countdown-cell {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}
.rdp-countdown-num {
  font-size: 1.6rem; font-weight: 800;
  color: #a31319;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.rdp-countdown-label {
  font-size: 0.7rem; font-weight: 600;
  color: #92400e; text-transform: uppercase;
  letter-spacing: 0.04em; margin-top: 4px;
}

/* --- Bare header (promo modal: no persona, just close + headline) --- */
.rdp-header-bare {
  border-bottom: none;
  padding: 14px 18px 0;
  position: relative;
}
.rdp-header-bare .rdp-close {
  position: absolute;
  top: 10px; right: 10px;
}
.rdp-bare-headline { padding-right: 36px; }
.rdp-promo-headline {
  font-size: 1.35rem;
  font-weight: 800;
  color: #a31319;
  line-height: 1.15;
  margin-bottom: 4px;
}
.rdp-promo-subline {
  font-size: 0.95rem;
  color: #475467;
  line-height: 1.4;
}

/* ====================================================================
   Qualification Quiz (Medvi-adapted)
   ==================================================================== */

/* When quiz is open, hide the promo banner and contact-widget FAB so the
   modal owns the screen — Medvi tunnel-vision pattern. */
body.rdp-quiz-active .promo-banner,
body.rdp-quiz-active .cw-fab,
body.rdp-quiz-active .cw-panel,
body.rdp-quiz-active .cw-backdrop { display: none !important; }

/* Wider modal for the quiz (more breathing room than the chat-modal) */
.rdp.rdp--quiz {
  width: 480px;
  border-radius: 22px;
  padding: 0;
}

.rdp-quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: none;
}
.rdp-quiz-persona {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.rdp-quiz-header .rdp-close {
  margin-left: auto;
}

/* Progress bar (endowed-progress: starts at 20%, animates forward) */
.rdp-progress-track {
  height: 4px;
  background: #f0f1f4;
  margin: 0 20px;
  border-radius: 2px;
  overflow: hidden;
}
.rdp-progress-fill {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, #d61f26, #a31319);
  border-radius: 2px;
  transition: width 0.5s ease-out;
}

/* Trust strip */
.rdp-trust-strip {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475467;
  background: #f9fafb;
  padding: 8px 20px;
  margin: 12px 20px 0;
  border-radius: 8px;
  letter-spacing: 0.01em;
}

/* Quiz body */
.rdp-quiz-body {
  padding: 18px 20px 22px;
  position: relative;
}
.rdp-quiz-q {
  font-size: 1.15rem;
  font-weight: 700;
  color: #131313;
  margin: 0 0 14px;
  line-height: 1.3;
}
.rdp-quiz-sub {
  font-size: 0.88rem;
  color: #667085;
  margin: -6px 0 14px;
  line-height: 1.4;
}

/* Chips — grid (project type, step 1) */
.rdp-chips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.rdp-chip-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 8px;
  background: #fff;
  border: 1.5px solid #e4e7ec;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.rdp-chip-grid:hover {
  border-color: #d61f26;
  background: #fef2f2;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(214, 31, 38, 0.10);
}
.rdp-chip-grid.is-selected {
  border-color: #d61f26;
  background: #fef2f2;
}
.rdp-chip-emoji {
  font-size: 1.6rem;
  line-height: 1;
}
.rdp-chip-grid .rdp-chip-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #131313;
  text-align: center;
}

/* Chips — vertical list (scope, timeline) */
.rdp-chips-vertical {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rdp-chip-vertical {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1.5px solid #e4e7ec;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  font-family: inherit;
}
.rdp-chip-vertical:hover {
  border-color: #d61f26;
  background: #fef2f2;
  transform: translateY(-1px);
}
.rdp-chip-vertical-body { flex: 1; min-width: 0; }
.rdp-chip-vertical .rdp-chip-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #131313;
  margin-bottom: 2px;
}
.rdp-chip-sub {
  font-size: 0.82rem;
  color: #667085;
}
.rdp-chip-arrow {
  color: #c7c7cc;
  flex-shrink: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}
.rdp-chip-vertical:hover .rdp-chip-arrow {
  color: #d61f26;
  transform: translateX(2px);
}

/* "Most popular" / "Spring Sale eligible" tags */
.rdp-chip-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #fff7ed;
  color: #92400e;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: 1px;
}
.rdp-chip-tag-popular {
  background: #d61f26;
  color: #fff;
}
.rdp-chip-popular {
  border-color: #fed7aa;
  background: #fffbeb;
}
.rdp-chip-popular:hover {
  border-color: #d61f26;
}

/* Affirmation flash */
.rdp-affirm {
  position: absolute;
  left: 20px; right: 20px;
  bottom: 18px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.rdp-affirm.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ZIP step */
.rdp-zip-form {
  display: flex;
  gap: 10px;
}
.rdp-zip-input {
  flex: 1;
  border: 1.5px solid #d0d5dd;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
}
.rdp-zip-input:focus {
  outline: none;
  border-color: #d61f26;
  box-shadow: 0 0 0 3px rgba(214, 31, 38, 0.15);
}
.rdp-zip-submit {
  width: auto;
  margin: 0;
  padding: 12px 22px;
  flex-shrink: 0;
}
.rdp-zip-result {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 10px;
}
.rdp-zip-result-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.rdp-zip-result-warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fed7aa;
}
.rdp-zip-result-error {
  background: #fef2f2;
  color: #a31319;
  border: 1px solid #fecaca;
}
.rdp-zip-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* "You qualify" badge on contact step */
.rdp-qualified {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #131313;
}
.rdp-qualified-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 0.85rem;
}

/* Trust line under contact form */
.rdp-trust-line {
  font-size: 0.75rem;
  color: #667085;
  text-align: center;
  margin-top: 10px;
}

/* Final reciprocity screen */
.rdp-final {
  text-align: center;
}
.rdp-final-check {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #f0fdf4;
  color: #16a34a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  margin: 0 auto 14px;
}
.rdp-final-headline {
  font-size: 1.3rem;
  font-weight: 800;
  color: #131313;
  margin: 0 0 6px;
}
.rdp-final-sub {
  color: #475467;
  font-size: 0.95rem;
  margin: 0 0 16px;
}
.rdp-final-list {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  counter-reset: rdpfinal;
}
.rdp-final-list li {
  counter-increment: rdpfinal;
  padding: 12px 14px 12px 44px;
  margin-bottom: 8px;
  background: #f9fafb;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
}
.rdp-final-list li::before {
  content: counter(rdpfinal);
  position: absolute;
  left: 12px; top: 12px;
  width: 22px; height: 22px;
  background: #d61f26;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.78rem;
}
.rdp-final-link {
  color: #d61f26;
  font-weight: 700;
  text-decoration: none;
}
.rdp-final-link:hover { text-decoration: underline; }
.rdp-final-promise {
  text-align: left;
  background: #fef2f2;
  border-left: 3px solid #d61f26;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #475467;
}

/* --- Mobile --- */
@media (max-width: 480px) {
  .rdp { bottom: 84px; right: 14px; left: 14px; width: auto; max-width: none; }
  .rdp.rdp--modal {
    bottom: 50%; right: 50%; left: auto;
    width: calc(100vw - 24px); max-width: none;
  }
  .rdp.rdp--quiz { width: calc(100vw - 24px); }
  .rdp-chips-grid { grid-template-columns: repeat(2, 1fr); }
  .rdp-chip-emoji { font-size: 1.4rem; }
  .rdp-quiz-q { font-size: 1.05rem; }
  .rdp-trust-strip { font-size: 0.7rem; padding: 7px 10px; }
}

/* --- Print --- */
@media print {
  .rdp, .rdp-backdrop { display: none !important; }
}
