/* Sondaggio: form, risultato personale, statistiche */

.tick { padding-left: 1.2rem; margin: 0 0 1rem; }
.tick li { margin-bottom: .3rem; }

#survey { margin-top: 1.5rem; }
#survey fieldset { border: 0; padding: 0; margin: 0 0 2rem; min-width: 0; }
#survey fieldset.step > legend { padding: 0; }
#survey fieldset.step > legend h2 { margin: 0 0 .4rem; }
.hp { position: absolute; left: -5000px; width: 1px; height: 1px; overflow: hidden; }

/* a step solo con JS: senza, il form è una pagina unica */
.js #survey fieldset.step { display: none; }
.js #survey fieldset.step.current { display: block; }

.progress { position: sticky; top: 3.5rem; z-index: 10; background: var(--bg); padding: .7rem 0 .6rem; margin-bottom: 1rem; }
.progress-text { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); font-weight: 600; margin-bottom: .35rem; }
.progress-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.field { margin-bottom: 1.1rem; display: grid; gap: .35rem; max-width: 22rem; }
.field label { font-size: 1rem; }
#survey select, #survey input[type="number"] {
  font: inherit; padding: .6rem .75rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); width: 100%;
}
#survey .field:first-of-type { max-width: 30rem; }

/* ---- colori ---- */
.colorq { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .9rem; }
.colorq-text { margin: 0 0 .7rem; font-size: 1.05rem; }
.palette { display: none; flex-wrap: wrap; gap: 5px; margin-bottom: .7rem; }
.js .palette { display: flex; }
.sw { width: 1.9rem; height: 1.9rem; border-radius: 7px; border: 2px solid rgb(0 0 0 / 18%); cursor: pointer; padding: 0; }
@media (prefers-color-scheme: dark) { .sw { border-color: rgb(255 255 255 / 25%); } }
.sw:hover { transform: scale(1.12); }
.sw[aria-pressed="true"] { outline: 3px solid var(--text); outline-offset: 2px; }
.colorq-custom { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; align-items: center; font-size: .95rem; }
.colorq-custom input[type="color"] { width: 3rem; height: 2.2rem; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; vertical-align: middle; cursor: pointer; }
.colorq.skipped .palette, .colorq.skipped input[type="color"] { opacity: .35; }
.skip-opt { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }

/* ---- scala likert ---- */
.likert { border: 1px solid var(--border) !important; border-radius: var(--radius); background: var(--surface); padding: .9rem 1.1rem 1rem !important; margin-bottom: .8rem !important; }
.likert.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 2px var(--danger-soft); }
.likert legend { padding: 0 .3rem; font-weight: 600; float: none; width: 100%; margin-bottom: .6rem; }
.likert legend .num { color: var(--muted); font-weight: 400; margin-right: .2rem; }
.scale { display: grid; grid-template-columns: auto repeat(5, 1fr) auto; align-items: center; gap: .3rem .4rem; }
.scale .end { font-size: .8rem; color: var(--muted); }
.scale .end:last-child { text-align: right; }
.opt { display: flex; justify-content: center; position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.dot {
  width: 2.7rem; height: 2.7rem; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--border); font-weight: 700; color: var(--muted); background: var(--surface);
  transition: background .12s, border-color .12s, color .12s;
}
.opt:hover .dot { border-color: var(--accent); }
.opt input:checked + .dot { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
@media (prefers-color-scheme: dark) { .opt input:checked + .dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); } }
.opt input:focus-visible + .dot { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (max-width: 34rem) {
  .scale { grid-template-columns: repeat(5, 1fr); }
  .scale .end:first-child { grid-column: 1 / 4; grid-row: 1; }
  .scale .end:last-child { grid-column: 3 / 6; grid-row: 1; }
  .dot { width: 2.4rem; height: 2.4rem; }
}

.step-nav { position: sticky; bottom: 0; background: var(--bg); padding: .8rem 0; display: flex; align-items: center; justify-content: space-between; gap: .8rem; border-top: 1px solid var(--border); }
.step-msg { color: var(--danger); font-size: .9rem; font-weight: 600; text-align: center; flex: 1; }
.submit-row { margin-top: 1.4rem; }
.js .submit-row { display: none; }
.js fieldset.step.last .submit-row { display: block; }
.linklike { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---- risultato personale ---- */
.trait-list { display: grid; gap: 1rem; margin: 1.2rem 0 2rem; }
.trait { padding: 1rem 1.2rem; }
.trait-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.trait h3 { margin: 0; }
.trait .en { color: var(--muted); font-weight: 400; font-size: .9rem; }
.trait .pct { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 12px; border-radius: 99px; background: var(--surface-2); margin: .7rem 0 .5rem; border: 1px solid var(--border); }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--accent); }
.meter .avg { position: absolute; top: -5px; width: 3px; height: 20px; background: var(--text); border-radius: 2px; }
.meter-legend { font-size: .85rem; color: var(--muted); display: flex; justify-content: space-between; }
.trait p { margin: .4rem 0 0; }
.result-grid { display: grid; grid-template-columns: minmax(16rem, 22rem) 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 46rem) { .result-grid { grid-template-columns: 1fr; } }
.radar { width: 100%; max-width: 24rem; margin-inline: auto; display: block; }
.radar .ring { fill: none; stroke: var(--border); stroke-width: 1; }
.radar .axis { stroke: var(--border); stroke-width: 1; }
.radar .you { fill: color-mix(in srgb, var(--accent) 28%, transparent); stroke: var(--accent); stroke-width: 2.5; }
.radar .avgp { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; }
.radar text { fill: var(--text); font: 600 12px var(--font); }
.radar .dotp { fill: var(--accent); }
.legend { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); justify-content: center; margin-top: .4rem; }
.legend i { display: inline-block; width: 1.4rem; height: 0; border-top: 3px solid var(--accent); vertical-align: middle; margin-right: .3rem; }
.legend i.dash { border-top: 2px dashed var(--muted); }
.mycolors { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .6rem; }
.mycolor { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.mycolor .chip { height: 3.2rem; }
.mycolor .chip.none { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface) 6px, var(--surface) 12px); }
.mycolor span { display: block; padding: .35rem .6rem; font-size: .85rem; }
.copy-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.copy-row input { flex: 1; min-width: 12rem; font: inherit; padding: .55rem .7rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* ---- statistiche ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .8rem; margin: 1.2rem 0; }
.kpi { padding: .9rem 1.1rem; }
.kpi b { display: block; font-size: 1.9rem; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .9rem; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--text); font: 500 12px var(--font); }
.chart .muted-t { fill: var(--muted); }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar:hover { opacity: .8; }
.chart .axis-line { stroke: var(--muted); stroke-width: 1; }
.stat-section { margin-top: 2.4rem; }
.trait-stat { margin-bottom: 1.4rem; }
.trait-stat h3 { margin: 0 0 .2rem; }
.mini-table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.mini-table th, .mini-table td { padding: .35rem .6rem; text-align: left; border-bottom: 1px solid var(--border); }
.mini-table td.num, .mini-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mosaic { display: flex; flex-wrap: wrap; gap: 2px; }
.mosaic i { width: 14px; height: 14px; border-radius: 3px; display: block; }
.emotion-card { padding: 1rem 1.2rem; }
.emotion-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.emotion-head h3 { margin: 0; }
.avg-chip { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.fam-row { display: grid; grid-template-columns: 6.5rem 1fr 3.4rem; gap: .5rem; align-items: center; font-size: .9rem; margin: .2rem 0; }
.fam-row .track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.fam-row .track span { display: block; height: 100%; border-radius: 4px; border: 1px solid rgb(0 0 0 / 15%); }
.fam-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.heat { border-collapse: collapse; font-size: .85rem; width: 100%; }
.heat th { font-weight: 600; padding: .3rem .4rem; text-align: center; }
.heat th.rl { text-align: left; }
.heat td { text-align: center; padding: .4rem .3rem; font-variant-numeric: tabular-nums; border: 2px solid var(--bg); min-width: 3.4rem; }
.heat td.na { color: var(--muted); }
.scroll-x { overflow-x: auto; }
.caveat { border-left: 4px solid var(--star); padding: .6rem 1rem; background: var(--surface-2); border-radius: 0 10px 10px 0; font-size: .95rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.emotions-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }

/* ---- tooltip e mappe di calore ---- */
:root { --div-pos: #2a78d6; --div-neg: #e34948; --div-mid: #f0efec; }
@media (prefers-color-scheme: dark) { :root { --div-pos: #3987e5; --div-neg: #e66767; --div-mid: #383835; } }
.tip { position: fixed; z-index: 200; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .7rem; box-shadow: var(--shadow); font-size: .85rem; line-height: 1.3; }
.tip strong { display: block; font-size: 1rem; }
.tip span { color: var(--muted); }
.chart .bar.on { filter: brightness(1.15); }
.chart:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
details.twin { margin-top: .4rem; font-size: .9rem; }
details.twin summary { cursor: pointer; color: var(--accent); }
details.twin table { margin-top: .4rem; }

/* il bordo sticky in alto (header + progresso) e in basso (Avanti) non deve coprire i campi */
.likert, .colorq, #survey .field { scroll-margin-block: 7.5rem; }

/* ---- riquadro "In breve" e legenda delle mappe ---- */
.highlights { margin: 1.2rem 0; border-left: 4px solid var(--accent); }
.highlights h2 { margin: 0 0 .5rem; font-size: 1.2rem; }
.highlights ul { margin: 0; padding-left: 1.2rem; }
.highlights li { margin-bottom: .45rem; }
.heat-legend { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .8rem; margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.heat-legend span { padding: .15rem .6rem; border-radius: 6px; }
.heat-legend .neg { background: color-mix(in srgb, var(--div-neg) 40%, var(--div-mid)); }
.heat-legend .mid { background: var(--div-mid); }
.heat-legend .pos { background: color-mix(in srgb, var(--div-pos) 40%, var(--div-mid)); }

/* ---- mappa dei colori: campo colorato + puntini ---- */
.cmap-title { margin: .9rem 0 .2rem; font-weight: 600; }
.cmap { width: 100%; height: auto; display: block; overflow: visible; }
.cmap .ax { fill: var(--muted); font: 500 11px var(--font); }
.cmap .frame { stroke: var(--border); stroke-width: 1; }
.cmap .tick { stroke: var(--muted); stroke-width: 1; }
.cmap .halo { fill: none; stroke: rgb(0 0 0 / 38%); stroke-width: 1; }
.cmap .dot { stroke: #fff; stroke-width: 1.7; }
