* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@keyframes dropInDown {
    from {
        opacity: 0;
        transform: translateY(-150%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    position: relative;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: bold;
}

.video-background {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    overflow: hidden;
}

.video-background video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 1;
    filter: blur(4px);
}

/* Header */
header {
    background: rgba(0, 0, 0, 0);
    color: white;
    padding: 1rem 0;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 10;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    text-decoration: none;
    display: flex;
    align-items: center;
    height: auto;
}

.logo-img {
    height: 60px;
    width: auto;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6)) drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s;
}

.logo:hover .logo-img {
    transform: scale(1.05);
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

nav a:hover {
    color: #eb551a;
}

/* Pre-header */
.pre-header {
    background: url('../images/pre-header.jpg') repeat-x center;
    background-size: auto 100%;
    height: 40px;
    width: 100%;
}

/* Main */
main {
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0);
}

/* Logo centrato sopra il riquadro */
main .logo {
    display: flex;
    justify-content: center;
}

.container {
    max-width: 500px;
    background: white;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* Il form resta nascosto finché il video di sfondo non è partito, poi compare con l'animazione */
.container.is-waiting {
    opacity: 0;
    visibility: hidden;
}

.container.is-revealed {
    animation: dropInDown 0.8s ease-out both;
}

.container h1 {
    font-size: 32px;
    margin-bottom: 10px;
    color: #004289;
    text-align: center;
}

.container p {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
    text-align: center;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

/* Scelta punto vendita: griglia di card con l'insegna */
.store-grid {
    border: 0;
    padding: 0;
    margin: 0 0 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.store-legend {
    grid-column: 1 / -1;
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
    padding: 0;
}

.store-option {
    position: relative;
    cursor: pointer;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    margin: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.store-option:hover {
    border-color: #004289;
}

.store-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.store-option img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.store-option span {
    display: block;
    margin-top: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #004289;
}

/* Transizione dell'ingrandimento (browser con View Transitions): la card scelta cambia dimensione in modo morbido */
.store-option.is-valid {
    view-transition-name: store-selected;
}

::view-transition-group(store-selected) {
    animation-duration: 0.5s;
    animation-timing-function: ease;
}

/* Punto vendita scelto: le altre card si chiudono e quella scelta si allarga */
.store-grid.is-chosen .store-option:not(.is-valid) {
    display: none;
}

.store-grid.is-chosen .store-option.is-valid {
    grid-column: 1 / -1;
}

.store-change-hint {
    display: none;
    grid-column: 1 / -1;
    text-align: center;
    font-size: 12px;
    color: #666;
}

.store-grid.is-chosen .store-change-hint {
    display: block;
}

/* Quando la griglia torna aperta (deselect), le card compaiono con una leggera comparsa */
.store-grid:not(.is-chosen) .store-option {
    animation: storeCardIn 0.35s ease-out both;
}

/* Zoom-out della card scelta quando si deseleziona: lo zoom-in al contrario */
.store-option.is-zooming-out {
    animation: storeZoomOut 0.3s ease-in both;
}

@keyframes storeZoomOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.85);
        opacity: 0.4;
    }
}

@media (prefers-reduced-motion: reduce) {
    .store-grid:not(.is-chosen) .store-option {
        animation: none;
    }
}

@keyframes storeCardIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Campi non ancora accesi: sbiaditi e non cliccabili finché il passo precedente non è completo */
.is-locked {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.3s;
}

.is-locked .step-badge {
    background: #aaa;
}

/* Numerazione dei campi 1-4 */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #004289;
    color: white;
    font-size: 13px;
    font-weight: bold;
    line-height: 1;
    transition: background 0.2s;
}

.form-group .step-badge {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
}

.form-group input[type="text"],
.form-group input[type="email"] {
    padding-left: 48px;
}

.checkbox-group .step-badge {
    flex-shrink: 0;
}

.store-legend .step-badge {
    margin-right: 6px;
    vertical-align: middle;
}

.form-group.is-valid .step-badge,
.checkbox-group.is-valid .step-badge,
.store-legend.is-valid .step-badge {
    background: #28a745;
}

/* Stato valido (verde + spunta): card scelta, campi compilati, privacy accettata */
.store-option.is-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.25);
}

.store-option.is-valid::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    line-height: 26px;
    border-radius: 50%;
    background: #28a745;
    color: white;
    font-weight: bold;
    text-align: center;
}

.form-group {
    position: relative;
}

.form-group input {
    transition: border-color 0.2s, background-color 0.2s;
}

.form-group.is-valid input {
    border-color: #28a745;
    background: #f0fff4;
    padding-right: 40px;
}

