/* ================================================================
   conversion.css — Exit intent, sticky CTA, delayed popup, scroll bar,
                    and global form validator inline feedback styles
   Spec: §25 Conversion Optimization + §25E Form Validation
================================================================ */

/* ══════════════════════════════════════════════════════════════
   POPUP OVERLAY BASE
══════════════════════════════════════════════════════════════ */
.cx-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 14, 13, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.cx-overlay.cx-visible {
  opacity: 1;
  pointer-events: auto;
}

.cx-overlay.cx-exit {
  opacity: 0;
  pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   CARD BASE (shared by exit + delayed popups)
══════════════════════════════════════════════════════════════ */
.cx-card {
  background: #fff;
  border-radius: var(--radius-lg, 12px);
  position: relative;
  width: 100%;
  max-width: 540px;
  padding: var(--space-10, 2.5rem) var(--space-8, 2rem) var(--space-8, 2rem);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  transform: scale(0.82);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.46, 0.64, 1),
              opacity 0.25s ease;
  overflow: hidden;
}

.cx-overlay.cx-visible .cx-card {
  transform: scale(1);
  opacity: 1;
}

.cx-overlay.cx-exit .cx-card {
  transform: scale(0.9);
  opacity: 0;
  transition-timing-function: ease-in;
  transition-duration: 0.22s;
}

/* ══════════════════════════════════════════════════════════════
   CLOSE BUTTON
══════════════════════════════════════════════════════════════ */
.cx-close {
  position: absolute;
  top: var(--space-4, 1rem);
  right: var(--space-4, 1rem);
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-cream, #faf7f2);
  border-radius: 50%;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-muted, #6b6560);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background 0.18s, color 0.18s;
}

