/* =====================================================
   Quiz Encanto Energy - Design System
   Palette dal brand-prompt: viola Encanto + crema avorio + oro antico
   Mobile-first, no framework, no build step.
   ===================================================== */

:root {
  /* Palette */
  --viola-encanto: #63368D;
  --viola-profondo: #3D1F5C;
  --viola-lavanda: #C8B3DB;
  --viola-lavanda-soft: #E5D9EE;
  --crema: #F3EDE4;
  --crema-soft: #FBF5EB;
  --oro: #B8956A;
  --oro-chiaro: #D4AF7A;
  --nero: #1A0E2B;
  --bianco: #FBFAF8;
  --grigio-medio: rgba(26, 14, 43, 0.55);
  --grigio-leggero: rgba(26, 14, 43, 0.18);
  --error: #B0413E;

  /* Typography */
  --font-display: "Cormorant Garamond", "Libre Baskerville", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  /* Spacing */
  --space-xs: 8px;
  --space-s: 16px;
  --space-m: 24px;
  --space-l: 40px;
  --space-xl: 64px;
  --space-xxl: 96px;

  /* Layout */
  --maxw: 720px;
  --maxw-narrow: 600px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 18px 50px -25px rgba(61, 31, 92, 0.45);
  --transition: 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--nero);
  background: var(--crema-soft);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
a { color: var(--viola-encanto); text-decoration: underline; text-underline-offset: 3px; transition: color var(--transition); }
a:hover { color: var(--viola-profondo); }

/* ========== Topbar (progress) ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bianco);
  border-bottom: 1px solid var(--grigio-leggero);
  backdrop-filter: saturate(140%) blur(8px);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px var(--space-m);
  display: flex;
  align-items: center;
  gap: var(--space-s);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--viola-encanto);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: default;
  user-select: none;
}
.brand-mark { display: inline-flex; }
.brand-text { font-family: var(--font-display); font-size: 19px; letter-spacing: 0.01em; }
.topbar-progress {
  flex: 1;
  height: 3px;
  background: var(--viola-lavanda-soft);
  border-radius: 4px;
  overflow: hidden;
}
.topbar-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--viola-encanto), var(--oro));
  transition: width 350ms ease-out;
}
.topbar-step {
  font-size: 13px;
  color: var(--grigio-medio);
  min-width: 38px;
  text-align: right;
}

/* ========== Containers / screens ========== */
main#app { flex: 1; }
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-m);
}
.container--narrow { max-width: var(--maxw-narrow); }

.screen {
  display: none;
  animation: fadeIn 380ms ease-out;
}
.screen.is-active { display: block; }

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

/* ========== Typography ========== */
.eyebrow {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--viola-encanto);
  font-weight: 600;
  margin: 0 0 var(--space-s) 0;
}
.eyebrow--q { color: var(--grigio-medio); }
.display {
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.12;
  font-weight: 500;
  color: var(--viola-profondo);
  margin: 0 0 var(--space-m) 0;
  letter-spacing: -0.01em;
}
.display--md {
  font-size: clamp(28px, 4.6vw, 38px);
  line-height: 1.18;
}
.lead {
  font-size: 19px;
  line-height: 1.55;
  color: var(--nero);
  margin: 0 0 var(--space-l) 0;
  max-width: 56ch;
}
.lead--sm { font-size: 17px; margin-bottom: var(--space-l); }

