/* ============================================================
   PWL · conversion-kit
   CTA flotante WhatsApp + formulario de lead 2 pasos + barra
   sticky mobile. Theming por custom properties --pwl-ck-*.
   ============================================================ */

.pwl-wa,
.pwl-lead,
.pwl-ck-bar {
  /* ---- tokens (override desde cualquier ancestro) ---- */
  --pwl-ck-ink: #171b20;            /* texto / superficies oscuras */
  --pwl-ck-ink-soft: #4c545e;       /* texto secundario */
  --pwl-ck-surface: #ffffff;        /* superficie clara */
  --pwl-ck-surface-2: #f4f1ec;      /* superficie alterna (cálida) */
  --pwl-ck-line: #e2ddd4;           /* bordes */
  --pwl-ck-accent: #8a6a3b;         /* acento (bronce) — detalles, focus */
  --pwl-ck-accent-ink: #6f5430;     /* acento apto texto sobre claro */
  --pwl-ck-wa: #0e7a5f;             /* verde WhatsApp propio (profundo) */
  --pwl-ck-danger: #b3372f;
  --pwl-ck-ok: #1f7a4d;
  --pwl-ck-radius: 14px;
  --pwl-ck-radius-pill: 999px;
  --pwl-ck-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --pwl-ck-shadow: 0 1px 2px rgba(23, 27, 32, .08), 0 8px 24px rgba(23, 27, 32, .14);
  --pwl-ck-shadow-lg: 0 2px 4px rgba(23, 27, 32, .1), 0 18px 48px rgba(23, 27, 32, .22);
  --pwl-ck-ease: cubic-bezier(.22, 1, .36, 1);
  --pwl-ck-bar-h: 64px;
  --pwl-ck-z-float: 60;
  --pwl-ck-z-bar: 55;

  font-family: var(--pwl-ck-font);
}

/* ============================================================
   (a) CTA FLOTANTE WHATSAPP — .pwl-wa
   Pill con label expandible. Aparece tras N% de scroll (JS
   agrega .is-visible). Respeta safe-area.
   ============================================================ */

.pwl-wa {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right, 0px));
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--pwl-ck-z-float);
  opacity: 0;
  transform: translateY(140%) scale(.92);
  pointer-events: none;
  transition:
    transform .55s var(--pwl-ck-ease),
    opacity .4s ease;
}

.pwl-wa.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Cuando la barra sticky está visible en mobile, el pill se retira
   (la barra ya trae WhatsApp; evita doble CTA apilado). */
.pwl-wa.is-suppressed {
  opacity: 0;
  transform: translateY(140%) scale(.92);
  pointer-events: none;
}

.pwl-wa__link {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 6px;
  background: var(--pwl-ck-ink);
  color: var(--pwl-ck-surface);
  border-radius: var(--pwl-ck-radius-pill);
  box-shadow: var(--pwl-ck-shadow-lg);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .25s var(--pwl-ck-ease);
}

.pwl-wa__link:active { transform: scale(.97); }

.pwl-wa__chip {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--pwl-ck-wa);
  color: #fff;
}

.pwl-wa__chip svg { width: 24px; height: 24px; display: block; }

/* anillo de pulso sutil: solo transform/opacity, 3 repeticiones */
.pwl-wa__chip::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--pwl-ck-wa);
  opacity: 0;
  transform: scale(1);
  pointer-events: none;
}

.pwl-wa.is-visible .pwl-wa__chip::after {
  animation: pwl-wa-ping 2.4s var(--pwl-ck-ease) .8s 3;
}

@keyframes pwl-wa-ping {
  0%   { opacity: .55; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.65); }
  100% { opacity: 0;   transform: scale(1.65); }
}

/* Label expandible.
   NOTA: anima max-width (layout) a propósito — está contenido al pill
   (1 elemento, <13em) y no desplaza nada del documento. Justificación
   en README § Performance. */
.pwl-wa__label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: .01em;
  transition:
    max-width .45s var(--pwl-ck-ease),
    opacity .3s ease .08s,
    padding .45s var(--pwl-ck-ease);
}

.pwl-wa.is-expanded .pwl-wa__label {
  max-width: 13em;
  opacity: 1;
  padding-inline: .85em 1.1em;
}