.cx-close:hover {
  background: var(--color-border, #e5e2de);
  color: var(--color-ink, #1a1917);
}

/* ══════════════════════════════════════════════════════════════
   EXIT POPUP — Blueprint Mockup (CSS-only)
══════════════════════════════════════════════════════════════ */
.cx-blueprint-mock {
  position: absolute;
  top: -16px;
  right: 24px;
  width: 72px;
  height: 96px;
  background: var(--color-ink, #1a1917);
  border-radius: 4px;
  transform: rotate(6deg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  z-index: 2;
}

.cx-bp-header {
  background: var(--color-gold, #c8963e);
  color: #fff;
  font-size: 4px;
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 4px;
  text-align: center;
}

.cx-bp-lines {
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cx-bp-lines span {
  display: block;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1px;
  width: 100%;
}

.cx-save-stamp {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) rotate(-22deg);
  background: var(--color-gold, #c8963e);
  color: #fff;
  font-size: 8.5px;
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 3px 6px;
  border-radius: 2px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   EXIT POPUP CONTENT
══════════════════════════════════════════════════════════════ */
.cx-eyebrow {
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-gold, #c8963e);
  margin: 0 0 var(--space-2, 0.5rem);
}

.cx-h2 {
  font-family: var(--font-display, 'Playfair Display', serif);
  font-size: clamp(1.25rem, 4vw, 1.65rem);
  font-weight: 900;
  color: var(--color-ink, #1a1917);
  margin: 0 0 var(--space-3, 0.75rem);
  letter-spacing: -0.02em;
  line-height: 1.18;
  padding-right: 64px; /* don't underlap mockup */
}

.cx-sub {
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.88rem;
  line-height: 1.72;
  color: var(--color-muted, #6b6560);
  margin: 0 0 var(--space-5, 1.25rem);
}

/* ══════════════════════════════════════════════════════════════
   POPUP FORM
══════════════════════════════════════════════════════════════ */
.cx-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 0.75rem);
}

.cx-input-wrap { position: relative; }

.cx-email-input {
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.93rem;
  color: var(--color-ink, #1a1917);
  background: #fff;
  border: 1.5px solid var(--color-border, #e5e2de);
  border-radius: var(--radius-sm, 6px);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.cx-email-input:focus {
  border-color: var(--color-gold, #c8963e);
  box-shadow: 0 0 0 3px rgba(200, 150, 62, 0.15);
}

.cx-email-input.cx-input-err {
  border-color: #c0392b;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

.cx-field-err {
  display: block;
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.72rem;
  color: #c0392b;
  margin-top: var(--space-1, 0.25rem);
}

.cx-field-err[hidden] { display: none; }

/* Gold CTA button (shared) */
.cx-btn-gold {
  display: block;
  width: 100%;
  background: var(--color-gold, #c8963e);
  color: #fff;
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: var(--space-4, 1rem) var(--space-6, 1.5rem);
  border: none;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.cx-btn-gold:hover {
  background: #a97828;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200, 150, 62, 0.3);
}

.cx-disclaimer {
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.72rem;
  color: var(--color-muted, #6b6560);
  text-align: center;
  margin: 0;
}

/* Success state */
.cx-success[hidden] { display: none; }

.cx-success-msg {
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.93rem;
  line-height: 1.6;
  color: #155724;
  background: #d4edda;
  border: 1px solid #c3e6cb;
  border-radius: var(--radius-sm, 6px);
  padding: var(--space-4, 1rem);
  margin: 0;
  text-align: center;
}

/* Decline link */
.cx-decline {
  display: block;
  text-align: center;
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.74rem;
  color: var(--color-muted, #6b6560);
  background: none;
  border: none;
  cursor: pointer;
  margin-top: var(--space-4, 1rem);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.18s;
}

.cx-decline:hover { color: var(--color-ink, #1a1917); }

/* ══════════════════════════════════════════════════════════════
   TIME-DELAYED POPUP (softer variant)
══════════════════════════════════════════════════════════════ */
.cx-delayed-card {
  text-align: center;
  padding: var(--space-10, 2.5rem) var(--space-8, 2rem) var(--space-8, 2rem);
}

.cx-delayed-emoji {
  font-size: 2.8rem;
  line-height: 1;
  margin: 0 0 var(--space-4, 1rem);
}

.cx-delayed-btn {
  display: inline-block;
  width: auto;
  padding: var(--space-4, 1rem) var(--space-8, 2rem);
  border-radius: 100px;
  margin: 0 auto var(--space-3, 0.75rem);
}

/* ══════════════════════════════════════════════════════════════
   STICKY FLOATING BUY BUTTON
══════════════════════════════════════════════════════════════ */
.cx-sticky-btn {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(110%);
  z-index: 900;
  background: var(--color-gold, #c8963e);
  border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
  display: flex;
  align-items: center;
  gap: var(--space-5, 1.25rem);
  padding: var(--space-4, 1rem) var(--space-8, 2rem) var(--space-4, 1rem) var(--space-7, 1.75rem);
  box-shadow: 0 -4px 24px rgba(200, 150, 62, 0.28);
  transition: transform 0.32s cubic-bezier(0.34, 1.2, 0.64, 1);
  white-space: nowrap;
}

.cx-sticky-btn.cx-visible {
  transform: translateX(-50%) translateY(0);
}

.cx-sticky-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  cursor: pointer;
  gap: 2px;
}

.cx-sticky-main {
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}

.cx-sticky-sub {
  font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.2;
}

.cx-sticky-close {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s;
  line-height: 1;
}

.cx-sticky-close:hover { background: rgba(255, 255, 255, 0.32); }

/* ══════════════════════════════════════════════════════════════
   SCROLL-TRIGGERED CTA BAR
══════════════════════════════════════════════════════════════ */
.cx-scroll-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 910;
  background: var(--color-ink, #1a1917);
  border-top: 2px solid var(--color-gold, #c8963e);
  transform: translateY(100%);
  transition: transform 0.28s ease;
}

.cx-scroll-bar.cx-visible { transform: translateY(0); }

.cx-scroll-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-3, 0.75rem) var(--space-6, 1.5rem);
  display: flex;
  align-items: center;
  gap: var(--space-4, 1rem);
}

.cx-scroll-bar-text {
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color-paper, #faf7f2);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cx-scroll-bar-btn {
  background: #fff;
  color: var(--color-ink, #1a1917);
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.8rem;
  font-weight: 700;
  padding: var(--space-2, 0.5rem) var(--space-5, 1.25rem);
  border-radius: 100px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s;
}

.cx-scroll-bar-btn:hover {
  background: var(--color-gold, #c8963e);
  color: #fff;
}

.cx-scroll-bar-close {
  background: none;
  border: none;
  color: rgba(250, 247, 242, 0.45);
  font-size: 1rem;
  cursor: pointer;
  padding: var(--space-1, 0.25rem) var(--space-2, 0.5rem);
  flex-shrink: 0;
  transition: color 0.18s;
  line-height: 1;
}

.cx-scroll-bar-close:hover { color: #fff; }

/* ══════════════════════════════════════════════════════════════
   FORM VALIDATOR INLINE FEEDBACK (global, injected by form-validator.js)
   Applied to any field with data-validate attribute across the site.
══════════════════════════════════════════════════════════════ */

/* Error border state */
.nv-invalid {
  border-color: #c0392b !important;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12) !important;
}

/* Valid border state */
.nv-valid {
  border-color: #27ae60 !important;
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1) !important;
}

/* Error message span (injected after the field) */
.nv-error-msg {
  display: block;
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-size: 0.72rem;
  font-weight: 500;
  color: #c0392b;
  margin-top: 4px;
  line-height: 1.45;
  animation: nv-fade-in 0.18s ease both;
}

.nv-err-icon {
  margin-right: 3px;
  font-size: 0.65rem;
}

/* Suggestion link inside error message */
.nv-suggestion-link {
  color: #c0392b;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.nv-suggestion-link:hover { color: var(--color-ink, #1a1917); }

/* Success checkmark span (injected after the field) */
.nv-success-indicator {
  display: block;
  font-size: 0.75rem;
  color: #27ae60;
  font-weight: 700;
  margin-top: 4px;
  animation: nv-fade-in 0.18s ease both;
}

@keyframes nv-fade-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 620px) {
  /* Overlay: align card to bottom, sheet slide-up */
  .cx-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .cx-card {
    max-width: 100%;
    border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
    /* Override scale to slide-up instead */
    transform: translateY(32px);
    transition: transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1),
                opacity 0.25s ease;
  }

  .cx-overlay.cx-visible .cx-card {
    transform: translateY(0);
    opacity: 1;
  }

  .cx-overlay.cx-exit .cx-card {
    transform: translateY(32px);
    opacity: 0;
  }

  /* Blueprint mockup hidden on mobile (space constraint) */
  .cx-blueprint-mock { display: none; }
  .cx-h2 { padding-right: 0; }

  /* Sticky button: full-width, no border-radius */
  .cx-sticky-btn {
    left: 0;
    right: 0;
    transform: translateY(110%);
    border-radius: 0;
    min-height: 56px;
    justify-content: space-between;
    padding-left: var(--space-5, 1.25rem);
    padding-right: var(--space-4, 1rem);
  }

  .cx-sticky-btn.cx-visible { transform: translateY(0); }

  /* Scroll bar: condense text */
  .cx-scroll-bar-text {
    font-size: 0.75rem;
  }

  .cx-scroll-bar-btn {
    font-size: 0.73rem;
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  }
}

@media (max-width: 400px) {
  .cx-scroll-bar-text {
    font-size: 0.68rem;
  }
}
