/**
 * style.css — WP Smart Lead Popup v1.1.0
 *
 * Design decisions:
 *  - Popup is ALWAYS centred (flexbox overlay, no bottom-sheet on mobile)
 *  - Input icons: SVG absolutely positioned, input has fixed left-padding
 *  - No spinner anywhere — button shows text + arrow only
 *  - Fluid card width: 92vw capped at 420px — works on every screen size
 *  - font-size: 16px on inputs prevents iOS Safari zoom
 *  - Four breakpoints: 480px, 400px, 360px, prefers-reduced-motion
 *
 * @package WP_Smart_Lead_Popup
 */

/* ─── Google Font ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --c-brand:        #864170;
  --c-brand-hover:  #6b3359;
  --c-brand-press:  #551f46;
  --c-brand-pale:   #f9f1f6;
  --c-brand-ring:   rgba(134, 65, 112, 0.18);
  --c-text:         #18080f;
  --c-muted:        #6d5566;
  --c-placeholder:  #c0a8b8;
  --c-border:       #e0ccd8;
  --c-border-focus: #864170;
  --c-bg:           #ffffff;
  --c-error:        #b91c1c;
  --c-error-bg:     #fef2f2;
  --c-success:      #166534;
  --c-success-bg:   #f0fdf4;
  --c-overlay:      rgba(12, 3, 9, 0.55);
  --radius:         14px;
  --radius-sm:      9px;
  --ease:           cubic-bezier(0.22, 1, 0.36, 1);
  --dur:            0.24s;
  --font:           'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* input geometry — ONE source of truth */
  --input-h:        46px;
  --input-icon-l:   13px;   /* left edge of icon */
  --input-icon-w:   14px;   /* icon width */
  --input-gap:      8px;    /* gap between icon and text */
  --input-pl: calc(var(--input-icon-l) + var(--input-icon-w) + var(--input-gap));
  /* = 13 + 14 + 8 = 35px */
}

/* ─── Overlay ─────────────────────────────────────────────────────────────── */
/*
 * Always centred — desktop, tablet, and mobile.
 * Uses align-items:center + justify-content:center at every viewport.
 * Padding prevents card from touching screen edges on narrow screens.
 */
.wslp-overlay {
  position:         fixed;
  inset:            0;
  z-index:          999999;
  display:          flex;
  align-items:      center;
  justify-content:  center;
  padding:          16px;
  box-sizing:       border-box;
  background:       var(--c-overlay);
  backdrop-filter:  blur(4px);
  -webkit-backdrop-filter: blur(4px);

  /* hidden by default */
  opacity:    0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease),
              visibility var(--dur) var(--ease);
}

.wslp-overlay.wslp-open {
  opacity:    1;
  visibility: visible;
}

/* ─── Card ────────────────────────────────────────────────────────────────── */
.wslp-card {
  position:      relative;
  overflow:      hidden;
  background:    var(--c-bg);
  border-radius: var(--radius);
  box-shadow:    0 20px 60px rgba(134,65,112,0.16),
                 0 4px 16px  rgba(0,0,0,0.08);
  width:         min(420px, 92vw);   /* fluid: 92% of viewport, max 420px */
  padding:       40px 32px 32px;
  box-sizing:    border-box;
  text-align:    center;
  font-family:   var(--font);

  /* entrance animation */
  transform:  translateY(20px) scale(0.97);
  transition: transform var(--dur) var(--ease);
}

.wslp-overlay.wslp-open .wslp-card {
  transform: translateY(0) scale(1);
}