.pwl-wa__link:focus-visible {
  outline: 2px solid var(--pwl-ck-accent);
  outline-offset: 3px;
}

/* ============================================================
   (b) FORMULARIO DE LEAD 2 PASOS — .pwl-lead
   ============================================================ */

.pwl-lead {
  background: var(--pwl-ck-surface);
  border: 1px solid var(--pwl-ck-line);
  border-radius: calc(var(--pwl-ck-radius) + 6px);
  box-shadow: var(--pwl-ck-shadow);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  max-width: 34rem;
  color: var(--pwl-ck-ink);
}

/* progreso */
.pwl-lead__progress {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.pwl-lead__progress-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--pwl-ck-accent-ink);
}

.pwl-lead__progress-track {
  height: 3px;
  border-radius: 2px;
  background: var(--pwl-ck-line);
  overflow: hidden;
}

.pwl-lead__progress-fill {
  height: 100%;
  background: var(--pwl-ck-accent);
  transform-origin: left center;
  transform: scaleX(.5);
  transition: transform .5s var(--pwl-ck-ease);
}

.pwl-lead[data-step="2"] .pwl-lead__progress-fill { transform: scaleX(1); }

.pwl-lead__step[hidden] { display: none; }

.pwl-lead__title {
  font-size: clamp(1.2rem, 3vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0 0 .35rem;
}

.pwl-lead__title:focus { outline: none; }

.pwl-lead__hint {
  margin: 0 0 1.25rem;
  color: var(--pwl-ck-ink-soft);
  font-size: .9375rem;
  line-height: 1.5;
}

/* fieldsets de elección (paso 1) */
.pwl-lead__group {
  border: 0;
  padding: 0;
  margin: 0 0 1.35rem;
}

.pwl-lead__legend {
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--pwl-ck-ink-soft);
  padding: 0;
  margin-bottom: .6rem;
}

.pwl-lead__choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.pwl-lead__choices--row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.pwl-lead__choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .5rem;
  padding: .8rem .6rem;
  border: 1px solid var(--pwl-ck-line);
  border-radius: var(--pwl-ck-radius);
  background: var(--pwl-ck-surface);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition:
    border-color .2s ease,
    background-color .2s ease,
    transform .2s var(--pwl-ck-ease);
}

.pwl-lead__choice:hover { border-color: var(--pwl-ck-accent); }
.pwl-lead__choice:active { transform: scale(.98); }

.pwl-lead__choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pwl-lead__choice:has(input:checked) {
  border-color: var(--pwl-ck-accent);
  background: var(--pwl-ck-surface-2);
  box-shadow: inset 0 0 0 1px var(--pwl-ck-accent);
  font-weight: 650;
}

.pwl-lead__choice:has(input:focus-visible) {
  outline: 2px solid var(--pwl-ck-accent);
  outline-offset: 2px;
}

/* campos (paso 2) */
.pwl-lead__field { margin-bottom: 1.1rem; }

.pwl-lead__label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .02em;
  margin-bottom: .35rem;
  color: var(--pwl-ck-ink);
}

.pwl-lead__input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 1rem;
  color: var(--pwl-ck-ink);
  background: var(--pwl-ck-surface);
  border: 1px solid var(--pwl-ck-line);
  border-radius: calc(var(--pwl-ck-radius) - 4px);
  padding: .75rem .9rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.pwl-lead__input::placeholder { color: color-mix(in srgb, var(--pwl-ck-ink-soft) 60%, transparent); }

.pwl-lead__input:focus-visible {
  outline: none;
  border-color: var(--pwl-ck-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pwl-ck-accent) 22%, transparent);
}

.pwl-lead__field.is-invalid .pwl-lead__input {
  border-color: var(--pwl-ck-danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pwl-ck-danger) 18%, transparent);
}

.pwl-lead__error {
  display: none;
  margin-top: .35rem;
  font-size: .8125rem;
  color: var(--pwl-ck-danger);
}

.pwl-lead__field.is-invalid .pwl-lead__error { display: block; }

/* honeypot — fuera de la vista y del tab order, invisible para humanos */
.pwl-lead__hp {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* botones */
.pwl-lead__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: 1.5rem;
}

