/**
 * WW Kit Finder Quiz Popup — Styles
 * All colours via CSS custom properties; zero external dependencies.
 *
 * @package WW_Quiz_Popup
 * @version 1.0.0
 */

/* ============================================================
   CSS CUSTOM PROPERTIES
   Reads from Astra's native vars; falls back to brand colours.
   ============================================================ */
:root {
  --ww-primary:    var(--ast-global-color-0, #1a3c5e);
  --ww-accent:     var(--ast-global-color-1, #e87722);
  --ww-bg:         #ffffff;
  --ww-text:       #333333;
  --ww-muted:      #666666;
  --ww-border:     #e0e0e0;
  --ww-overlay:    rgba(0, 0, 0, 0.6);
  --ww-radius:     12px;
  --ww-shadow:     0 20px 60px rgba(0, 0, 0, 0.2);
  --ww-transition: 0.3s ease;
  --ww-accent-tint: #fff8f4; /* fallback light tint for selected cards */
}

/* ============================================================
   OVERLAY
   ============================================================ */
.ww-quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--ww-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--ww-transition);
  /* JS sets display:none initially; flex is set when shown */
}

.ww-quiz-overlay.ww-popup-visible {
  opacity: 1;
}

/* ============================================================
   POPUP CARD
   ============================================================ */
.ww-quiz-card {
  position: relative;
  background: var(--ww-bg);
  border-radius: var(--ww-radius);
  box-shadow: var(--ww-shadow);
  max-width: 560px;
  width: 94%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform var(--ww-transition);
  outline: none; /* focus managed via JS */
  -webkit-overflow-scrolling: touch;
}

.ww-quiz-overlay.ww-popup-visible .ww-quiz-card {
  transform: scale(1);
}

/* Inner padding wrapper */
.ww-inner {
  padding: 36px 32px 28px;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.ww-progress-wrap {
  height: 4px;
  background: var(--ww-border);
  border-radius: var(--ww-radius) var(--ww-radius) 0 0;
  overflow: hidden;
  position: sticky;
  top: 0;
  z-index: 2;
}

.ww-progress-bar {
  height: 100%;
  background: var(--ww-accent);
  transition: width 0.4s ease;
  width: 0%;
}

/* ============================================================
   CLOSE BUTTON
   ============================================================ */
.ww-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ww-muted);
  transition: color var(--ww-transition), background var(--ww-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.ww-close-btn:hover,
.ww-close-btn:focus-visible {
  color: var(--ww-accent);
  background: rgba(232, 119, 34, 0.08);
  outline: none;
}

/* ============================================================
   BRANDING / HEADER (intro screen)
   ============================================================ */
.ww-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.ww-brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ww-primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ww-headline {
  font-size: 24px;
  font-weight: 700;
  color: var(--ww-primary);
  margin: 0 0 10px;
  line-height: 1.25;
}

.ww-subheadline {
  font-size: 15px;
  color: var(--ww-muted);
  margin: 0 0 24px;
  line-height: 1.55;
}

/* ============================================================
   STEP CONTAINERS
   ============================================================ */
.ww-step {
  animation: wwFadeIn 0.2s ease both;
}

@keyframes wwFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ww-question {
  font-size: 18px;
  font-weight: 600;
  color: var(--ww-primary);
  margin: 0 0 18px;
  line-height: 1.35;
}

/* ============================================================
   OPTION CARDS (radio replacement)
   ============================================================ */
.ww-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.ww-option-card {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--ww-border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ww-bg);
  transition:
    border-color var(--ww-transition),
    background var(--ww-transition);
  user-select: none;
  box-sizing: border-box;
}

.ww-option-card:hover {
  border-color: var(--ww-accent);
}

.ww-option-card:focus-visible {
  outline: 3px solid var(--ww-accent);
  outline-offset: 2px;
}

.ww-option-card.ww-selected {
  border-color: var(--ww-accent);
  background: var(--ww-accent-tint);
}

.ww-radio-dot {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ww-border);
  background: var(--ww-bg);
  transition:
    border-color var(--ww-transition),
    background var(--ww-transition);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ww-option-card.ww-selected .ww-radio-dot {
  border-color: var(--ww-accent);
  background: var(--ww-accent);
  box-shadow: inset 0 0 0 3px var(--ww-bg);
}

.ww-option-label {
  font-size: 15px;
  color: var(--ww-text);
  line-height: 1.45;
}

/* ============================================================
   BUTTONS — Primary (Next / Start / Submit)
   ============================================================ */
