/* =============================================================================
 * Fling Quiz Funnel — styles
 * All funnel-specific color comes from CSS variables set by the engine from
 * brand.colors. Reskinning a funnel is JSON-only. Mobile-first (390px).
 * ========================================================================== */

:root {
  /* defaults; overridden per-funnel by engine.applyBrand() */
  --bg: #faf3ec;
  --primary: #004643;
  --accent: #1f7a5c;        /* emerald — CTAs, badges, progress, accents */
  --gauge: #c9543a;         /* warm terracotta — the concern meter only */
  --text: #121212;
  --deep-accent: #004643;

  --card: #ffffff;
  --muted: #6b7280;
  --line: #e7ddd2;
  --success: #16a34a;

  /* calm selection / hover / focus highlight (brand forest green, distinct from the red CTA) */
  --select: #004643;
  --select-soft: #eef2f0;

  --radius: 14px;
  --radius-lg: 20px;
  --pill: 999px;
  --maxw: 480px;

  --shadow: 0 2px 10px rgba(30, 24, 16, 0.06);
  --shadow-lg: 0 10px 30px rgba(30, 24, 16, 0.12);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-head: "Fraunces", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.45;
}

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 20px 40px;
  position: relative;
}

/* screen transition */
.screen-in { animation: fadein 220ms ease both; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- top bar ------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  height: 56px;
  margin-bottom: 6px;
}
.topbar-center { flex: 1; text-align: center; }
.topbar--q .topbar-center { font-family: var(--mono); font-size: 13px; color: var(--muted); letter-spacing: 0.04em; }
.topbar-spacer { width: 40px; }
.back {
  width: 40px; height: 40px;
  border: none; background: transparent;
  font-size: 22px; color: var(--text);
  cursor: pointer; border-radius: var(--pill);
}
.back:active { background: rgba(0,0,0,0.05); }

.logo { height: 26px; object-fit: contain; }
.logo--text {
  font-weight: 800; font-size: 22px; letter-spacing: -0.02em;
  color: var(--primary);
}

/* ---- progress bar -------------------------------------------------------- */
.progress {
  height: 4px; width: 100%;
  background: var(--line);
  border-radius: var(--pill);
  overflow: hidden;
  margin-bottom: 28px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--pill);
  transition: width 300ms ease;
}

/* ---- intro --------------------------------------------------------------- */
.intro { text-align: center; padding-top: 8px; }
.intro-hero {
  width: 100%; max-width: 320px; margin: 8px auto 20px;
  border-radius: var(--radius-lg);
  display: block;
}
.intro-headline {
  font-family: var(--font-head);
  font-size: 30px; line-height: 1.12; font-weight: 600;
  letter-spacing: -0.01em; margin: 8px 0 12px;
}
.intro-subhead { font-size: 16px; color: var(--muted); margin: 0 auto 20px; max-width: 380px; }
.intro-trust {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 30px; padding: 7px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--pill);
  box-shadow: var(--shadow);
}
.trust-stars { color: #f5a623; letter-spacing: 1px; font-size: 14px; }
.trust-label { font-family: var(--mono); font-size: 12.5px; color: var(--text); font-weight: 500; }
.gate-prompt { font-weight: 600; font-size: 15px; margin: 0 0 14px; }
.gate-cards { display: flex; gap: 12px; }
.gate-card {
  flex: 1;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 120ms ease, border-color 120ms ease, background 150ms ease, box-shadow 120ms ease;
  box-shadow: var(--shadow);
}
.gate-card:active { transform: scale(0.97); }
.gate-card:hover, .gate-card.selected {
  border-color: var(--select); background: var(--select-soft); box-shadow: var(--shadow-lg);
}
.gate-emoji { font-size: 42px; line-height: 1; }
.gate-label { font-weight: 600; font-size: 16px; }

/* ---- questions ----------------------------------------------------------- */
.q-image { width: 100%; border-radius: var(--radius); margin-bottom: 18px; }
.q-headline {
  font-family: var(--font-head);
  font-size: 25px; line-height: 1.2; font-weight: 600;
  letter-spacing: -0.005em; margin: 0 0 8px;
}
.q-subtext { color: var(--muted); margin: 0 0 20px; }
.answers { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.answer {
  min-height: 60px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: left;
  font-size: 16px; font-weight: 500;
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center;
  transition: transform 100ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
  box-shadow: var(--shadow);
}
.answer:hover { border-color: var(--select); }
.answer:active { transform: scale(0.99); }
.answer.selected {
  background: var(--select-soft);
  border-color: var(--select);
  color: var(--text);
  font-weight: 600;
}

/* ---- input question ------------------------------------------------------ */
.input-wrap { margin-top: 22px; display: flex; flex-direction: column; gap: 16px; }
.text-input {
  width: 100%;
  font-size: 18px;
  font-family: var(--font);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
}
.text-input:focus { outline: none; border-color: var(--select); box-shadow: 0 0 0 3px rgba(0,70,67,0.12); }

/* ---- primary button ------------------------------------------------------ */
.btn-primary {
  width: 100%;
  min-height: 56px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--pill);
  font-size: 17px; font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 100ms ease, filter 150ms ease;
}
.btn-primary:active { transform: scale(0.99); }
.btn-primary:hover { filter: brightness(1.05); }

/* ---- loader -------------------------------------------------------------- */
.loader { text-align: center; padding-top: 60px; display: flex; flex-direction: column; align-items: center; }
.loader-ring { position: relative; width: 160px; height: 160px; margin-bottom: 32px; }
.loader-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 120ms linear; }
.loader-pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 800; font-family: var(--mono);
}
.loader-steps { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 340px; text-align: left; }
.loader-step {
  padding: 12px 0 12px 32px;
  position: relative;
  color: var(--muted);
  font-size: 15px;
  opacity: 0.45;
  transition: opacity 250ms ease, color 250ms ease;
}
.loader-step::before {
  content: "○";
  position: absolute; left: 4px; top: 11px;
  color: var(--muted);
}
.loader-step.active { opacity: 1; color: var(--text); }
.loader-step.done { opacity: 1; color: var(--text); }
.loader-step.done::before { content: "✓"; color: var(--success); font-weight: 700; }