.form-group.is-valid::after {
    content: '✓';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #28a745;
    font-weight: bold;
    font-size: 18px;
    pointer-events: none;
}

.checkbox-group.is-valid label {
    color: #28a745;
    font-weight: 600;
}

.checkbox-group.is-valid input[type="checkbox"] {
    accent-color: #28a745;
}

.checkbox-group.is-valid label::after {
    content: ' ✓';
    font-weight: bold;
}

.store-option:focus-within {
    outline: 2px solid #004289;
    outline-offset: 2px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

input[type="text"],
input[type="email"],
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    font-size: 16px;
    transition: border-color 0.3s;
    background: white;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus {
    outline: none;
    border-color: #004289;
    box-shadow: 0 0 0 3px rgba(0, 66, 137, 0.1);
}

/* Honeypot: nascosto agli utenti, compilato solo dai bot */
.hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

input::placeholder {
    color: #757575;
    opacity: 1;
}

/* Il placeholder della select (value vuoto) appare grigio */
select:invalid {
    color: #757575;
}

.checkbox-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    flex-shrink: 0;
}

input[type="checkbox"] {
    margin-top: 5px;
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0;
    font-weight: 400;
    font-size: 15px;
    text-align: center;
}

.btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #004289 0%, #eb551a 100%);
    color: white;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 66, 137, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Messaggi del form: sopra e sotto il pulsante */
.form-messages:empty {
    display: none;
}

.form-messages {
    margin-top: 16px;
}

/* Messages */
.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert ul {
    list-style: none;
    padding: 0;
}

.alert li {
    margin: 5px 0;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 14px;
}

footer p {
    margin: 0;
}

/* Modal Custom */
.modal-custom {
    border: none;
    border-radius: 0;
    box-shadow: 0 10px 60px rgba(0, 66, 137, 0.2);
}

.modal-custom .modal-header {
    background: linear-gradient(135deg, #004289 0%, #eb551a 100%);
    color: white;
    padding: 20px;
    border-radius: 0;
}

.modal-custom .modal-title {
    font-weight: bold;
    font-size: 20px;
}

.modal-custom .btn-close {
    filter: brightness(0) invert(1);
}

.modal-custom .modal-body {
    padding: 30px;
    background: #f9f9f9;
}

.confirm-details {
    background: white;
    padding: 15px;
    margin: 15px 0;
    border-left: 4px solid #004289;
}

.confirm-details p {
    margin: 10px 0;
    font-size: 14px;
}

.modal-custom .modal-footer {
    padding: 20px;
    background: white;
}

.modal-custom .btn-secondary {
    background: #ddd;
    color: #333;
    border: none;
}

.modal-custom .btn-secondary:hover {
    background: #ccc;
}

.modal-custom .btn-primary {
    color: white;
    border: none;
}

.modal-custom .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 66, 137, 0.3);
}

/* Finestra di conferma iscrizione */
.modal-success {
    border: none;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
}

.modal-success .modal-body {
    padding: 40px 30px 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f3f7ff 100%);
}

.success-badge {
    width: 84px;
    height: 84px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #28a745 0%, #5fd17c 100%);
    color: white;
    font-size: 44px;
    font-weight: bold;
    line-height: 84px;
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.35);
    animation: popIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

.success-title {
    color: #004289;
    font-weight: 700;
    font-size: 26px;
    margin-bottom: 10px;
}

.success-text {
    color: #555;
    font-size: 16px;
    line-height: 1.6;
}

.modal-success .modal-footer {
    justify-content: center;
    background: transparent;
    padding: 10px 30px 30px;
}

.success-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, #004289 0%, #eb551a 100%);
    box-shadow: 0 8px 20px rgba(0, 66, 137, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

.success-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 66, 137, 0.35);
}

@keyframes popIn {
    from {
        transform: scale(0.3);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Animate modal */
.modal.fade .modal-dialog {
    animation: slideInUp 0.5s ease-out;
}

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

/* Responsive */
@media (max-width: 768px) {
    nav ul {
        gap: 1rem;
    }

    nav a {
        font-size: 14px;
    }

    .container {
        padding: 30px 20px;
    }

    .container h1 {
        font-size: 24px;
    }

    /* Layout stabile: il contenuto parte dall'alto e non viene ricentrato quando la tastiera si apre */
    main {
        min-height: 0;
        justify-content: flex-start;
        padding: 24px 16px 40px;
    }

    /* Comparsa semplice (solo dissolvenza): niente scivolamento mentre il telefono ridisegna la pagina */
    .container.is-revealed {
        animation: fadeIn 0.6s ease-out both;
    }

    /* Sfumatura sul video a schermo intero: costosa sui telefoni, la togliamo */
    .video-background video {
        filter: none;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
}
