/* ==========================================================================
   QUIZ — foglio a tutto schermo (mobile) / pannello centrato (desktop)
   ========================================================================== */

.sheet { position: fixed; inset: 0; z-index: 100; visibility: hidden; pointer-events: none; }
.sheet.is-open { visibility: visible; pointer-events: auto; }
.sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 23, .55);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  opacity: 0;
  transition: opacity .5s ease;
}
.sheet.is-open .sheet__scrim { opacity: 1; }
.sheet__panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--text);
  transform: translateY(100%);
  transition: transform .65s var(--ease);
  overflow: hidden;
  overflow: clip;
}
.sheet.is-open .sheet__panel { transform: none; }
@media (min-width: 834px) {
  .sheet__panel {
    inset: 5vh auto 5vh 50%;
    width: min(680px, 92vw);
    border-radius: 32px;
    transform: translate(-50%, 40px) scale(.98);
    opacity: 0;
    transition: transform .6s var(--ease), opacity .4s ease;
    box-shadow: 0 60px 120px -40px rgba(0, 0, 0, .6);
  }
  .sheet.is-open .sheet__panel { transform: translate(-50%, 0); opacity: 1; }
}

/* Header */
.sheet__head {
  flex: none;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
}
.sheet__iconbtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  transition: background-color .2s ease, opacity .3s ease;
}
.sheet__iconbtn:hover { background: rgba(0, 0, 0, .05); }
.sheet__iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sheet__iconbtn[hidden] { display: grid; visibility: hidden; }
.sheet__close { background: rgba(0, 0, 0, .06); width: 34px; height: 34px; justify-self: end; margin-right: 5px; }
.sheet__close svg { width: 14px; height: 14px; stroke-width: 2.4; }
.sheet__title { text-align: center; font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: -.005em; }
.sheet__title b { color: var(--text); font-weight: 600; }

/* Progresso segmentato */
.progress { flex: none; display: flex; gap: 4px; padding: 0 24px 8px; transition: opacity .3s ease; }
.progress i { flex: 1; height: 4px; border-radius: 999px; background: rgba(0, 0, 0, .08); overflow: hidden; position: relative; }
.progress i::after { content: ""; position: absolute; inset: 0; background: var(--gold); border-radius: inherit; transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease); }
.progress i.is-done::after, .progress i.is-current::after { transform: scaleX(1); }
.progress i.is-current::after { background: var(--text); }
.progress.is-hidden { opacity: 0; }

/* Corpo */
.sheet__body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; position: relative; }
.sheet__stage { padding: 24px 24px 40px; max-width: 560px; margin: 0 auto; }
@media (min-width: 834px) { .sheet__stage { padding: 28px 48px 48px; } }