.trust {
  margin-top: var(--space-xl);
  padding-top: var(--space-l);
  border-top: 1px solid var(--grigio-leggero);
  color: var(--grigio-medio);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.micro {
  font-size: 14px;
  color: var(--grigio-medio);
  margin: var(--space-s) 0 0 0;
}

/* ========== Hero ========== */
.screen--hero { background: linear-gradient(180deg, var(--crema-soft) 0%, var(--bianco) 100%); }
.cta-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-xs); }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
  transition: transform var(--transition), background-color var(--transition), box-shadow var(--transition), color var(--transition), border-color var(--transition);
  min-height: 48px;
  text-decoration: none;
  white-space: nowrap;
}
.btn--primary {
  background: var(--viola-encanto);
  color: var(--bianco);
  box-shadow: var(--shadow);
}
.btn--primary:hover:not(:disabled) {
  background: var(--viola-profondo);
  transform: translateY(-1px);
}
.btn--primary:active:not(:disabled) { transform: translateY(0); }
.btn--primary:disabled {
  background: var(--viola-lavanda);
  color: rgba(255, 255, 255, 0.85);
  cursor: not-allowed;
  box-shadow: none;
}
.btn--ghost {
  background: transparent;
  color: var(--viola-encanto);
  border: 1.5px solid var(--viola-lavanda);
}
.btn--ghost:hover { background: var(--viola-lavanda-soft); border-color: var(--viola-encanto); }
.btn--large { padding: 18px 36px; font-size: 17px; min-height: 56px; }

/* ========== Question screen ========== */
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 var(--space-l) 0;
}
.option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bianco);
  border: 1.5px solid var(--grigio-leggero);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background-color var(--transition), transform var(--transition);
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: var(--nero);
  font-size: 16px;
  line-height: 1.5;
  min-height: 56px;
}
.option:hover { border-color: var(--viola-lavanda); background: var(--crema-soft); }
.option:focus-visible { outline: 2px solid var(--viola-encanto); outline-offset: 3px; }
.option.is-selected {
  border-color: var(--viola-encanto);
  background: var(--viola-lavanda-soft);
}
.option-mark {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--grigio-leggero);
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bianco);
  transition: border-color var(--transition), background-color var(--transition);
}
.option.is-selected .option-mark {
  border-color: var(--viola-encanto);
  background: var(--viola-encanto);
}
.option.is-selected .option-mark::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bianco);
}
.option--multi .option-mark { border-radius: 6px; }
.option--multi.is-selected .option-mark::after {
  width: 12px;
  height: 8px;
  background: none;
  border-left: 2px solid var(--bianco);
  border-bottom: 2px solid var(--bianco);
  transform: rotate(-45deg) translate(2px, -1px);
  border-radius: 0;
}
.option-label { flex: 1; }

/* Insight */
.insight {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  align-items: start;
  background: var(--viola-lavanda-soft);
  border-left: 3px solid var(--viola-encanto);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 var(--space-l) 0;
  animation: insightIn 420ms ease-out;
}
.insight[hidden] { display: none; }
@keyframes insightIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.insight-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--viola-encanto);
  color: var(--bianco);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.insight-text {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--viola-profondo);
  white-space: pre-wrap;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  flex-wrap: wrap;
}

/* ========== Form ========== */
form#leadForm { display: flex; flex-direction: column; gap: var(--space-m); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--nero);
  letter-spacing: 0.01em;
}
.req { color: var(--viola-encanto); }
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"] {
  padding: 14px 16px;
  border: 1.5px solid var(--grigio-leggero);
  border-radius: var(--radius);
  background: var(--bianco);
  font: inherit;
  color: var(--nero);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  min-height: 52px;
}
.field input:focus {
  outline: none;
  border-color: var(--viola-encanto);
  box-shadow: 0 0 0 3px var(--viola-lavanda-soft);
}
.field input.is-invalid { border-color: var(--error); }
.error {
  color: var(--error);
  font-size: 13px;
  min-height: 0;
  font-weight: 500;
}
.field--check { flex-direction: row; align-items: flex-start; gap: 12px; }
.check {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.55;
  color: var(--nero);
  width: 100%;
}
.check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.check-mark {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--grigio-leggero);
  border-radius: 6px;
  background: var(--bianco);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: border-color var(--transition), background-color var(--transition);
}
.check input:checked + .check-mark {
  background: var(--viola-encanto);
  border-color: var(--viola-encanto);
}
.check input:checked + .check-mark::after {
  content: "";
  width: 12px;
  height: 7px;
  border-left: 2px solid var(--bianco);
  border-bottom: 2px solid var(--bianco);
  transform: rotate(-45deg) translate(1px, -2px);
}
.check input:focus-visible + .check-mark {
  outline: 2px solid var(--viola-encanto);
  outline-offset: 2px;
}
.check-text { font-weight: 400; }
.check-text a { font-weight: 500; }

