/* motion.css — M32: animazioni carine OVUNQUE.
   Decisione dell'autore (03/11/2026, richiesta 45): il movimento è parte del
   prodotto, sempre acceso, anche con «riduci movimento» nel sistema. Per
   questo qui non esiste alcun blocco prefers-reduced-motion e non deve
   comparirne uno in nessun altro CSS: la descrizione testuale (aria-label
   sugli elementi grafici che si muovono) sostituisce l'interruttore.
   Regole di costruzione:
   - le entrate usano animation-fill-mode: backwards, MAI both/forwards:
     un transform lasciato in vigore a fine animazione batterebbe l'hover
     e creerebbe un contenitore per gli elementi position: fixed;
   - niente stili inline (CSP style-src 'self'): ritardi e progressi passano
     da variabili CSS impostate via CSSOM da motion.js. */

:root {
  --m-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --m-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --m-step: 70ms;
}

@keyframes m-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes m-fade {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

@keyframes m-pop {
  0% { opacity: 0; transform: scale(0.92); }
  60% { opacity: 1; transform: scale(1.035); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes m-drop {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes m-ring {
  0% { box-shadow: var(--shadow-accent), 0 0 0 0 color-mix(in srgb, var(--color-accent) 40%, transparent); }
  70% { box-shadow: var(--shadow-accent), 0 0 0 16px transparent; }
  100% { box-shadow: var(--shadow-accent), 0 0 0 0 transparent; }
}

/* ---------- M33: la LUCE di chi parla ----------
   Bagliore arancione che respira. Riutilizzabile: .vs-glow su qualunque
   elemento (sedia, card attiva, idea nuova). Anima solo box-shadow e
   filter; il contenuto resta identico anche fermo (html.vs-calm), dove
   resta acceso il bagliore statico. Chi la usa su un elemento grafico
   aggiunge role="img" + aria-label che dice chi è illuminato e perché. */
@keyframes vs-glow {
  0%, 100% { box-shadow: var(--shadow-glow-soft); }
  50% { box-shadow: var(--shadow-glow); }
}

@keyframes vs-glow-in {
  0% { box-shadow: 0 0 0 0 rgba(var(--color-light-rgb), 0); filter: brightness(1); }
  40% { box-shadow: 0 0 0 10px rgba(var(--color-light-rgb), 0.35), 0 0 40px 12px rgba(var(--color-light-rgb), 0.35); filter: brightness(1.06); }
  100% { box-shadow: var(--shadow-glow-soft); filter: brightness(1); }
}

/* Bagliore continuo (chi ha la parola) */
.vs-glow {
  box-shadow: var(--shadow-glow);
  animation: vs-glow 2.4s ease-in-out infinite;
}

/* Lampo singolo (un'idea appena arrivata): si accende e si posa */
.vs-glow--once {
  box-shadow: var(--shadow-glow-soft);
  animation: vs-glow-in 1.4s var(--m-ease) backwards;
}

/* Luce ferma, senza respiro */
.vs-glow--still { box-shadow: var(--shadow-glow); animation: none; }

html.vs-calm .vs-glow { box-shadow: var(--shadow-glow); }

/* Entrata in profondità (3D leggero) per scene e pannelli */
@keyframes m-tilt-in {
  from { opacity: 0; transform: perspective(var(--perspective)) rotateX(10deg) translateY(18px); }
  to { opacity: 1; transform: perspective(var(--perspective)) rotateX(0) translateY(0); }
}

.m-tilt-in { animation: m-tilt-in 700ms var(--m-ease) backwards; animation-delay: calc(var(--m-i, 0) * var(--m-step)); }

@keyframes m-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-7px) rotate(0.8deg); }
}

/* L'alone che pulsa e gli spostamenti laterali escono dalla colonna: senza
   questo la landing scorreva di lato sul telefono (fino a 50 px). «clip» e
   non «hidden»: non crea un contenitore di scroll e lascia lo sticky. */
.app__main { overflow-x: clip; }

/* ---------- Entrata a scalare (motion.js) ---------- */

.m-pre { opacity: 0; }

.m-in {
  animation: m-rise 560ms var(--m-ease) backwards;
  animation-delay: calc(var(--m-i, 0) * var(--m-step));
}

/* Cambio pagina: dissolvenza leggera sul contenitore, i figli salgono. */
main.m-page { animation: m-fade 260ms ease backwards; }

/* ---------- Barra di avanzamento della pagina ---------- */

.m-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  background: linear-gradient(90deg, var(--color-accent), var(--color-light));
  box-shadow: 0 0 12px rgba(var(--color-light-rgb), 0.6);
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
}

/* ---------- Bottoni ---------- */

.button {
  transition: transform 160ms var(--m-ease), box-shadow 220ms ease,
    background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.button:not(:disabled):hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.button:not(:disabled):active { transform: translateY(0) scale(0.97); box-shadow: none; }

/* Primario: al passaggio il bagliore arancione si allarga e si alza. */
.button--primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent), 0 0 0 4px color-mix(in srgb, var(--color-accent) 18%, transparent);
}

