/**
 * SolarPlus Funnel — Frontend Stylesheet
 * Based on SolarPlus brand style guide
 *
 * CSS Variables (set dynamically from plugin settings):
 * --spf-color-primary     CTA + selected states
 * --spf-color-card-border Selected card border
 * --spf-color-progress    Active progress dot
 * --spf-color-bg          Background
 * --spf-font-size         Body font size
 */

/* ========================================================
 * RESET
 * ======================================================== */
.spf-funnel,
.spf-funnel * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ========================================================
 * CONTAINER
 * ======================================================== */
.spf-funnel {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--spf-font-size, 15px);
  color: #1A1A1A;
  background: var(--spf-color-bg, #FFFFFF);
  max-width: 600px;
  margin: 0 auto;
  overflow: visible;
  position: relative;
}

/* ========================================================
 * SLIDER TRACK — horizontal slide
 * ======================================================== */
.spf-slider {
  overflow: hidden;
  position: relative;
  margin: 0 -2px;
  padding: 0 2px;
}

.spf-track {
  display: flex;
  transition: transform 0.35s ease;
  will-change: transform;
  align-items: stretch;
}

.spf-step {
  width: 100%;
  min-width: 100%;
  flex: 0 0 100%;
  flex-shrink: 0;
  padding: clamp(24px, 5vw, 40px) clamp(16px, 4vw, 36px);
}

/* ========================================================
 * PROGRESS DOTS
 * ======================================================== */
.spf-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 24px 0 0;
}

.spf-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E0E0E0;
  transition: background 0.25s ease;
}

.spf-dot-active {
  background: var(--spf-color-progress, #FF3B30);
}

/* ========================================================
 * TYPOGRAPHY
 * ======================================================== */
.spf-heading {
  font-family: 'Manrope', sans-serif;
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 800;
  color: #1A1A1A;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 24px;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.spf-subheading {
  font-size: 14px;
  color: #6B7280;
  text-align: center;
  line-height: 1.6;
  margin-bottom: 24px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ========================================================
 * CARDS — selection UI
 * ======================================================== */
.spf-card-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
  padding: 2px;
}

.spf-card-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.spf-card-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.spf-card {
  background: #FFFFFF;
  border: 1.5px solid #E0E0E0;
  border-radius: 8px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  min-width: 0;
}

.spf-card:hover {
  border-color: #9CA3AF;
}

.spf-card.selected {
  border-color: var(--spf-color-card-border, #FF3B30);
  background: #FFF5F5;
}

.spf-branch-card {
  padding: 28px 20px;
}

.spf-card-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.spf-card-label {
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #1A1A1A;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.spf-card-sub {
  font-size: 13px;
  color: #6B7280;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ========================================================
 * FORM FIELDS
 * ======================================================== */
.spf-field {
  margin-bottom: 20px;
}

.spf-label {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #1A1A1A;
  margin-bottom: 6px;
  display: block;
}

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

.spf-has-prefix .spf-input {
  padding-left: 40px;
}

.spf-has-suffix .spf-input {
  padding-right: 52px;
}

.spf-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 500;
  color: #6B7280;
  pointer-events: none;
}

.spf-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 500;
  color: #6B7280;
  pointer-events: none;
}

.spf-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #1A1A1A;
  background: #FFFFFF;
  outline: none;
  transition: border-color 0.2s ease;
  -moz-appearance: textfield;
}

.spf-input::-webkit-outer-spin-button,
.spf-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.spf-input:focus {
  border-color: #1A1A1A;
}

.spf-hint {
  font-size: 12px;
  color: #9CA3AF;
  margin-top: 6px;
}

.spf-error {
  font-size: 12px;
  color: #FF3B30;
  margin-top: 5px;
  display: none;
}

/* ========================================================
 * NAVIGATION — Back + Next
 * ======================================================== */
