/* ============================================================
   Medspa Lead Magnet Widget
   ------------------------------------------------------------
   A self-contained, embeddable treatment-match assessment.
   All styles are scoped under .msw-root to avoid host-page collisions.

   Customize: override CSS variables on .msw-root (or via
   MedspaWidget.config.theme — see medspa-widget.js).
   ============================================================ */

.msw-root {
  /* Theme tokens — override via JS config.theme or inline style */
  --msw-bg: #ffffff;
  --msw-surface: #fafaf7;
  --msw-surface-2: #f4f1ec;
  --msw-ink: #1a1814;
  --msw-ink-soft: #5a554d;
  --msw-muted: #8a857c;
  --msw-line: #e6e1d8;
  --msw-accent: #b08a5b;        /* warm bronze — medspa luxe */
  --msw-accent-ink: #ffffff;
  --msw-accent-soft: #f3ead9;
  --msw-success: #6b8e6f;
  --msw-danger: #b04a3f;

  --msw-radius-sm: 8px;
  --msw-radius: 14px;
  --msw-radius-lg: 22px;

  --msw-shadow: 0 1px 2px rgba(26, 24, 20, .04), 0 8px 30px rgba(26, 24, 20, .06);
  --msw-shadow-lg: 0 2px 4px rgba(26, 24, 20, .04), 0 24px 60px rgba(26, 24, 20, .12);

  --msw-font-display: "Cormorant Garamond", "Playfair Display", Georgia, "Times New Roman", serif;
  --msw-font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Container */
  font-family: var(--msw-font-body);
  color: var(--msw-ink);
  background: var(--msw-bg);
  border: 1px solid var(--msw-line);
  border-radius: var(--msw-radius-lg);
  box-shadow: var(--msw-shadow);
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  box-sizing: border-box;
  line-height: 1.5;
}

.msw-root *,
.msw-root *::before,
.msw-root *::after {
  box-sizing: border-box;
}

/* ---------- Header ---------- */
.msw-header {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--msw-line);
  background: var(--msw-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.msw-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.msw-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--msw-accent);
  color: var(--msw-accent-ink);
  display: grid;
  place-items: center;
  font-family: var(--msw-font-display);
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

.msw-brand-text {
  min-width: 0;
}

.msw-brand-name {
  font-family: var(--msw-font-display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--msw-ink);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msw-brand-tag {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--msw-muted);
  margin-top: 2px;
}

.msw-progress {
  flex: 1;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.msw-progress-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--msw-muted);
}

.msw-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--msw-surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.msw-progress-fill {
  height: 100%;
  background: var(--msw-accent);
  width: 0%;
  transition: width 320ms cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Body ---------- */
.msw-body {
  padding: 32px 28px 28px;
}

.msw-step {
  display: none;
  animation: mswFade 280ms ease both;
}

.msw-step.is-active {
  display: block;
}

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

.msw-eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--msw-accent);
  font-weight: 600;
  margin-bottom: 10px;
}

/* Optional page-specific intro — rendered on step 1 when config.intro is set */
.msw-intro {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--msw-ink-soft);
  background: var(--msw-surface);
  border: 1px solid var(--msw-line);
  border-radius: var(--msw-radius);
  padding: 12px 14px;
  margin: 0 0 22px;
}

.msw-question {
  font-family: var(--msw-font-display);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 500;
  color: var(--msw-ink);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.msw-help {
  font-size: 14px;
  color: var(--msw-ink-soft);
  margin: 0 0 22px;
}

/* ---------- Options ---------- */
.msw-options {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.msw-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--msw-bg);
  border: 1px solid var(--msw-line);
  border-radius: var(--msw-radius);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.msw-option:hover {
  border-color: var(--msw-accent);
  background: var(--msw-surface);
}

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

.msw-option.is-selected {
  border-color: var(--msw-accent);
  background: var(--msw-accent-soft);
}

.msw-option-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--msw-line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: border-color 160ms ease, background 160ms ease;
}

.msw-option.is-selected .msw-option-check {
  border-color: var(--msw-accent);
  background: var(--msw-accent);
}

.msw-option.is-selected .msw-option-check::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--msw-accent-ink);
}

.msw-option-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.35;
}

.msw-option-text small {
  display: block;
  font-size: 12px;
  color: var(--msw-muted);
  margin-top: 2px;
}

/* Multi-select chips for skin concerns */
.msw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.msw-chip {
  padding: 9px 14px;
  border: 1px solid var(--msw-line);
  border-radius: 999px;
  background: var(--msw-bg);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--msw-ink-soft);
  transition: all 160ms ease;
}

.msw-chip:hover {
  border-color: var(--msw-accent);
  color: var(--msw-ink);
}

.msw-chip.is-selected {
  background: var(--msw-accent);
  border-color: var(--msw-accent);
  color: var(--msw-accent-ink);
}

/* ---------- Form fields (lead capture) ---------- */
.msw-fields {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.msw-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msw-label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--msw-ink-soft);
  font-weight: 600;
}

.msw-input {
  font: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--msw-line);
  border-radius: var(--msw-radius);
  background: var(--msw-bg);
  color: var(--msw-ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  width: 100%;
}

.msw-input:focus {
  outline: none;
  border-color: var(--msw-accent);
  box-shadow: 0 0 0 3px var(--msw-accent-soft);
}