/* top accent line */
.wslp-card::before {
  content:    '';
  position:   absolute;
  inset:      0 0 auto;
  height:     3px;
  background: linear-gradient(90deg, var(--c-brand-hover), #c06fa0, var(--c-brand));
}

/* ─── Close button ────────────────────────────────────────────────────────── */
.wslp-close {
  position:        absolute;
  top:             12px;
  right:           12px;
  width:           30px;
  height:          30px;
  border:          1px solid var(--c-border);
  border-radius:   50%;
  background:      transparent;
  color:           var(--c-muted);
  cursor:          pointer;
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         0;
  transition:      background var(--dur), color var(--dur), border-color var(--dur);
  z-index:         2;
}

.wslp-close:hover {
  background:    var(--c-brand-pale);
  color:         var(--c-brand);
  border-color:  var(--c-brand);
}

.wslp-close:focus-visible {
  outline:        2px solid var(--c-brand);
  outline-offset: 2px;
}

/* ─── Icon badge ──────────────────────────────────────────────────────────── */
.wslp-icon {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  width:           56px;
  height:          56px;
  border-radius:   50%;
  background:      linear-gradient(145deg, var(--c-brand), #a0507e);
  color:           #fff;
  margin-bottom:   16px;
  box-shadow:      0 6px 18px rgba(134,65,112,0.28);
  flex-shrink:     0;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */
.wslp-title {
  margin:         0 0 8px;
  font-size:      clamp(18px, 4.5vw, 22px);
  font-weight:    700;
  line-height:    1.2;
  letter-spacing: -0.3px;
  color:          var(--c-text);
}

.wslp-desc {
  margin:      0 0 22px;
  font-size:   clamp(13px, 3.2vw, 15px);
  line-height: 1.6;
  color:       var(--c-muted);
}

/* ─── Form ────────────────────────────────────────────────────────────────── */
#wslp-form-area { text-align: left; }

.wslp-field { margin-bottom: 13px; }

.wslp-label {
  display:        block;
  margin-bottom:  5px;
  font-size:      11.5px;
  font-weight:    600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color:          var(--c-muted);
}

.wslp-req { color: var(--c-brand); }

/* ─── Input wrapper + icon ────────────────────────────────────────────────── */
/*
 * The icon SVG is a sibling BEFORE the input in the DOM.
 * It is absolutely positioned to sit inside the input's left padding zone.
 * The input uses padding-left = --input-pl = 35px to clear the icon.
 * This avoids any flex-order or z-index tricks.
 */
.wslp-input-wrap {
  position: relative;  /* sole positioning context for the icon */
}

.wslp-field-icon {
  position:       absolute;
  left:           var(--input-icon-l);          /* 13px from left edge 
  top:            50%;
  transform:      translateY(-50%);
  width:          var(--input-icon-w);           /* 14px */
  height:         var(--input-icon-w);
  color:          var(--c-placeholder);
  pointer-events: none;
  transition:     color var(--dur);
  flex-shrink:    0;
  display:        block; 
  display: none !important;
}

/* icon goes brand when input is focused */
.wslp-input:focus ~ .wslp-field-icon,
.wslp-input-wrap:focus-within .wslp-field-icon {
  color: var(--c-brand);
}

.wslp-input {
  width:              100%;
  height:             var(--input-h);              /* 46px — consistent across browsers */
  padding:            0 12px 0 var(--input-pl);    /* left = 35px */
  border:             1.5px solid var(--c-border);
  border-radius:      var(--radius-sm);
  font-family:        var(--font);
  font-size:          16px;    /* 16px prevents iOS Safari auto-zoom */
  color:              var(--c-text);
  background:         var(--c-bg);
  box-sizing:         border-box;
  outline:            none;
  -webkit-appearance: none;
  transition:         border-color var(--dur), box-shadow var(--dur);
}

.wslp-input::placeholder { color: var(--c-placeholder); }

.wslp-input:focus {
  border-color: var(--c-border-focus);
  box-shadow:   0 0 0 3px var(--c-brand-ring);
}

.wslp-input.wslp-err {
  border-color: var(--c-error);
  box-shadow:   0 0 0 3px rgba(185,28,28,0.12);
}

/* ─── Error message ───────────────────────────────────────────────────────── */
.wslp-error {
  margin:        0 0 12px;
  padding:       9px 12px;
  background:    var(--c-error-bg);
  border:        1px solid rgba(185,28,28,0.2);
  border-radius: var(--radius-sm);
  font-size:     13px;
  line-height:   1.5;
  color:         var(--c-error);
  text-align:    left;
}

/* ─── Submit button ───────────────────────────────────────────────────────── */
/*
 * Layout: flex, text centred, arrow pinned to right via margin-left:auto.
 * NO spinner. NO absolutely-positioned children. Clean and simple.
 */
.wslp-btn {
  display:          flex;
  align-items:      center;
  justify-content:  center;
  gap:              8px;
  width:            100%;
  height:           48px;          /* fixed height — reliable on all devices */
  padding:          0 20px;
  border:           none;
  border-radius:    var(--radius-sm);
  background:       var(--c-brand);
  color:            #fff;
  font-family:      var(--font);
  font-size:        15px;
  font-weight:      600;
  letter-spacing:   0.01em;
  cursor:           pointer;
  transition:       background var(--dur), transform 0.14s ease, box-shadow var(--dur);
  box-shadow:       0 4px 14px rgba(134,65,112,0.32);
  -webkit-tap-highlight-color: transparent;
  user-select:      none;
}

.wslp-btn:hover:not(:disabled) {
  background:  var(--c-brand-hover);
  box-shadow:  0 6px 20px rgba(134,65,112,0.40);
  transform:   translateY(-1px);
}

.wslp-btn:active:not(:disabled) {
  background: var(--c-brand-press);
  transform:  translateY(0);
  box-shadow: 0 2px 8px rgba(134,65,112,0.28);
}

.wslp-btn:focus-visible {
  outline:        2px solid var(--c-brand);
  outline-offset: 3px;
}

.wslp-btn:disabled {
  opacity:   0.65;
  cursor:    not-allowed;
  transform: none !important;
}

/* loading state — text changes, arrow hidden, no spinner element */
.wslp-btn.wslp-loading .wslp-btn-arrow { display: none; }

.wslp-btn-arrow {
  flex-shrink: 0;
  margin-left: 2px;
  transition:  transform 0.14s ease;
}

.wslp-btn:hover:not(:disabled) .wslp-btn-arrow {
  transform: translateX(3px);
}

/* ─── Privacy note ────────────────────────────────────────────────────────── */
.wslp-privacy {
  margin:      10px 0 0;
  font-size:   12px;
  color:       #a890a0;
  text-align:  center;
  line-height: 1.5;
  display: none;
}

/* ─── Success state ───────────────────────────────────────────────────────── */
#wslp-success-area { text-align: center; padding: 12px 0 4px; }

@keyframes wslp-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  65%  { transform: scale(1.1); }
  100% { transform: scale(1);   opacity: 1; }
}

.wslp-success-icon {
  display:       inline-flex;
  color:         var(--c-success);
  margin-bottom: 14px;
  animation:     wslp-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.wslp-success-msg {
  margin:      0;
  font-size:   16px;
  font-weight: 600;
  line-height: 1.5;
  color:       var(--c-success);
}

/* ─── Responsive — 480px ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .wslp-card {
    padding: 36px 22px 28px;
  }

  .wslp-icon {
    width:         48px;
    height:        48px;
    margin-bottom: 13px;
  }

  .wslp-icon svg { width: 19px; height: 19px; }

  .wslp-desc { margin-bottom: 18px; }

  .wslp-btn { height: 46px; font-size: 14px; }
}

/* ─── Responsive — 400px ──────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .wslp-card { padding: 32px 18px 24px; }
  .wslp-title { font-size: 18px; }
}

/* ─── Responsive — 360px ──────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .wslp-card { padding: 28px 14px 22px; }

  .wslp-icon {
    width:  42px;
    height: 42px;
  }
}

/* ─── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .wslp-overlay,
  .wslp-card,
  .wslp-btn,
  .wslp-close,
  .wslp-input,
  .wslp-field-icon { transition: none; }

  .wslp-overlay.wslp-open .wslp-card { transform: none; }
  .wslp-success-icon { animation: none; }
}