.spf-nav {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.spf-back-btn {
  flex: 0 0 auto;
  padding: 14px 20px;
  background: transparent;
  border: 1px solid #E0E0E0;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #6B7280;
  cursor: pointer;
  transition: all 0.2s ease;
}

.spf-back-btn:hover {
  background: #F5F5F5;
  color: #1A1A1A;
}

.spf-next-btn {
  flex: 1;
  padding: 14px 24px;
  background: var(--spf-color-primary, #FF3B30);
  border: none;
  border-radius: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #FFFFFF;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.spf-next-btn:hover {
  background: #E0352B;
}

.spf-next-btn:disabled {
  background: #F5F5F5;
  color: #9CA3AF;
  cursor: not-allowed;
}

/* ========================================================
 * RESULT SCREEN
 * ======================================================== */
.spf-result-step {
  text-align: center;
}

.spf-result-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.spf-result-card {
  background: #F5F5F5;
  border-radius: 8px;
  padding: 20px 16px;
  min-width: 0;
}

.spf-result-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6B7280;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.spf-result-value {
  font-family: 'Manrope', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: #1A1A1A;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.spf-accent {
  color: #FF7A00;
}

.spf-trust {
  font-size: 12px;
  color: #6B7280;
  line-height: 1.65;
  padding: 14px 16px;
  background: #F5F5F5;
  border-radius: 8px;
  border-left: 3px solid #E0E0E0;
  margin-bottom: 20px;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.spf-cta-prompt {
  font-family: 'Manrope', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #1A1A1A;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.spf-result-actions {
  margin-top: 20px;
}

.spf-result-btn {
  width: 100%;
  padding: 16px 24px;
  background: var(--spf-color-primary, #FF3B30);
  border: none;
  border-radius: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #FFFFFF;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.spf-result-btn:hover {
  background: #E0352B;
}

.spf-form-nav {
  margin-top: 0;
  margin-bottom: 20px;
}

/* ========================================================
 * LEAD FORM
 * ======================================================== */
.spf-form-step {
  padding-top: 0;
}

.spf-consent {
  font-size: 11px;
  color: #6B7280;
  line-height: 1.65;
  margin-bottom: 16px;
}

.spf-submit-btn {
  width: 100%;
  padding: 16px 24px;
  background: var(--spf-color-primary, #FF3B30);
  border: none;
  border-radius: 8px;
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #FFFFFF;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.spf-submit-btn:hover {
  background: #E0352B;
}

.spf-submit-btn:disabled {
  background: #F5F5F5;
  color: #9CA3AF;
  cursor: not-allowed;
}

.spf-submit-error {
  font-size: 12px;
  color: #FF3B30;
  text-align: center;
  margin-bottom: 12px;
  display: none;
}

/* ========================================================
 * FLUID SCALING — applies at all sizes
 * Heading and step padding scale smoothly using clamp()
 * instead of jumping at fixed breakpoints
 * ======================================================== */
.spf-heading {
  font-size: clamp(20px, 4vw, 24px);
}

.spf-step {
  padding: clamp(24px, 5vw, 40px) clamp(16px, 4vw, 36px);
}

/* ========================================================
 * RESPONSIVE — content-first breakpoints
 *
 * Breakpoints are based on when the layout starts to feel
 * crowded or too empty — not on device labels.
 *
 * 720px+       Desktop — funnel max-width 600px, centered
 * 600–719px    Funnel fills viewport — add side breathing room
 * 480–599px    3-col cards start feeling crowded — use 2-col
 * 400–479px    Branch cards still comfortable side by side
 * 360–399px    Everything collapses to single column
 * ======================================================== */

/* ── 600–719px ─────────────────────────────────────────
   Funnel fills full viewport width at this range.
   Add horizontal padding so content never touches edges.
   ──────────────────────────────────────────────────── */
@media (max-width: 719px) {
  .spf-funnel {
    padding: 0 16px;
  }

  /* Compensate slider margin for added funnel padding */
  .spf-slider {
    margin: 0 -14px;
    padding: 0 14px;
  }
}

/* ── 480–599px ─────────────────────────────────────────
   3-column cards start feeling crowded below 480px.
   Collapse 3-col to 2-col. Keep 2-col and branch cards.
   Result cards always stay 2-col — enough space.
   Progress dots slightly smaller — less visual weight.
   ──────────────────────────────────────────────────── */
@media (max-width: 599px) {

  /* 3-col → 2-col (timeline, property type) */
  .spf-card-grid-3 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* 2-col stays 2-col (meter type, branch) */
  .spf-card-grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  /* Card padding tighter */
  .spf-card {
    padding: 16px 12px;
  }

  .spf-branch-card {
    padding: 20px 12px;
  }

  /* Card label slightly smaller */
  .spf-card-label {
    font-size: 14px;
  }

  /* Result cards stay 2-col — comfortable at this size */
  .spf-result-cards {
    grid-template-columns: 1fr 1fr;
  }

  .spf-result-value {
    font-size: clamp(20px, 5vw, 24px);
  }

  /* Progress dots — slightly smaller */
  .spf-progress {
    padding: 16px 0 0;
    gap: 8px;
  }

  .spf-dot {
    width: 8px;
    height: 8px;
  }

  /* Navigation — tighter gap */
  .spf-nav {
    gap: 8px;
  }

  .spf-back-btn {
    padding: 12px 16px;
    font-size: 13px;
  }

  .spf-next-btn {
    padding: 12px 20px;
    font-size: 14px;
  }
}

/* ── 360–479px ─────────────────────────────────────────
   Below 480px, 2-col cards start getting tight.
   Collapse everything to single column.
   Branch cards (Step 0) stay side by side until 360px
   since they only need ~150px each minimum.
   ──────────────────────────────────────────────────── */
@media (max-width: 479px) {

  /* 3-col → single column */
  .spf-card-grid-3 {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Branch cards (Step 0) — stay side by side */
  .spf-card-grid-2:not(.spf-branch-grid) {
    grid-template-columns: 1fr 1fr;
  }

  /* Meter type (2 cards) — stays 2-col, only 2 options */
  .spf-card-grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  /* Result cards — stay 2-col always */
  .spf-result-cards {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Below 360px ────────────────────────────────────────
   At 360px and below, even 2-col branch cards feel tight.
   Collapse branch cards to single column.
   Everything single column at this size.
   ──────────────────────────────────────────────────── */
@media (max-width: 359px) {

  /* Branch cards stack */
  .spf-card-grid-2 {
    grid-template-columns: 1fr;
  }

  /* Meter type also stacks */
  .spf-card-grid-2 {
    grid-template-columns: 1fr;
  }

  /* Result cards — only at very small sizes do they stack */
  .spf-result-cards {
    grid-template-columns: 1fr;
  }

  .spf-result-value {
    font-size: 20px;
  }

  /* Card label */
  .spf-card-label {
    font-size: 13px;
  }
}