/* Il bottone principale: riflesso che scorre al passaggio. */
.button--primary { position: relative; overflow: hidden; }

.button--primary::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
  transform: translateX(-130%);
  pointer-events: none;
}

.button--primary:not(:disabled):hover::after {
  transform: translateX(130%);
  transition: transform 750ms ease;
}

/* La porta d'ingresso della home respira un anello, piano, ogni tanto. */
.site-cta { animation: m-ring 3.8s ease-out 2s infinite; }

/* ---------- Card e righe ---------- */

.project-card,
.game-card,
.format-card,
.phase-card,
.history-item,
.capture-item {
  transition: transform 220ms var(--m-ease), box-shadow 260ms ease, border-color 200ms ease;
}

.project-card:hover,
.game-card:hover,
.format-card:hover,
.phase-card:hover,
.history-item:hover,
.capture-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }

.project-card:active,
.game-card:active,
.format-card:active,
.phase-card:active { transform: translateY(-1px) scale(0.985); }

.phase-nav-item { transition: transform 200ms var(--m-ease), background-color 200ms ease, color 200ms ease; }
.phase-nav-item:hover { transform: translateX(4px); }

.task-row,
.kpi-row,
.origin-step { transition: background-color 220ms ease, transform 220ms var(--m-ease); }
.task-row:hover,
.origin-step:hover { transform: translateX(3px); }

/* ---------- Pillole, filtri, controlli ---------- */

.game-pill,
.rc-chip {
  transition: transform 160ms var(--m-spring), background-color 200ms ease,
    border-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

.game-pill:not(:disabled):hover { transform: translateY(-2px); }
.game-pill:not(:disabled):active { transform: scale(0.94); }
.game-pill[aria-pressed="true"] { animation: m-pop 340ms var(--m-spring) backwards; }

/* Campi di testo: il fuoco si accende con un alone morbido. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
  transition: box-shadow 220ms ease, border-color 200ms ease, background-color 200ms ease;
}

input:focus,
textarea:focus,
select:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 18%, transparent); }

/* Card generiche: si sollevano e prendono un filo d'arancione. */
.card { transition: transform 220ms var(--m-ease), box-shadow 260ms ease, border-color 200ms ease; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.card--active:hover,
.card[aria-current="true"]:hover { box-shadow: var(--shadow-lift), var(--shadow-glow-soft); }

/* ---------- Messaggi e pannelli che compaiono ---------- */

.notice-line:not([hidden]),
[role="status"]:not([hidden]):not(:empty),
.game-reveal:not([hidden]) { animation: m-rise 420ms var(--m-ease) backwards; }

details[open] > :not(summary) { animation: m-drop 320ms var(--m-ease) backwards; }

.aiuto-pop:not([hidden]) { animation: m-pop 240ms var(--m-spring) backwards; }
.aiuto { transition: transform 180ms var(--m-spring), background-color 200ms ease, color 200ms ease; }
.aiuto:hover { transform: scale(1.12); }
.aiuto:active { transform: scale(0.94); }

/* ---------- Atmosfera ---------- */

.blot-panel { animation: m-float 8s ease-in-out infinite; }
.site-nav a { transition: color 200ms ease, border-color 200ms ease, transform 180ms var(--m-ease); }
.site-nav a:hover { transform: translateY(-1px); }
.site-card__go,
.site-hero__more { display: inline-block; transition: transform 200ms var(--m-ease); }
.site-card:hover .site-card__go,
.site-hero__more:hover { transform: translateX(5px); }
.app__brand { display: inline-block; transition: transform 240ms var(--m-spring); }
.app__brand:hover { transform: scale(1.04) rotate(-1deg); }

/* ---------- Interruttore «Animazioni» ----------
   L'unico modo in cui il movimento si ferma: lo sceglie l'utente, non il
   sistema. Con .vs-calm su <html> ogni animazione e transizione è spenta;
   gli elementi in attesa di entrare restano comunque visibili. */

/* Leva: il blu è ammesso solo qui e sui misuratori. */
.motion-toggle, .motion-toggle:hover { gap: var(--space-1); color: var(--color-meter); }
.motion-toggle[aria-pressed="false"] { color: var(--color-text-soft); }
.motion-toggle__icon { display: inline-block; color: var(--color-meter); animation: m-twinkle 3.2s ease-in-out infinite; transition: transform 300ms var(--m-spring); }
.motion-toggle:hover .motion-toggle__icon { transform: rotate(72deg) scale(1.15); }
.motion-toggle[aria-pressed="false"] .motion-toggle__icon { color: var(--color-text-soft); }

@media (max-width: 719px) {
  .motion-toggle__label { display: none; }
}

@keyframes m-twinkle {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.22); opacity: 0.7; }
}

html.vs-calm *,
html.vs-calm *::before,
html.vs-calm *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