.pwl-btn {
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: .01em;
  border: 0;
  border-radius: var(--pwl-ck-radius-pill);
  padding: .8rem 1.6rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .2s var(--pwl-ck-ease), opacity .2s ease;
}

.pwl-btn:active { transform: scale(.97); }
.pwl-btn:focus-visible { outline: 2px solid var(--pwl-ck-accent); outline-offset: 3px; }
.pwl-btn[disabled] { opacity: .55; cursor: default; }

.pwl-btn--primary {
  background: var(--pwl-ck-ink);
  color: var(--pwl-ck-surface);
}

.pwl-btn--ghost {
  background: transparent;
  color: var(--pwl-ck-ink-soft);
  padding-inline: .9rem;
}

.pwl-btn--ghost:hover { color: var(--pwl-ck-ink); }

/* alerta de error de envío */
.pwl-lead__alert {
  display: none;
  margin-top: 1rem;
  padding: .75rem 1rem;
  border-radius: calc(var(--pwl-ck-radius) - 4px);
  background: color-mix(in srgb, var(--pwl-ck-danger) 10%, var(--pwl-ck-surface));
  border: 1px solid color-mix(in srgb, var(--pwl-ck-danger) 35%, var(--pwl-ck-line));
  color: var(--pwl-ck-danger);
  font-size: .875rem;
}

.pwl-lead.has-error .pwl-lead__alert { display: block; }

/* éxito */
.pwl-lead__success {
  text-align: center;
  padding: 1.5rem 0 .75rem;
}

.pwl-lead__success[hidden] { display: none; }

.pwl-lead__success-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--pwl-ck-ok) 12%, var(--pwl-ck-surface));
  color: var(--pwl-ck-ok);
}

.pwl-lead__success-badge svg { width: 30px; height: 30px; }

.pwl-lead__success.is-shown .pwl-lead__success-badge {
  animation: pwl-pop .55s var(--pwl-ck-ease) both;
}

@keyframes pwl-pop {
  0%   { opacity: 0; transform: scale(.6); }
  60%  { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   (c) BARRA CTA STICKY MOBILE — .pwl-ck-bar
   Solo <768px. JS agrega .is-visible tras el umbral de scroll.
   ============================================================ */

.pwl-ck-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: var(--pwl-ck-z-bar);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: .5rem;
  padding: .55rem calc(.75rem + env(safe-area-inset-right, 0px))
           calc(.55rem + env(safe-area-inset-bottom, 0px))
           calc(.75rem + env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--pwl-ck-surface) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--pwl-ck-line);
  transform: translateY(110%);
  transition: transform .5s var(--pwl-ck-ease);
}

.pwl-ck-bar.is-visible { transform: translateY(0); }

@media (min-width: 768px) {
  .pwl-ck-bar { display: none; }
}

.pwl-ck-bar__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: .35rem .5rem;
  border-radius: var(--pwl-ck-radius);
  text-decoration: none;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--pwl-ck-ink);
  -webkit-tap-highlight-color: transparent;
  transition: transform .2s var(--pwl-ck-ease), background-color .2s ease;
}

.pwl-ck-bar__btn:active { transform: scale(.96); }
.pwl-ck-bar__btn:focus-visible { outline: 2px solid var(--pwl-ck-accent); outline-offset: -2px; }
.pwl-ck-bar__btn svg { width: 20px; height: 20px; }

/* botón central protagonista (WhatsApp) */
.pwl-ck-bar__btn--main {
  flex-direction: row;
  gap: .5rem;
  padding: .35rem 1.15rem;
  font-size: .875rem;
  background: var(--pwl-ck-wa);
  color: #fff;
  border-radius: var(--pwl-ck-radius-pill);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--pwl-ck-wa) 40%, transparent);
}

/* ============================================================
   reduced-motion: todo visible, nada animado
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .pwl-wa,
  .pwl-wa__link,
  .pwl-wa__label,
  .pwl-ck-bar,
  .pwl-ck-bar__btn,
  .pwl-lead__progress-fill,
  .pwl-lead__choice,
  .pwl-btn,
  .pwl-lead__input {
    transition: none !important;
  }
  .pwl-wa.is-visible .pwl-wa__chip::after { animation: none; }
  .pwl-lead__success.is-shown .pwl-lead__success-badge { animation: none; }
}