.form-actions {
  margin-top: var(--space-s);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
}
.form-error {
  background: rgba(176, 65, 62, 0.08);
  border: 1px solid rgba(176, 65, 62, 0.3);
  color: var(--error);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
}

/* ========== Result ========== */
.profile-body {
  margin: var(--space-l) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}
.profile-body p {
  font-size: 17px;
  line-height: 1.7;
  color: var(--nero);
  margin: 0;
  white-space: pre-wrap;
}
.profile-body p:first-letter {
  font-family: var(--font-display);
  font-size: 1.4em;
  font-weight: 500;
  color: var(--viola-encanto);
}

.porta-card {
  background: linear-gradient(135deg, var(--viola-profondo), var(--viola-encanto));
  color: var(--bianco);
  border-radius: var(--radius);
  padding: var(--space-l);
  margin: var(--space-l) 0;
  position: relative;
  overflow: hidden;
}
.porta-card::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 60%;
  height: 180%;
  background: radial-gradient(closest-side, rgba(184, 149, 106, 0.32), transparent);
  pointer-events: none;
}
.porta-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 6px 0;
  opacity: 0.85;
  font-weight: 600;
}
.porta-name {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  margin: 0 0 var(--space-s) 0;
  letter-spacing: -0.01em;
}
.porta-tagline { margin: 0; font-size: 17px; line-height: 1.55; opacity: 0.95; }

.next-step {
  margin-top: var(--space-l);
  padding: var(--space-l);
  background: var(--bianco);
  border: 1px solid var(--grigio-leggero);
  border-radius: var(--radius);
}
.next-step h3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 var(--space-s) 0;
  color: var(--viola-profondo);
}
.next-step p { margin: 0 0 var(--space-m) 0; line-height: 1.65; white-space: pre-wrap; }

/* ========== Footer ========== */
.footer {
  background: var(--viola-profondo);
  color: rgba(251, 250, 248, 0.78);
  padding: var(--space-l) 0;
  margin-top: var(--space-xxl);
}
.footer .container { padding: 0 var(--space-m); }
.footer p { margin: 0 0 6px 0; font-size: 13px; line-height: 1.6; }
.footer-brand { color: var(--bianco); font-weight: 500; }
.footer a { color: var(--oro-chiaro); }
.footer a:hover { color: var(--bianco); }

/* ========== Noscript banner ========== */
.noscript-banner {
  background: var(--viola-encanto);
  color: var(--bianco);
  padding: var(--space-s);
  text-align: center;
  font-size: 14px;
}

/* ========== Mobile ========== */
@media (max-width: 600px) {
  .container { padding: var(--space-l) var(--space-s); }
  .topbar-inner { padding: 10px var(--space-s); gap: 12px; }
  .brand-text { display: none; }
  .topbar-step { font-size: 12px; }
  .lead { font-size: 17px; }
  .options { gap: 8px; }
  .option { padding: 14px 16px; font-size: 15px; }
  .insight { padding: 14px 16px; }
  .insight-text { font-size: 16px; line-height: 1.55; }
  .actions { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .actions .btn { width: 100%; }
  .btn--large { width: 100%; }
  .porta-name { font-size: 28px; }
  .next-step { padding: var(--space-m); }
}

/* Touch devices: kill hover bounce */
@media (hover: none) {
  .btn--primary:hover:not(:disabled) { transform: none; background: var(--viola-encanto); }
  .option:hover { background: var(--bianco); border-color: var(--grigio-leggero); }
  .option.is-selected { background: var(--viola-lavanda-soft); border-color: var(--viola-encanto); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}