/* ---- results ------------------------------------------------------------- */
.results { padding-bottom: 90px; }
.res-header { text-align: center; margin-bottom: 22px; padding-top: 2px; }
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.03em;
  color: var(--muted); text-transform: none; margin: 0 0 10px;
}
.res-headline {
  font-family: var(--font-head);
  font-size: 28px; line-height: 1.14; font-weight: 600;
  letter-spacing: -0.01em; margin: 0 0 18px;
}
.hero-cta { margin-top: 22px; }

.gauge { margin: 0 auto; max-width: 380px; }
.gauge-track {
  position: relative; height: 10px; border-radius: var(--pill);
  background: linear-gradient(90deg, #f1c40f33, #e67e2233, var(--gauge));
  border: 1px solid var(--line);
}
.gauge-fill { display: none; }
.gauge-marker {
  position: absolute; top: 50%; width: 18px; height: 18px;
  background: #fff; border: 3px solid var(--gauge); border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow);
}
.gauge-meta { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-top: 14px; }
.gauge-score { font-size: 30px; font-weight: 800; font-family: var(--mono); color: var(--gauge); }
.gauge-zone { font-size: 14px; font-weight: 600; color: var(--text); }

.res-summary { margin: 32px 0; }
.res-summary h2, .res-how h2, .res-testimonials h2, .res-offer h2, .faq h2 {
  font-family: var(--font-head);
  font-size: 21px; font-weight: 600; margin: 0 0 16px; letter-spacing: -0.005em;
}
.summary-cards { display: flex; flex-direction: column; gap: 10px; }
.summary-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start;
  box-shadow: var(--shadow);
}
.summary-card .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  margin-top: 7px; flex: 0 0 auto;
}
.summary-card p { margin: 0; font-size: 15px; }

/* mechanism — the "why you still feel this way" turning point */
.res-mechanism { margin: 36px 0; }
.mech-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow);
}
.mech-eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 8px;
}
.mech-headline {
  font-family: var(--font-head); font-size: 23px; line-height: 1.2;
  font-weight: 600; letter-spacing: -0.005em; margin: 0 0 14px;
}
.mech-img {
  width: 100%; border-radius: var(--radius); margin: 4px 0 16px;
  background: #faf4ec;
}
.mech-body { font-size: 15.5px; line-height: 1.55; margin: 0 0 18px; }
.mech-points { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 12px; }
.mech-point { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; font-weight: 500; }
.mech-num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--accent); font-family: var(--mono); font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.mech-transition {
  margin: 0; font-weight: 600; font-size: 16px; line-height: 1.4;
  color: var(--text); padding-top: 16px; border-top: 1px solid var(--line);
}
.mech-cta { margin-top: 18px; }

