/* ══════════════════════════════════════════════════════════════════════════════
   TEMA C — Acqua + sabbia
   Sfondo sabbia calda (#f4f1ed) con il teal del sito come primario.
   Le card delle lezioni usano l'azzurro ghiaccio #D6F1F5, creando un
   contrasto caldo/freddo accogliente e riconoscibile.
   ══════════════════════════════════════════════════════════════════════════════ */

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

:root {
    --beige:       #f4f1ed;   /* sabbia calda */
    --beige-scuro: #e8e3db;   /* sabbia media */
    --verde:       #0A7888;   /* teal primario del sito */
    --verde-scuro: #116F7C;   /* teal scuro */
    --testo:       #2a2520;   /* marrone scuro caldo */
    --grigio:      #7a7060;   /* grigio caldo */
    --errore:      #b04040;
    --radius:      8px;
    --shadow:      0 2px 12px rgba(10,120,136,0.13);
    --font:        'Georgia', serif;
}

html, body {
    margin: 0; padding: 0; min-height: 100vh;
    background-color: var(--beige);
    color: var(--testo);
    font-family: var(--font);
    font-size: 16px; line-height: 1.6;
}
body { display: flex; justify-content: center; align-items: center; }

.page-wrapper {
    margin: 0; padding: 0; border: 0;
    width: 100%; height: 100vh;
    max-width: 1440px; max-height: 925px;
    overflow: hidden;
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */

.layout { display: grid; grid-template-columns: 1fr 1fr; height: 100%; }

.intro-section {
    background: linear-gradient(161deg, #7BABB5 9%, #116F7C 57%);
    color: #fff; padding: 60px 48px;
    display: flex; flex-direction: column; justify-content: center;
    max-height: 100%; overflow-y: auto;
}
.intro-section h1 { font-size: 2rem; margin: 0 0 20px; font-weight: normal; line-height: 1.3; }
.intro-section p  { font-size: 1.05rem; opacity: 0.92; margin: 0 0 16px; }
.intro-section .intro-logo { font-size: 1.3rem; font-weight: bold; letter-spacing: 0.05em; margin-bottom: 50px;}
.intro-logo img {max-width:200px;}
aside a { color:inherit }

.form-section {
    background: #fff;
    padding: 52px 48px; display: flex; align-items: flex-start; justify-content: center;
    max-height: 100%; overflow-y: auto;
}
.form-section > * { width: 100%; max-width: 460px; }

/* ── Step ───────────────────────────────────────────────────────────────────── */

.step { width: 100%; }
.step-hidden { display: none; }

.step-title    { font-size: 1.4rem; font-weight: normal; color: var(--verde-scuro); margin: 0 0 6px; }
.step-subtitle { font-size: 0.95rem; color: var(--grigio); margin: 0 0 28px; }
#step-insegnante a, #step-thankyou a { color: var(--verde); }

.msg-errore {
    background: #fdf0f0; border-left: 3px solid var(--errore);
    color: var(--errore); padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 20px; font-size: 0.9rem; display: none;
}
.msg-errore a { color:var(--verde); }

/* ── Form ───────────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label { display: block; font-size: 0.88rem; color: var(--grigio); margin-bottom: 5px; }

input[type="text"], input[type="tel"], input[type="email"], select {
    width: 100%; padding: 10px 13px;
    border: 1px solid #c8c0b4;
    border-radius: var(--radius);
    background: var(--beige);
    color: var(--testo);
    font-family: var(--font); font-size: 0.97rem;
    transition: border-color 0.2s; appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--verde); }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M0 0l6 7 6-7z' fill='%230A7888'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}

.sesso-group { display: flex; gap: 20px; align-items: center; padding-top: 4px; }
.sesso-group label { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 0.97rem; color: var(--testo); margin: 0; }
.sesso-group input[type="radio"] { accent-color: var(--verde); width: 17px; height: 17px; cursor: pointer; }

/* ── Pulsanti ───────────────────────────────────────────────────────────────── */

.btn {
    display: inline-block; padding: 12px 28px; border: none;
    border-radius: var(--radius); font-family: var(--font); font-size: 1rem;
    cursor: pointer; transition: background 0.2s, transform 0.1s; text-decoration: none;
}
.btn:active { transform: scale(0.98); }

.btn-primario { background: var(--verde); color: #fff; width: 100%; margin-top: 8px; }
.btn-primario:hover { background: var(--verde-scuro); }

.btn-secondario { background: var(--beige-scuro); color: var(--testo); }
.btn-secondario:hover { background: #ddd6cc; }

.btn-outline { background: transparent; border: 1px solid var(--verde); color: var(--verde); }
.btn-outline:hover { background: var(--beige); }

/* ── Lista lezioni ──────────────────────────────────────────────────────────── */

#lezioni-container { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }

/* Card in azzurro ghiaccio su sfondo sabbia — contrasto caldo/freddo */
.lezione-card {
    border: 1px solid #b0d9e2; border-radius: var(--radius); padding: 16px 20px;
    cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
    background: #D6F1F5;
}
.lezione-card:hover { border-color: var(--verde); box-shadow: var(--shadow); }

.lezione-corso    { font-size: 1.05rem; font-weight: bold; color: var(--verde-scuro); margin-bottom: 4px; }
.lezione-dettagli { font-size: 0.9rem; color: #4e7a82; }
.lezione-note     { font-size: 0.85rem; color: var(--verde); margin-top: 6px; }
.lezioni-vuote    { color: var(--grigio); font-style: italic; margin-top: 16px; }

/* ── Step SMS error ─────────────────────────────────────────────────────────── */

.sms-error-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

/* ── Step ringraziamento ────────────────────────────────────────────────────── */

#step-thankyou { text-align: center; padding: 20px 0; }
#step-thankyou .icona-ok { font-size: 3rem; margin-bottom: 16px; }
#step-thankyou h2 { color: var(--verde-scuro); font-weight: normal; margin-bottom: 12px; }
#step-thankyou p  { color: var(--grigio); margin-bottom: 24px; }

/* ── Dialog ─────────────────────────────────────────────────────────────────── */

dialog {
    border: none; border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    padding: 36px; max-width: 420px; width: 90%;
    font-family: var(--font); color: var(--testo);
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog h3 { margin: 0 0 12px; font-weight: normal; color: var(--verde-scuro); font-size: 1.2rem; }
dialog p  { margin: 0 0 24px; font-size: 0.97rem; color: var(--grigio); }

/* Dialog riepilogo in azzurro ghiaccio — richiama le card lezioni */
#dialog-riepilogo {
    background: #D6F1F5; border-radius: var(--radius);
    padding: 14px 18px; margin-bottom: 24px; font-size: 0.97rem;
}
#dialog-riepilogo strong { color: var(--verde-scuro); display: block; margin-bottom: 4px; }
.dialog-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ── Spinner ────────────────────────────────────────────────────────────────── */

.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,0.4); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite;
    vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile ─────────────────────────────────────────────────────────────────── */

/* ── Privacy checkbox ───────────────────────────────────────────────────────── */

.privacy-check-group { margin-top: 8px; }
.privacy-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 0.92rem; color: var(--testo); }
.privacy-label input[type="checkbox"] { accent-color: var(--verde); width: 17px; height: 17px; flex-shrink: 0; margin-top: 2px; cursor: pointer; }
.privacy-label a { color: var(--verde); text-decoration: underline; }

.btn:disabled { opacity: 0.45; }

/* Stato "consenso mancante": stesso aspetto del disabled ma cliccabile (gestito in JS) */
.btn-primario.needs-consent { opacity: 0.45; cursor: not-allowed; }
.btn-primario.needs-consent:hover { background: var(--verde); }

/* Shake + glow del gruppo privacy quando l'utente prova a inviare senza consenso */
.privacy-check-group { border-radius: 6px; padding: 4px; margin-left: -4px; margin-right: -4px; }
.privacy-check-group.shake {
    animation: ss-consent-shake 0.4s ease-in-out, ss-consent-glow 0.9s ease-out;
}
@keyframes ss-consent-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
@keyframes ss-consent-glow {
    0%   { box-shadow: 0 0 0 0 rgba(176, 64, 64, 0.55); background: rgba(176, 64, 64, 0.08); }
    40%  { box-shadow: 0 0 0 8px rgba(176, 64, 64, 0.18); background: rgba(176, 64, 64, 0.10); }
    100% { box-shadow: 0 0 0 0 rgba(176, 64, 64, 0); background: transparent; }
}

/* ── Dialog privacy ─────────────────────────────────────────────────────────── */

#dialog-privacy { max-width: 580px; }
#privacy-content { max-height: 55vh; overflow-y: auto; margin-bottom: 20px; font-size: 0.9rem; line-height: 1.55; }
#privacy-content h4 { margin: 14px 0 4px; color: var(--verde-scuro); font-size: 0.95rem; font-weight: bold; }
#privacy-content p  { margin: 0 0 8px; }
#privacy-content ul { margin: 0 0 8px; padding-left: 18px; }
#privacy-content li { margin-bottom: 4px; color: var(--grigio); }
dialog a { color: var(--verde); }

.form-header-mobile { display: none; }
.form-header-mobile img { width: 100%; }

@media (max-height: 720px) {
    .form-group { margin-bottom: 6px; }
    label { margin-bottom: 1px; }
}

@media (max-width: 768px) {
    .intro-section { display: none; }
    .layout { grid-template-columns: 1fr; }
    .form-section { padding: 32px 20px; }
    .form-row { display: block; }
    dialog { padding: 24px 20px; }
    .form-header-desktop { display: none; }
    .form-header-mobile { display: block; }
}

/* ── Cookie banner ──────────────────────────────────────────────────────────── */
#cookie_banner {
    position: fixed; bottom: 0; left: 0; width: 100%; z-index: 100000;
    background-color: rgba(244, 241, 237, .9);
    box-shadow: 0 0 2em rgba(0,0,0,0.4);
    color: var(--testo);
}
.cookie-banner-text {
    max-width: 1400px; width: 80%; margin: 1.5em auto;
    text-align: center; font-size: 1em; line-height: 1.5em;
}
.cookie-banner-text a { color: var(--verde); }
.cookie-banner-actions { text-align: center; margin: 0 0 1.5em; }
#btnokcook, #btnkocook {
    border: none; border-radius: var(--radius);
    font-family: var(--font); font-size: 1rem;
    cursor: pointer; padding: 8px 20px; margin: 0 .4em;
    transition: background 0.2s;
}
#btnokcook { background: var(--verde); color: #fff; font-weight: 600; }
#btnokcook:hover { background: var(--verde-scuro); }
#btnkocook { background: var(--beige-scuro); color: var(--testo); }
#btnkocook:hover { background: #ddd6cc; }
