/* ================================================================
   MODALITÀ CATORCIO 🛺 — attiva con body.catorcio
   Versione super-ottimizzata per telefoni vecchi:
   - zero animazioni e transizioni CSS
   - zero backdrop-filter (blur = killer GPU sui device datati)
   - zero filtri/ombre testo decorative
   - sfondi solidi al posto delle trasparenze
   Le funzioni dell'app restano identiche: cambia solo la resa visiva.
   Caricato DOPO gli altri CSS così vince la cascata.
   ================================================================ */

/* 1) Stop ad animazioni e transizioni — tecnica "reduced motion":
      durate quasi-zero invece di `none`, così gli eventi transitionend /
      animationend SCATTANO ancora (i toast si auto-rimuovono dal DOM,
      il glint WRAP si pulisce). `none` li sopprimerebbe e i nodi
      resterebbero appesi per sempre. */
body.catorcio *,
body.catorcio *::before,
body.catorcio *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
    text-shadow: none !important;
    /* box-shadow = paint costoso: su header e bottom-nav (position:fixed) viene
       ridipinto a OGNI frame di scroll. Spento ovunque → scroll fluido sui device
       vecchi. Lo sfondo solido (sezione 3) garantisce comunque la leggibilità.
       Nota: i focus-ring fatti con box-shadow spariscono; quelli con `outline`
       (default) restano. */
    box-shadow: none !important;
    /* backdrop-filter universale: copre tutti i 46 punti senza dover elencare
       ogni selettore (la lista esplicita sotto resta per i casi a specificità
       alta con !important nei CSS iniettati). */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    /* will-change tiene viva una compositor-layer (consuma RAM/GPU): sui telefoni
       a poca memoria è un freno. Azzerato ovunque. */
    will-change: auto !important;
}

/* Animazioni dichiarate con shorthand !important altrove (solo decorative,
   nessun listener agganciato): qui serve specificità più alta e `none` è sicuro */
html body.catorcio.design-wrap .design-switch button.on,
html body.catorcio .dev-scanline,
html body.catorcio .dev-cursor {
    animation: none !important;
}

/* 2) Niente blur: backdrop-filter spento ovunque (alta specificità per
      battere le regole !important di css/03.css e degli stili iniettati) */
html body.catorcio .card,
html body.catorcio.dark-theme .card,
html body.catorcio header,
html body.catorcio.dark-theme header,
html body.catorcio .bottom-nav,
html body.catorcio.dark-theme .bottom-nav,
html body.catorcio .modal-content,
html body.catorcio.dark-theme .modal-content,
html body.catorcio .modal,
html body.catorcio .toast,
html body.catorcio.dark-theme .toast,
html body.catorcio .flatpickr-calendar,
html body.catorcio.dark-theme .flatpickr-calendar,
html body.catorcio .welcome-modal-content,
html body.catorcio .import-preview-content,
html body.catorcio .calendar-header,
html body.catorcio.design-wrap .card,
html body.catorcio.design-wrap .modal {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* 3) Sfondi solidi DISTINTI dallo sfondo pagina + bordo netto.
   PROBLEMA risolto qui: --md-sys-color-surface coincide con lo sfondo del body
   (entrambi #e4e9f2), quindi senza ombra le card sparivano. Diamo un fondo che
   contrasta davvero (bianco in chiaro) e un bordo da 1px: il bordo si dipinge
   senza blur (costo ~zero) e ridà i contorni persi con la box-shadow. */
html body.catorcio .card {
    background-color: #ffffff !important;
    border: 1px solid rgba(0,0,0,0.12) !important;
}
html body.catorcio.dark-theme .card {
    background-color: #1a1a2e !important;
    border: 1px solid rgba(255,255,255,0.14) !important;
}
html body.catorcio.design-wrap .card {
    background: var(--wrap-sheet, #ffffff) !important;
    border: 1px solid rgba(0,0,0,0.10) !important;
}

/* 3b) Header e bottom-nav: l'ombra li staccava dal contenuto, ora un bordo */
html body.catorcio header {
    border-bottom: 1px solid rgba(0,0,0,0.12) !important;
}
html body.catorcio.dark-theme header {
    border-bottom: 1px solid rgba(255,255,255,0.12) !important;
}
html body.catorcio .bottom-nav {
    border-top: 1px solid rgba(0,0,0,0.12) !important;
}
html body.catorcio.dark-theme .bottom-nav {
    border-top: 1px solid rgba(255,255,255,0.12) !important;
}

/* 3c) Modali, popup e calendario: bordo per staccarli dallo sfondo */
html body.catorcio .modal-content,
html body.catorcio .welcome-modal-content,
html body.catorcio .import-preview-content,
html body.catorcio .flatpickr-calendar,
html body.catorcio .cantieri-modal-content {
    border: 1px solid rgba(0,0,0,0.15) !important;
}
html body.catorcio.dark-theme .modal-content,
html body.catorcio.dark-theme .welcome-modal-content,
html body.catorcio.dark-theme .import-preview-content,
html body.catorcio.dark-theme .flatpickr-calendar,
html body.catorcio.dark-theme .cantieri-modal-content {
    border: 1px solid rgba(255,255,255,0.16) !important;
}

/* 4) Niente filtri decorativi (drop-shadow glow su icone nav, glitch, ecc.) */
body.catorcio .nav-item.active .material-symbols-outlined,
body.catorcio .material-symbols-outlined,
body.catorcio img,
body.catorcio svg {
    filter: none !important;
}

/* 5) Scenografia WRAP: pura decorazione, via.
      NB: .wgl (glint sui bottoni) NON va in display:none — si auto-rimuove
      con animationend, che su elementi display:none non scatterebbe mai
      (accumulo di nodi nel DOM). Con la durata 0.01ms è comunque invisibile. */
body.catorcio .wrap-scene,
body.catorcio .wrap-pageglint,
body.catorcio .wrap-scrap {
    display: none !important;
}
body.catorcio .wgl {
    opacity: 0 !important;
}

/* 6) Logo fermo (l'animazione è già spenta, evita anche will-change inutile) */
body.catorcio .bouncing-logo,
body.catorcio .bouncing-logo-excited {
    will-change: auto !important;
    transform: none !important;
}

/* 7) Hover/effetti "vivi" disattivati (su touch vecchi causano repaint inutili) */
body.catorcio .card:hover {
    box-shadow: none !important;
}

/* 8) Sfondo aurora scuro: resta il gradiente ma statico e senza fixed
      (background-attachment: fixed forza repaint a ogni scroll su Android vecchi) */
html body.catorcio.dark-theme,
html body.catorcio.design-wrap.dark-theme {
    background-attachment: scroll !important;
}
