/* =============================================================
   Lottomatica Group e l'Ambiente — Survey
   styles.css
   Mobile-first · design tokens · premium corporate
   Sezioni: 1) Tokens  2) Reset/base  3) Layout shell
            4) Header  5) Progress  6) Steps  7) Options
            8) Privacy  9) Buttons  10) Thanks  11) Utils
            12) Responsive  13) Reduced motion
   ============================================================= */

/* ---------- 1) DESIGN TOKENS ---------- */
:root {
  /* Brand */
  --brand-blue:       #002D72;
  --brand-blue-600:   #00409A;
  --brand-blue-700:   #002257;
  --brand-blue-050:   #eef2fa;
  --green:            #00A651;
  --green-600:        #008F45;
  --green-050:        #e8f7ef;

  /* Neutrals / text */
  --text:             #16203a;
  --text-muted:       #5a6478;
  --text-on-brand:    #ffffff;

  /* Surfaces */
  --surface:          #ffffff;
  --surface-subtle:   #f6f8fc;
  --surface-sunken:   #f0f4fa;
  --border:           #e2e8f2;
  --border-strong:    #cdd6e6;

  /* Feedback */
  --danger:           #c0322b;
  --danger-bg:        #fbeceb;

  /* Radius */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* Spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 56px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(16, 32, 70, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 32, 70, 0.08);
  --shadow-lg: 0 24px 60px -20px rgba(16, 32, 70, 0.28);

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-eyebrow: 0.78rem;
  --fs-body:    1rem;
  --fs-title:   1.45rem;
  --fs-hero:    2rem;

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur:  0.32s;

  /* Layout */
  --shell-max: 720px;
}

/* ---------- 2) RESET / BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(12px, 4vw, 40px);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

h1, h2, p { margin: 0; }

button { font-family: inherit; }

/* Subtle, calm background wash (blue → green) */
.bg-decoration {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(0, 64, 154, 0.10), transparent 60%),
    radial-gradient(820px 520px at 100% 0%, rgba(0, 166, 81, 0.09), transparent 55%),
    linear-gradient(180deg, #f7f9fd 0%, #eef2f8 100%);
}

/* ---------- 3) LAYOUT SHELL ---------- */
.shell {
  width: 100%;
  max-width: var(--shell-max);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.shell__main {
  padding: clamp(20px, 5vw, 40px);
}

.shell__footer {
  padding: var(--sp-4) clamp(20px, 5vw, 40px);
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}

/* ---------- 4) HEADER ---------- */
.shell__header {
  background: linear-gradient(120deg, var(--brand-blue-700), var(--brand-blue) 55%, var(--brand-blue-600));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) clamp(20px, 5vw, 32px);
}
.brand { display: flex; align-items: center; }
.brand--right { justify-content: flex-end; }
.brand__logo { height: 36px; width: auto; }
.brand__logo--less { height: 34px; }

/* ---------- 5) PROGRESS ---------- */
.progress {
  padding: var(--sp-4) clamp(20px, 5vw, 40px) 0;
}
.progress__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
}
.badge--anon {
  color: var(--green-600);
  background: var(--green-050);
}
.progress__count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.progress__track {
  height: 7px;
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand-blue), var(--green));
  transition: width var(--dur) var(--ease);
}

/* ---------- 6) STEPS ---------- */
.step { display: none; animation: stepIn var(--dur) var(--ease); }
.step.is-active { display: block; }
.step:focus { outline: none; }

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

.eyebrow {
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green-600);
  margin-bottom: var(--sp-3);
}
.step__title {
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: 1.25;
  color: var(--brand-blue);
  letter-spacing: -0.01em;
}
.step__title--hero { font-size: var(--fs-hero); }
.step__subtitle {
  margin-top: var(--sp-3);
  color: var(--text-muted);
  font-size: 1.02rem;
}

.intro-text {
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}
.intro-text p + p { margin-top: var(--sp-4); }
.intro-text strong { color: var(--text); }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: var(--radius-pill);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-blue); }
.dot--green { background: var(--green); }

/* ---------- 7) OPTION CARDS ---------- */
.options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease),
              background-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform 0.12s var(--ease);
}
.option:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
}
.option:active { transform: scale(0.992); }

/* visually hidden native radio (keeps full a11y + keyboard) */
.option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.option__marker {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  position: relative;
}
.option__marker::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--brand-blue);
  transform: scale(0);
  transition: transform var(--dur) var(--ease);
}

.option__body { display: flex; align-items: baseline; gap: var(--sp-3); }
.option__key {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--brand-blue);
  font-size: 0.92rem;
  min-width: 1ch;
}
.option__text { color: var(--text); font-size: 0.98rem; }

/* selected state */
.option:has(input:checked) {
  border-color: var(--brand-blue);
  background: var(--brand-blue-050);
  box-shadow: var(--shadow-sm);
}
.option:has(input:checked) .option__marker { border-color: var(--brand-blue); }
.option:has(input:checked) .option__marker::after { transform: scale(1); }

/* focus-visible (keyboard) */
.option:has(input:focus-visible) {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

/* ---------- 8) PRIVACY ---------- */
.privacy-card {
  margin-top: var(--sp-6);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-blue);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
}
.privacy-card__text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}
.consent {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-blue);
  letter-spacing: 0.04em;
}
.consent input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.consent__box {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-brand);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.consent__box svg { opacity: 0; transition: opacity var(--dur) var(--ease); }
.consent input:checked + .consent__box {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
}
.consent input:checked + .consent__box svg { opacity: 1; }
.consent input:focus-visible + .consent__box {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}

/* ---------- 9) BUTTONS ---------- */
.step__actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-8);
}
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px 26px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform 0.1s var(--ease), box-shadow var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.btn:active { transform: scale(0.985); }

.btn--primary {
  flex: 1;
  background: var(--brand-blue);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--brand-blue-600); }

.btn--ghost {
  background: transparent;
  color: var(--brand-blue);
  border: 1.5px solid var(--border-strong);
}
.btn--ghost:hover { background: var(--surface-subtle); }

.btn[disabled], .btn[aria-busy="true"] {
  opacity: 0.7;
  cursor: not-allowed;
}

/* submit spinner */
.btn__spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  display: none;
  animation: spin 0.7s linear infinite;
}
.btn--submit[aria-busy="true"] .btn__spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 10) ERRORS ---------- */
.field-error, .form-error {
  margin-top: var(--sp-4);
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #f1c7c4;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- 11) THANK YOU ---------- */
.step--thanks { text-align: center; padding: var(--sp-6) 0; }
.thanks__icon {
  width: 76px; height: 76px;
  margin: 0 auto var(--sp-6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--green-600);
  background: var(--green-050);
  animation: pop var(--dur) var(--ease);
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- 11b) UTILITIES ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
/* Honeypot — kept out of view and tab order */
.hp-field {
  position: absolute !important;
  left: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}
.skip-link {
  position: absolute;
  left: 8px; top: -48px;
  background: var(--brand-blue);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 10;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 8px; }

/* ---------- 12) RESPONSIVE ---------- */
@media (max-width: 600px) {
  body { padding: 0; align-items: stretch; }
  .shell {
    border-radius: 0;
    border: none;
    box-shadow: none;
    min-height: 100dvh;
  }
  :root { --fs-hero: 1.6rem; --fs-title: 1.25rem; }
  .step__actions { flex-direction: column-reverse; }
  .btn--ghost, .btn--primary { width: 100%; }
}

/* ---------- 13) REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