.ww-btn-primary {
  display: block;
  width: 100%;
  padding: 16px 20px;
  background: var(--ww-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    filter var(--ww-transition),
    opacity var(--ww-transition);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.ww-btn-primary:hover:not(:disabled),
.ww-btn-primary:focus-visible:not(:disabled) {
  filter: brightness(1.08);
  outline: none;
}

.ww-btn-primary:disabled,
.ww-btn-primary[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

/* Link styled as primary button */
a.ww-btn-primary,
a.ww-btn-link.ww-btn-primary {
  display: block;
}

/* ============================================================
   BUTTONS — Secondary (outline)
   ============================================================ */
.ww-btn-secondary {
  display: block;
  width: 100%;
  padding: 14px 20px;
  background: transparent;
  border: 2px solid var(--ww-primary);
  color: var(--ww-primary);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  margin-top: 10px;
  transition:
    background var(--ww-transition),
    color var(--ww-transition);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.ww-btn-secondary:hover,
.ww-btn-secondary:focus-visible {
  background: var(--ww-primary);
  color: #ffffff;
  outline: none;
}

/* ============================================================
   BACK BUTTON
   ============================================================ */
.ww-back-btn {
  display: block;
  background: none;
  border: none;
  color: var(--ww-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 10px 0 2px;
  text-decoration: underline;
  width: auto;
  margin-top: 4px;
  transition: color var(--ww-transition);
}

.ww-back-btn:hover,
.ww-back-btn:focus-visible {
  color: var(--ww-primary);
  outline: none;
}

/* ============================================================
   EMAIL STEP — Fields
   ============================================================ */
.ww-step5-intro {
  font-size: 14px;
  color: var(--ww-muted);
  margin: -8px 0 20px;
  line-height: 1.5;
}

.ww-field-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.ww-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ww-text);
  margin-bottom: 6px;
}

.ww-text-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--ww-border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--ww-text);
  background: var(--ww-bg);
  transition:
    border-color var(--ww-transition),
    box-shadow var(--ww-transition);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.ww-text-input:focus {
  border-color: var(--ww-accent);
  box-shadow: 0 0 0 3px rgba(232, 119, 34, 0.15);
  outline: none;
}

.ww-text-input.ww-input-error {
  border-color: #c0392b;
}

.ww-inline-error {
  font-size: 13px;
  color: #c0392b;
  margin-top: 5px;
  min-height: 1em;
  display: block;
}

/* Checkbox row */
.ww-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  cursor: pointer;
}

.ww-checkbox {
  flex-shrink: 0;
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--ww-accent);
  cursor: pointer;
}

.ww-checkbox-label {
  font-size: 13px;
  color: var(--ww-muted);
  line-height: 1.5;
}

/* Submit button — inherits .ww-btn-primary; always enabled on this step */
.ww-btn-submit {
  margin-top: 4px;
}

/* Spinner inside submit button while fetching */
.ww-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: wwSpin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes wwSpin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   RESULTS SCREEN
   ============================================================ */
.ww-results-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ww-muted);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ww-results-headline {
  font-size: 22px;
  font-weight: 700;
  color: var(--ww-primary);
  margin: 0 0 12px;
  line-height: 1.3;
}

.ww-results-description {
  font-size: 15px;
  color: var(--ww-text);
  line-height: 1.6;
  margin: 0 0 22px;
}

.ww-results-ctas {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 6px;
}

/* ============================================================
   REVIEW BLOCK
   ============================================================ */
.ww-review-block {
  border-left: 4px solid var(--ww-border);
  padding-left: 16px;
  margin: 20px 0;
}

.ww-review-quote {
  font-style: italic;
  color: var(--ww-muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 6px;
}

.ww-review-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--ww-text);
  margin: 0;
}

/* ============================================================
   TRUST LINE
   ============================================================ */
.ww-trust-line {
  font-size: 13px;
  color: var(--ww-muted);
  text-align: center;
  margin-top: 16px;
  line-height: 1.55;
}

.ww-trust-phone,
.ww-trust-wa {
  color: var(--ww-accent);
  text-decoration: underline;
  font-weight: 600;
}

.ww-trust-phone:hover,
.ww-trust-wa:hover {
  color: var(--ww-primary);
}

/* ============================================================
   RESULTS FOOTER — close text link
   ============================================================ */
.ww-results-footer {
  text-align: center;
  margin-top: 20px;
}

.ww-text-close {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--ww-muted);
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
  transition: color var(--ww-transition);
}

.ww-text-close:hover {
  color: var(--ww-primary);
}

/* ============================================================
   MOBILE BREAKPOINT — 480px and below
   ============================================================ */
@media (max-width: 480px) {
  .ww-quiz-card {
    width: 98%;
    max-height: 100svh;   /* svh = small viewport height, avoids mobile browser chrome */
    max-height: 100vh;    /* fallback for browsers without svh */
    border-radius: 8px;
  }

  .ww-inner {
    padding: 24px 18px 20px;
  }

  .ww-headline {
    font-size: 20px;
  }

  .ww-question {
    font-size: 16px;
  }

  .ww-btn-primary {
    font-size: 15px;
    padding: 14px 16px;
    min-height: 48px;
  }

  .ww-btn-secondary {
    font-size: 14px;
    padding: 12px 16px;
    min-height: 48px;
  }

  .ww-option-card {
    padding: 12px 14px;
  }

  .ww-option-label {
    font-size: 14px;
  }

  .ww-results-headline {
    font-size: 19px;
  }

  .ww-close-btn {
    /* Ensure tap target remains 44x44 */
    width: 44px;
    height: 44px;
  }
}

/* Extra small phones */
@media (max-width: 360px) {
  .ww-inner {
    padding: 20px 14px 16px;
  }
}