.msw-input.is-error {
  border-color: var(--msw-danger);
}

.msw-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--msw-ink-soft);
  line-height: 1.45;
}

.msw-checkbox-row input {
  margin-top: 2px;
  accent-color: var(--msw-accent);
}

.msw-error {
  color: var(--msw-danger);
  font-size: 12px;
  margin-top: 4px;
}

/* ---------- Buttons / nav ---------- */
.msw-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.msw-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
  letter-spacing: 0.01em;
}

.msw-btn:focus-visible {
  outline: 2px solid var(--msw-accent);
  outline-offset: 2px;
}

.msw-btn-primary {
  background: var(--msw-ink);
  color: var(--msw-bg);
}

.msw-btn-primary:hover {
  background: var(--msw-accent);
}

.msw-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.msw-btn-ghost {
  background: transparent;
  color: var(--msw-ink-soft);
  border-color: transparent;
  padding: 12px 14px;
}

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

.msw-btn-cta {
  background: var(--msw-accent);
  color: var(--msw-accent-ink);
  font-size: 15px;
  padding: 14px 26px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.msw-btn-cta:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

/* ---------- Result ---------- */
.msw-result-hero {
  text-align: center;
  padding: 8px 0 22px;
  border-bottom: 1px solid var(--msw-line);
  margin-bottom: 22px;
}

.msw-result-eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--msw-accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.msw-result-title {
  font-family: var(--msw-font-display);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.1;
  color: var(--msw-ink);
  margin: 0 0 10px;
  letter-spacing: -0.015em;
}

.msw-result-summary {
  font-size: 15px;
  color: var(--msw-ink-soft);
  max-width: 480px;
  margin: 0 auto 18px;
}

.msw-fitscore {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--msw-surface);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--msw-ink);
}

.msw-fitscore-bar {
  width: 100px;
  height: 6px;
  background: var(--msw-surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.msw-fitscore-fill {
  height: 100%;
  background: var(--msw-accent);
  border-radius: 999px;
}

.msw-fitscore-num {
  font-weight: 700;
  color: var(--msw-accent);
}

.msw-result-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.msw-result-detail {
  border: 1px solid var(--msw-line);
  border-radius: var(--msw-radius);
  padding: 14px;
  background: var(--msw-surface);
}

.msw-result-detail-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--msw-accent);
  font-weight: 700;
  margin-bottom: 5px;
}

.msw-result-detail-value {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--msw-ink-soft);
  margin: 0;
}

.msw-treatments {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.msw-treatment {
  border: 1px solid var(--msw-line);
  border-radius: var(--msw-radius);
  padding: 16px 18px;
  background: var(--msw-surface);
}

.msw-treatment.is-primary {
  background: var(--msw-bg);
  border-color: var(--msw-accent);
  box-shadow: 0 0 0 1px var(--msw-accent) inset;
}

.msw-treatment-rank {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--msw-muted);
  margin-bottom: 4px;
}

.msw-treatment.is-primary .msw-treatment-rank {
  color: var(--msw-accent);
}

.msw-treatment-name {
  font-family: var(--msw-font-display);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--msw-ink);
}

.msw-treatment-desc {
  font-size: 14px;
  color: var(--msw-ink-soft);
  margin: 0;
}

.msw-urgency {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--msw-accent-soft);
  border-radius: var(--msw-radius);
  font-size: 13px;
  color: var(--msw-ink);
  margin-bottom: 22px;
}

.msw-urgency::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--msw-accent);
  flex-shrink: 0;
  animation: mswPulse 1.8s ease-in-out infinite;
}

@keyframes mswPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

.msw-cta-row {
  text-align: center;
  margin-bottom: 18px;
}

.msw-cta-sub {
  font-size: 12px;
  color: var(--msw-muted);
  margin-top: 10px;
}

/* ---------- Disclaimer / footer ---------- */
.msw-disclaimer {
  font-size: 11px;
  color: var(--msw-muted);
  line-height: 1.5;
  padding: 14px 28px;
  background: var(--msw-surface);
  border-top: 1px solid var(--msw-line);
  text-align: center;
}

.msw-restart {
  background: none;
  border: none;
  font: inherit;
  color: var(--msw-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
}

.msw-restart:hover {
  color: var(--msw-ink);
}

/* ---------- Mobile ---------- */
@media (max-width: 540px) {
  .msw-root {
    border-radius: var(--msw-radius);
  }
  .msw-header {
    padding: 16px 18px 14px;
    flex-wrap: wrap;
  }
  .msw-progress {
    max-width: 100%;
    align-items: flex-start;
  }
  .msw-body {
    padding: 24px 18px 22px;
  }
  .msw-question {
    font-size: 22px;
  }
  .msw-result-title {
    font-size: 26px;
  }
  .msw-result-details {
    grid-template-columns: 1fr;
  }
  .msw-disclaimer {
    padding: 12px 18px;
  }
  .msw-actions {
    flex-direction: row-reverse;
    justify-content: space-between;
  }
  .msw-btn-primary {
    flex: 1;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .msw-step,
  .msw-progress-fill,
  .msw-option,
  .msw-btn,
  .msw-urgency::before {
    animation: none !important;
    transition: none !important;
  }
}
