/* Modulo di iscrizione Prato 4. Tutto sotto .po4-iscr per non interferire con il tema. */

.po4-iscr {
	--po4-green: #004c01;
	--po4-green-dark: #003300;
	--po4-yellow: #fcbd00;
	--po4-text: #1d2327;
	--po4-muted: #5c6670;
	--po4-border: #b9c0c7;
	--po4-error: #b3261e;
	--po4-bg-soft: #f4f7f4;
	--po4-radius: 8px;
	max-width: 760px;
	margin: 0 auto;
	color: var(--po4-text);
	font-size: 16px;
	line-height: 1.5;
	scroll-margin-top: 16px;
}

.po4-iscr *,
.po4-iscr *::before,
.po4-iscr *::after { box-sizing: border-box; }

.po4-iscr [hidden] { display: none !important; }

/* ------------------------------------------------------------ avanzamento */

.po4-progress { margin: 0 0 12px; }
.po4-progress__bar { height: 8px; background: #e2e8e2; border-radius: 99px; overflow: hidden; }
.po4-progress__bar span { display: block; height: 100%; width: 0; background: var(--po4-green); border-radius: 99px; transition: width .25s ease; }
.po4-progress__label { margin: 8px 0 0; font-weight: 600; color: var(--po4-green); }

.po4-stepnav { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; }
.po4-stepnav li { margin: 0; padding: 0; }
.po4-stepnav button {
	font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 99px;
	border: 1px solid var(--po4-border); background: #fff; color: var(--po4-muted); cursor: pointer;
}
.po4-stepnav button:disabled { cursor: default; opacity: .55; }
.po4-stepnav button[aria-current="step"] { background: var(--po4-green); border-color: var(--po4-green); color: #fff; font-weight: 600; }
.po4-stepnav button:not(:disabled):not([aria-current]):hover { border-color: var(--po4-green); color: var(--po4-green); }

/* ---------------------------------------------------------------- passi */

.po4-step { margin: 0 0 8px; }
.po4-step__title { margin: 0 0 6px; font-size: 1.4rem; line-height: 1.25; color: var(--po4-green); outline: none; }
.po4-step__subtitle { margin: 0 0 16px; color: var(--po4-muted); }

.po4-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 16px; }
@media (min-width: 600px) {
	.po4-grid { grid-template-columns: 1fr 1fr; }
	.po4-grid > .po4-field { grid-column: 1 / -1; }
	.po4-grid > .po4-field--half { grid-column: auto; }
}

/* ---------------------------------------------------------------- campi */

.po4-field { min-width: 0; }
.po4-label { display: block; margin: 0 0 4px; font-weight: 600; }
.po4-req { color: var(--po4-error); }
.po4-help { margin: 0 0 6px; font-size: 14px; color: var(--po4-muted); }

.po4-iscr input[type="text"],
.po4-iscr input[type="email"],
.po4-iscr input[type="tel"],
.po4-iscr input[type="date"],
.po4-iscr select,
.po4-iscr textarea {
	display: block; width: 100%; margin: 0; padding: 10px 12px;
	font: inherit; font-size: 16px; /* 16px: evita lo zoom automatico su iOS */
	color: var(--po4-text); background: #fff;
	border: 1px solid var(--po4-border); border-radius: var(--po4-radius);
	min-height: 44px;
}
.po4-iscr textarea { min-height: 120px; resize: vertical; }
.po4-iscr input:hover, .po4-iscr select:hover, .po4-iscr textarea:hover { border-color: var(--po4-yellow); }
.po4-iscr input:focus, .po4-iscr select:focus, .po4-iscr textarea:focus,
.po4-iscr button:focus-visible, .po4-consent__text:focus-visible {
	outline: 3px solid var(--po4-yellow); outline-offset: 1px; border-color: var(--po4-green);
}
.po4-input--cf { text-transform: uppercase; letter-spacing: .06em; font-family: ui-monospace, Menlo, Consolas, monospace; }

.po4-field.is-invalid input,
.po4-field.is-invalid select,
.po4-field.is-invalid textarea { border-color: var(--po4-error); }
.po4-error { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--po4-error); }