.q { animation: qIn .55s var(--ease) both; }
.q.is-leaving { animation: qOut .28s ease both; }
.q.is-back { animation-name: qInBack; }
@keyframes qIn { from { opacity: 0; transform: translate3d(28px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes qInBack { from { opacity: 0; transform: translate3d(-28px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes qOut { to { opacity: 0; transform: translate3d(-16px, 0, 0); } }

.q__k { font-size: 13px; font-weight: 600; color: var(--gold-lo); font-variant-numeric: tabular-nums; }
.q__title { margin-top: 8px; font-size: clamp(26px, 6vw, 34px); line-height: 1.12; font-weight: 700; letter-spacing: -.035em; }
.q__desc { margin-top: 10px; font-size: 16px; color: var(--text-2); }

/* Opzioni */
.opts { display: grid; gap: 10px; margin-top: 28px; }
.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 14px 16px 14px 20px;
  border-radius: 18px;
  text-align: left;
  background: var(--white);
  box-shadow: 0 0 0 1px var(--hairline);
  transition: transform .25s var(--ease), box-shadow .25s ease, background-color .25s ease;
  animation: qIn .5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms + 60ms);
  -webkit-tap-highlight-color: transparent;
}
.opt:hover { box-shadow: 0 0 0 1px rgba(0, 0, 0, .16), 0 8px 24px -16px rgba(2, 8, 23, .3); }
.opt:active { transform: scale(.985); }
.opt__txt { flex: 1; min-width: 0; }
.opt__l { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.opt__s { display: block; margin-top: 2px; font-size: 14px; color: var(--text-2); line-height: 1.35; }
.opt__radio { flex: none; width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 0 0 1.5px #c7c7cc inset; display: grid; place-items: center; transition: background-color .25s ease, box-shadow .25s ease; }
.opt__radio svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset .35s var(--ease) .05s; }
.opt.is-selected { box-shadow: 0 0 0 2px var(--gold); background: #fffdf8; }
.opt.is-selected .opt__radio { background: var(--gold); box-shadow: none; }
.opt.is-selected .opt__radio svg { stroke-dashoffset: 0; }

/* Campi */
.fields { display: grid; gap: 12px; margin-top: 28px; }
.field { position: relative; display: block; }
.field__input, .field__area {
  width: 100%;
  font: inherit;
  font-size: 17px;
  letter-spacing: -.02em;
  color: var(--text);
  background: var(--white);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 0 0 1px var(--hairline);
  transition: box-shadow .2s ease;
  -webkit-appearance: none;
  appearance: none;
}
.field__input { height: 62px; padding: 24px 18px 8px; }
.field__area { min-height: 180px; padding: 18px; resize: vertical; line-height: 1.45; }
.field__input:focus, .field__area:focus { outline: none; box-shadow: 0 0 0 2px var(--gold); }
.field__label {
  position: absolute;
  left: 18px;
  top: 21px;
  font-size: 17px;
  color: var(--text-2);
  pointer-events: none;
  transform-origin: left top;
  transition: transform .25s var(--ease), color .2s ease;
}
.field__input:focus + .field__label,
.field__input:not(:placeholder-shown) + .field__label { transform: translateY(-11px) scale(.72); }
.field__input:focus + .field__label { color: var(--gold-lo); }
.field.is-invalid .field__input, .field.is-invalid .field__area { box-shadow: 0 0 0 2px #d70015; }
.field__hint { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--text-2); }

.privacy { display: flex; gap: 12px; align-items: flex-start; margin-top: 6px; padding: 14px 4px; font-size: 14px; line-height: 1.45; color: var(--text-2); cursor: pointer; }
.privacy input { position: absolute; opacity: 0; pointer-events: none; }
.privacy__box { flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 7px; box-shadow: 0 0 0 1.5px #c7c7cc inset; display: grid; place-items: center; transition: background-color .2s ease, box-shadow .2s ease; background: var(--white); }
.privacy__box svg { width: 13px; height: 13px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.6); transition: opacity .2s, transform .3s var(--ease); }
.privacy input:checked + .privacy__box { background: var(--gold); box-shadow: none; }
.privacy input:checked + .privacy__box svg { opacity: 1; transform: none; }
.privacy input:focus-visible + .privacy__box { outline: 2px solid var(--gold); outline-offset: 2px; }
.privacy__link { color: var(--text); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

.alert {
  display: none;
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.4;
  color: #8a0010;
  background: #fff1f2;
  box-shadow: 0 0 0 1px rgba(215, 0, 21, .15) inset;
}
.alert.is-visible { display: block; animation: shake .45s var(--ease); }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

.q__actions { margin-top: 28px; }
.q__actions .btn { width: 100%; }
.q__secure { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.q__secure svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }

/* Caricamento */
.state { text-align: center; padding: 48px 8px; animation: qIn .6s var(--ease) both; }
.loader { width: 72px; height: 72px; margin: 0 auto 28px; }
.loader circle { fill: none; stroke-width: 3; }
.loader .bg { stroke: rgba(0, 0, 0, .08); }
.loader .fg { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 60 200; transform-origin: center; animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state__title { font-size: 26px; font-weight: 700; letter-spacing: -.03em; }
.state__text { margin: 12px auto 0; max-width: 34ch; color: var(--text-2); }
.curiosity { margin: 36px auto 0; max-width: 32ch; padding: 18px 20px; border-radius: 18px; background: var(--white); box-shadow: 0 0 0 1px var(--hairline); font-size: 15px; line-height: 1.45; color: var(--text); transition: opacity .3s ease; }
.curiosity small { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--gold-lo); }

/* Successo */
.success__badge { width: 88px; height: 88px; margin: 0 auto 28px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(180deg, #e3c98a, #c9a962); box-shadow: 0 20px 40px -16px rgba(201, 169, 98, .8); animation: pop .7s var(--ease) both; }
.success__badge svg { width: 40px; height: 40px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .6s var(--ease) .35s forwards; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.success__hl { color: var(--text); font-weight: 600; }
.success__reviews { margin-top: 36px; padding: 20px 12px; border-radius: 22px; background: var(--white); box-shadow: 0 0 0 1px var(--hairline); min-height: 120px; }
.success__reviews p { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.state .btn { margin-top: 28px; }

/* Privacy dialog */
.pdialog { position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: center; background: rgba(2, 8, 23, .4); opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s; }
.pdialog.is-visible { opacity: 1; visibility: visible; }
.pdialog__card { width: 100%; max-height: 82%; display: flex; flex-direction: column; background: var(--white); border-radius: 28px 28px 0 0; transform: translateY(40px); transition: transform .45s var(--ease); }
.pdialog.is-visible .pdialog__card { transform: none; }
@media (min-width: 834px) { .pdialog { align-items: center; } .pdialog__card { width: 88%; border-radius: 24px; } }
.pdialog__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 8px 24px; }
.pdialog__head h3 { font-size: 20px; font-weight: 700; letter-spacing: -.025em; }
.pdialog__body { overflow-y: auto; padding: 8px 24px 8px; font-size: 15px; line-height: 1.55; color: var(--text-2); }
.pdialog__body h4 { margin: 18px 0 6px; font-size: 15px; color: var(--text); }
.pdialog__body ul { padding-left: 20px; margin: 6px 0; }
.pdialog__body strong { color: var(--text); }
.pdialog__foot { padding: 16px 24px calc(20px + env(safe-area-inset-bottom)); }
.pdialog__foot .btn { width: 100%; }