.res-product {
  margin: 36px 0; padding: 24px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  text-align: center; box-shadow: var(--shadow);
}
.product-img { width: 100%; max-width: 100%; border-radius: var(--radius); margin: 0 auto 16px; display: block; }
.product-eyebrow { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.product-name { font-family: var(--font-head); font-size: 26px; font-weight: 600; margin: 0 0 16px; }
.benefits { list-style: none; padding: 0; margin: 0; text-align: left; max-width: 320px; margin: 0 auto; }
.benefits li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; font-size: 15px; }
.benefits .check { color: var(--success); font-weight: 800; }

.res-how { margin: 36px 0; }
.how-img { width: 100%; border-radius: var(--radius); margin-bottom: 18px; }
.how-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.how-step { display: flex; gap: 14px; align-items: flex-start; }
.how-num {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.how-step h3 { font-size: 16px; margin: 2px 0 4px; }
.how-step p { margin: 0; color: var(--muted); font-size: 14.5px; }

.res-testimonials { margin: 36px 0; }
.life-img { width: 100%; border-radius: var(--radius); margin-bottom: 18px; }
.t-cards { display: flex; flex-direction: column; gap: 12px; }
.t-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.t-stars { color: #f5a623; letter-spacing: 2px; font-size: 15px; }
.t-text { margin: 8px 0 6px; font-size: 15px; }
.t-name { margin: 0; font-size: 13.5px; color: var(--muted); font-weight: 600; }

.res-offer { margin: 40px 0 24px; }
.res-offer h2 { text-align: center; }
.pkg-cards { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.pkg-card {
  position: relative; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 14px; cursor: pointer; font-family: var(--font);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.pkg-card.highlighted { border-color: var(--select); box-shadow: 0 0 0 3px rgba(0,70,67,0.12); }
.pkg-badge {
  position: absolute; top: -11px; left: 18px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: var(--pill); letter-spacing: 0.02em;
}
.pkg-top { display: flex; justify-content: space-between; align-items: center; }
.pkg-label { font-weight: 700; font-size: 16px; }
.pkg-save { font-size: 12px; font-weight: 700; color: var(--success); }
.pkg-price { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.pkg-now { font-size: 22px; font-weight: 800; }
.pkg-compare { color: var(--muted); text-decoration: line-through; font-size: 15px; }
.pkg-unit { font-size: 13px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }

.res-guarantee { margin: 28px 0; }
.guarantee-badge {
  background: #fff; border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 14px 16px; font-size: 14px; font-weight: 600; text-align: center; margin-bottom: 24px;
}
.faq { margin: 8px 0 24px; }
.faq details {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 16px; margin-bottom: 10px; overflow: hidden;
}
.faq summary {
  list-style: none; cursor: pointer; padding: 15px 0; font-weight: 600; font-size: 15px;
  position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 2px; color: var(--accent); font-size: 20px; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 16px; color: var(--muted); font-size: 14.5px; }

.res-footer { margin-top: 32px; text-align: center; }
.disclaimer { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }
.copyright { font-size: 12px; color: var(--muted); }

/* sticky CTA */
.sticky-cta {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: rgba(250,243,236,0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  max-width: var(--maxw); margin: 0 auto;
  z-index: 50;
}

/* ---- fatal / validation -------------------------------------------------- */
.fatal { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.fatal-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow); }
.fatal-card h1 { font-size: 20px; margin: 0 0 10px; }
.fatal-card ul { margin: 12px 0 0; padding-left: 18px; }
.fatal-card li { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }

/* ---- debug overlay ------------------------------------------------------- */
#debug {
  position: fixed; bottom: 8px; right: 8px; z-index: 999;
  max-width: 320px; max-height: 50vh; overflow: auto;
  background: rgba(18,18,18,0.92); color: #d7ffe0;
  font-family: var(--mono); font-size: 11px; line-height: 1.4;
  padding: 10px 12px; border-radius: 10px;
}
.debug-title { color: #fff; font-weight: 600; margin-bottom: 6px; }
.debug-line { white-space: pre-wrap; word-break: break-word; }

/* desktop framing — keep the single mobile-width column, but present it as an
   intentional floating card on a softer backdrop (not a bare column on flat cream). */
@media (min-width: 540px) {
  body { background: #efe6d9; }
  #app {
    background: var(--bg);
    margin: 28px auto;
    border-radius: 22px;
    box-shadow: 0 14px 44px rgba(30, 24, 16, 0.16);
    overflow: hidden; /* clip hero image / edges to the rounded corners */
    min-height: calc(100dvh - 56px);
  }
}