.po4-radio { margin: 0; padding: 0; border: 0; min-width: 0; }
.po4-radio legend { padding: 0; }
.po4-check { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0 0; cursor: pointer; }
.po4-check input { width: 22px; height: 22px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--po4-green); }

/* ------------------------------------------------------------- consensi */

.po4-consent__text {
	max-height: 260px; overflow: auto; padding: 12px 14px; margin: 0 0 4px;
	background: var(--po4-bg-soft); border: 1px solid var(--po4-border); border-radius: var(--po4-radius);
	font-size: 14px;
}
.po4-consent__text p { margin: 0 0 10px; }
.po4-consent__text ul { margin: 0 0 10px 1.2em; padding: 0; }
/* Si accetta solo dopo aver scorso il testo fino in fondo. */
.po4-consent__hint { margin: 2px 0 0; font-size: 14px; color: var(--po4-muted); }
.po4-consent__hint::before { content: "↓ "; font-weight: 700; }
.po4-consent__hint.is-flash { color: var(--po4-error); font-weight: 600; }
.po4-check input:disabled { cursor: not-allowed; opacity: .45; }
.po4-check input:disabled + span { color: var(--po4-muted); }

/* ------------------------------------------------------------- combobox */

.po4-combo { position: relative; }
.po4-combo__list {
	position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
	margin: 4px 0 0; padding: 4px 0; list-style: none; max-height: 260px; overflow: auto;
	background: #fff; border: 1px solid var(--po4-green); border-radius: var(--po4-radius);
	box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}
.po4-combo__list li { margin: 0; padding: 9px 12px; cursor: pointer; }
.po4-combo__list li.is-active, .po4-combo__list li:hover { background: var(--po4-green); color: #fff; }
.po4-suggest__rest { font-weight: 700; }
/* Luoghi (GeoNames): la zona (regione, Stato) accanto al nome, piu' tenue. */
.po4-suggest__detail { margin-left: .5em; font-size: .85em; opacity: .75; }
/* Regione/provincia di nascita: la fornisce GeoNames con il luogo scelto, non si scrive. */
.po4-iscr input[data-po4-geo-region] { background: #eef1ee; color: #33443a; border-style: dashed; cursor: not-allowed; }
.po4-iscr input[data-po4-geo-region]:hover { border-color: var(--po4-border); }
/* Bandiere (emoji) del Paese scelto, a sinistra del campo. */
.po4-combo__flag { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 19px; line-height: 1; letter-spacing: 3px; pointer-events: none; white-space: nowrap; }
.po4-combo__list li.po4-combo__msg { cursor: default; color: var(--po4-muted); background: transparent; }

/* --------------------------------------------------------------- azioni */

.po4-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 28px; padding-top: 18px; border-top: 1px solid #e2e8e2; }
.po4-btn {
	font: inherit; font-weight: 600; padding: 11px 20px; min-height: 44px; cursor: pointer;
	color: var(--po4-green); background: #fff; border: 2px solid var(--po4-green); border-radius: var(--po4-radius);
}
.po4-btn:hover { background: var(--po4-yellow); border-color: var(--po4-yellow); color: #000; }
.po4-btn--primary { color: #fff; background: var(--po4-green); margin-left: auto; }
.po4-btn--primary:hover { background: var(--po4-yellow); color: #000; }
.po4-btn--ghost { background: transparent; }
.po4-btn--link { border-color: transparent; background: transparent; text-decoration: underline; padding-left: 4px; padding-right: 4px; }
.po4-btn:disabled { opacity: .6; cursor: default; }
@media (max-width: 520px) {
	.po4-actions .po4-btn--primary { flex: 1 1 100%; order: -1; margin-left: 0; }
	.po4-actions .po4-btn--ghost { flex: 1 1 auto; }
}

/* ------------------------------------------------------------ messaggi */

.po4-alert {
	margin: 0 0 16px; padding: 12px 14px; font-weight: 600;
	background: #fdf1ef; color: var(--po4-error); border: 1px solid var(--po4-error); border-left-width: 6px; border-radius: var(--po4-radius);
}
.po4-alert:focus { outline: 3px solid var(--po4-yellow); }

.po4-thanks { padding: 24px; background: var(--po4-bg-soft); border: 2px solid var(--po4-green); border-radius: var(--po4-radius); outline: none; }
.po4-thanks h2 { margin-top: 0; color: var(--po4-green); }
.po4-thanks__number { font-size: 1.15rem; }

/* ------------------------------------------ ricerca indirizzi (Google) */

.po4-field--search { padding: 16px; background: var(--po4-bg-soft); border: 1px solid #c9d6c9; border-left: 4px solid var(--po4-green); border-radius: var(--po4-radius); }
.po4-field--search .po4-combo input {
	padding-left: 44px; font-size: 17px; min-height: 50px;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23004c01' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center;
}
.po4-addr-privacy { margin: 6px 0 0; font-size: 13px; color: var(--po4-muted); }
.po4-addr-privacy::before { content: "🔒 "; }

/* Passo Residenza: due blocchi numerati e la scheda dell'indirizzo trovato. */
.po4-group { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 10px 0 -6px; font-size: 1.15rem; line-height: 1.3; color: var(--po4-green); }
.po4-group__n { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--po4-green); color: #fff; font-size: 15px; font-weight: 700; }
.po4-addr-card { grid-column: 1 / -1; padding: 14px 16px 16px; background: #fff; border: 1px solid #c9d6c9; border-radius: var(--po4-radius); }
.po4-addr-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; margin: 0 0 12px; }
.po4-addr-card__title { margin: 0; font-weight: 700; color: var(--po4-green); }
.po4-addr-card__tick { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-right: 4px; border-radius: 50%; background: var(--po4-green); color: #fff; font-size: 13px; }
.po4-addr-card__head .po4-linkbtn { margin: 0; }
.po4-addr-card__foot { margin: 12px 0 0; font-size: 13px; color: var(--po4-muted); }
.po4-addr-card__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.po4-addr-card__grid > .po4-field { grid-column: span 12; }
/* Ordine di lettura di un indirizzo (l'ordine dei campi nel modulo/CSV/admin resta quello storico). */
.po4-addr-card__grid > [data-po4-field="residenza_tipo_strada"] { order: 1; }
.po4-addr-card__grid > [data-po4-field="residenza_tipo_strada_altro"] { order: 2; }
.po4-addr-card__grid > [data-po4-field="residenza_indirizzo"] { order: 3; grid-column: span 8; }
.po4-addr-card__grid > [data-po4-field="residenza_civico"] { order: 4; grid-column: span 4; }
.po4-addr-card__grid > [data-po4-field="residenza_luogo"] { order: 5; }
.po4-addr-card__grid > [data-po4-field="residenza_area"] { order: 6; }
@media (min-width: 600px) {
	.po4-addr-card__grid > [data-po4-field="residenza_tipo_strada"] { grid-column: span 3; }
	.po4-addr-card__grid > [data-po4-field="residenza_tipo_strada_altro"] { grid-column: span 3; }
	.po4-addr-card__grid > [data-po4-field="residenza_indirizzo"] { grid-column: span 6; }
	.po4-addr-card__grid > [data-po4-field="residenza_civico"] { grid-column: span 3; }
	.po4-addr-card__grid > [data-po4-field="residenza_luogo"] { grid-column: span 5; }
	.po4-addr-card__grid > [data-po4-field="residenza_area"] { grid-column: span 7; }
}
/* In attesa dell'indirizzo (ricerca obbligatoria) i campi non servono: la scheda compare a indirizzo scelto. */
.po4-field.is-waiting { display: none; }
/* Un campo bloccato non si "compila": niente asterisco obbligatorio e niente etichetta ripetuta in ogni campo. */
.po4-addr-card .po4-field.is-locked > .po4-label .po4-req { display: none; }
.po4-addr-card .po4-field.is-locked > .po4-label::after { content: none; }
.po4-combo__attrib { margin: 0; padding: 4px 12px; font-size: 12px; color: var(--po4-muted); text-align: right; cursor: default; }
.po4-combo__list li.po4-combo__attrib:hover { background: transparent; color: var(--po4-muted); }

/* Campi di residenza bloccati: compilati da Google Maps (non modificabili) o in attesa della ricerca. */
.po4-field.is-locked input, .po4-field.is-locked select,
.po4-field.is-derived input, .po4-field.is-derived select,
.po4-field.is-waiting input, .po4-field.is-waiting select {
	background: #eef1ee; color: #33443a; border-style: dashed; cursor: not-allowed;
}
.po4-field.is-locked input:hover, .po4-field.is-locked select:hover,
.po4-field.is-derived input:hover, .po4-field.is-derived select:hover,
.po4-field.is-waiting input:hover, .po4-field.is-waiting select:hover { border-color: var(--po4-border); }
.po4-field.is-locked > .po4-label::after { content: " · compilato da Google Maps"; font-weight: 400; font-size: 13px; color: var(--po4-green); }
.po4-field.is-derived > .po4-label::after { content: " · in base alla tua risposta"; font-weight: 400; font-size: 13px; color: var(--po4-green); }
.po4-field.is-waiting > .po4-label::after { content: " · si compila dalla ricerca"; font-weight: 400; font-size: 13px; color: var(--po4-muted); }
/* Le istruzioni per chi scrive a mano non servono quando il campo si compila da solo. */
.po4-field.is-locked > .po4-help, .po4-field.is-derived > .po4-help, .po4-field.is-waiting > .po4-help { display: none; }
.po4-uk { margin: 14px 0 0; padding-top: 12px; border-top: 1px dashed var(--po4-border); }
.po4-field--search.is-invalid { border-color: var(--po4-error); border-style: solid; }

/* -------------------------------------------- note sotto i campi (CF) */

.po4-note { margin: 6px 0 0; padding: 8px 12px; font-size: 14px; border-left: 4px solid var(--po4-border); background: var(--po4-bg-soft); border-radius: 4px; }
.po4-note--ok { border-left-color: var(--po4-green); }
.po4-note--warn { border-left-color: var(--po4-yellow); background: #fff8e1; }
.po4-note--info { border-left-color: #5c6670; }
.po4-linkbtn { margin: 6px 0 0; padding: 0; font: inherit; font-size: 14px; color: var(--po4-green); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.po4-linkbtn:hover { color: var(--po4-green-dark); }

/* ---------------------------------------------------------------- bozza */

.po4-dialog { width: min(560px, calc(100vw - 32px)); padding: 22px; border: 2px solid var(--po4-green); border-radius: var(--po4-radius); color: var(--po4-text); }
.po4-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.po4-dialog h2 { margin: 0 0 10px; color: var(--po4-green); }
.po4-dialog__label { display: block; margin: 14px 0 4px; font-weight: 600; }
.po4-dialog__row { display: flex; gap: 8px; }
.po4-dialog__row input { flex: 1 1 auto; min-width: 0; }
.po4-dialog__row .po4-combo { flex: 1 1 auto; min-width: 0; }
.po4-dialog__row .po4-combo input { width: 100%; box-sizing: border-box; }
.po4-dialog__msg { min-height: 1.5em; margin: 10px 0 0; font-weight: 600; color: var(--po4-green); }
.po4-dialog__footer { margin-top: 12px; }

/* honeypot: fuori schermo, non display:none (alcuni bot lo saltano) */
.po4-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.po4-progress__bar span { transition: none; }
}
