/* =====================================================================
   Vettore — movimento. Stessi colori e stessa struttura di prima: qui si aggiungono solo transizioni e animazioni
   (entrata delle pagine, menu, icone, pulsanti, card, liste, campi, finestre). Con «riduci movimento» attivo nel sistema è tutto spento.
   ===================================================================== */

:root {
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-molla: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- passaggio da una pagina all'altra (dissolvenza incrociata, dove il browser la supporta) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: gb-esce .16s ease-in both; }
::view-transition-new(root) { animation: gb-entra .34s var(--ease-out) both; }
@keyframes gb-esce { to { opacity: 0; transform: translateY(-4px); } }
@keyframes gb-entra { from { opacity: 0; transform: translateY(10px); } }

/* ---------- barra di caricamento in alto mentre si cambia pagina ---------- */
.gb-barra { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 9999; background: var(--accent); transform-origin: left; animation: gb-barra 1.2s var(--ease-out) infinite; pointer-events: none; }
@keyframes gb-barra { 0% { transform: scaleX(0); opacity: 1; } 70% { transform: scaleX(.85); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* ---------- entrata della pagina: ogni blocco sale e compare uno dopo l'altro ---------- */
main > .container { animation: none; }
main > .container > * { animation: gb-sale .55s var(--ease-out) both; }
main > .container > *:nth-child(2) { animation-delay: .05s; } main > .container > *:nth-child(3) { animation-delay: .1s; }
main > .container > *:nth-child(4) { animation-delay: .15s; } main > .container > *:nth-child(5) { animation-delay: .2s; }
main > .container > *:nth-child(6) { animation-delay: .25s; } main > .container > *:nth-child(7) { animation-delay: .3s; }
main > .container > *:nth-child(n+8) { animation-delay: .34s; }
@keyframes gb-sale { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.page-header h1 { animation: gb-scorri .6s var(--ease-out) both; }
.page-header .eyebrow { display: inline-block; animation: gb-scorri .5s .05s var(--ease-out) both; }
.page-header p { animation: gb-scorri .6s .12s var(--ease-out) both; }
@keyframes gb-scorri { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

/* elementi sotto la piega: compaiono quando ci si arriva con lo scorrimento (la classe la mette animazioni.js) */
.gb-rv { opacity: 0; transform: translateY(22px); animation: none !important; transition: opacity .6s var(--ease-out), transform .6s var(--ease-out); }
.gb-rv.visto { opacity: 1; transform: none; }

/* elenchi: le righe entrano a cascata */
.news-list > *, .rows > *, .data-list > *, .req-row, .report-row, .mod-row, .day-events > li, .event-list > *, .my-loan, .queue > * { animation: gb-sale .45s var(--ease-out) both; }
.news-list > *:nth-child(2), .rows > *:nth-child(2), .data-list > *:nth-child(2), .event-list > *:nth-child(2), .queue > *:nth-child(2) { animation-delay: .04s; }
.news-list > *:nth-child(3), .rows > *:nth-child(3), .data-list > *:nth-child(3), .event-list > *:nth-child(3), .queue > *:nth-child(3) { animation-delay: .08s; }
.news-list > *:nth-child(4), .rows > *:nth-child(4), .data-list > *:nth-child(4), .event-list > *:nth-child(4), .queue > *:nth-child(4) { animation-delay: .12s; }
.news-list > *:nth-child(5), .rows > *:nth-child(5), .data-list > *:nth-child(5), .event-list > *:nth-child(5), .queue > *:nth-child(5) { animation-delay: .16s; }
.news-list > *:nth-child(n+6), .rows > *:nth-child(n+6), .data-list > *:nth-child(n+6), .event-list > *:nth-child(n+6), .queue > *:nth-child(n+6) { animation-delay: .2s; }
.news-list > *, .rows > *, .data-list > *, .req-row, .report-row, .mod-row, .event-list > *, .queue > * { transition: background .22s, transform .25s var(--ease-out), border-color .22s; }
.news-list > *:hover, .rows > *:hover, .data-list > *:hover, .req-row:hover, .report-row:hover, .mod-row:hover, .event-list > *:hover { transform: translateX(3px); }
tbody tr { transition: background .2s; }

/* ---------- menu laterale ---------- */
.sb-link { transition: background .22s, color .22s, transform .28s var(--ease-out); animation: gb-sx .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 28ms); }
@keyframes gb-sx { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.sb-link:hover { transform: translateX(4px); }
.sb-link:active { transform: translateX(2px) scale(.98); }
.sb-link .ic { transition: transform .35s var(--ease-molla); }
.sb-link:hover .ic { transform: scale(1.18) rotate(-8deg); }
.sb-link.active::before { transform-origin: center; animation: gb-barra-attiva .5s var(--ease-molla) both; }
@keyframes gb-barra-attiva { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.sb-link.active .ic { animation: gb-rimbalzo .6s var(--ease-molla) .15s both; }
@keyframes gb-rimbalzo { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.sb-count { animation: gb-pop-badge .55s var(--ease-molla) both, gb-pulsa 2.6s ease-in-out 1s infinite; }
@keyframes gb-pop-badge { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes gb-pulsa { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-tint); } 50% { box-shadow: 0 0 0 6px transparent; } }
.sb-group > .sb-sub { animation: gb-apre .35s var(--ease-out) both; transform-origin: top; }
@keyframes gb-apre { from { opacity: 0; transform: translateY(-6px) scaleY(.92); } to { opacity: 1; transform: none; } }
.sb-user { transition: background .22s, transform .25s var(--ease-out); } .sb-user:hover { transform: translateX(3px); }
@media (max-width: 899px) {
  .sidebar { transition: transform .42s var(--ease-out); }
  .scrim { transition: opacity .35s; }
  body.drawer-open .sb-link { animation: gb-sx .45s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms + .08s); }
}

/* ---------- barra in alto, icone e pulsanti ---------- */
.iconbtn, .menu-btn { transition: background .22s, border-color .22s, color .22s, transform .25s var(--ease-molla); }
.iconbtn:hover, .menu-btn:hover { transform: translateY(-1px) scale(1.06); }
.iconbtn:active, .menu-btn:active { transform: scale(.9); }
.iconbtn .ic, .menu-btn .ic { transition: transform .4s var(--ease-molla); }
.iconbtn:hover .ic { transform: rotate(12deg); }
.theme-corner.gira .ic { animation: gb-gira .6s var(--ease-molla); }
@keyframes gb-gira { from { transform: rotate(-180deg) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.search-pill { transition: border-color .25s, background .25s, transform .25s var(--ease-out), box-shadow .3s; } .search-pill:hover { transform: translateY(-1px); }

.vt-btn, .btn { position: relative; overflow: hidden; transition: transform .2s var(--ease-out), background .22s, border-color .22s, color .22s, box-shadow .3s; }
.vt-btn:hover, .btn:hover { transform: translateY(-1px); }
.vt-btn:active, .btn:active { transform: translateY(0) scale(.97); }
.vt-btn-primary:hover, .btn-primary:hover { box-shadow: 0 8px 20px -8px var(--accent); }
.vt-btn .ic, .btn .ic { transition: transform .35s var(--ease-molla); }
.vt-btn:hover .ic, .btn:hover .ic { transform: scale(1.15) translateX(1px); }
.gb-ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .25; transform: scale(0); animation: gb-onda .6s ease-out forwards; }
@keyframes gb-onda { to { transform: scale(1); opacity: 0; } }

/* ---------- card e riquadri ---------- */
.card { transition: border-color .25s, transform .3s var(--ease-out), box-shadow .3s, background .25s; }
.card:hover { border-color: var(--border-300); }
a.card, .card.tap, .tool-card, .link-tile, .stat-tile, .result-card, .tpl, .job-card, .pending-card, .sys-card, .tool, .summary-side { transition: transform .3s var(--ease-out), box-shadow .3s, border-color .25s, background .25s; }
a.card:hover, .card.tap:hover, .tool-card:hover, .link-tile:hover, .stat-tile:hover, .result-card:hover, .tpl:hover, .job-card:hover, .tool:hover { transform: translateY(-3px); box-shadow: 0 14px 28px -16px rgba(0, 0, 0, .55); border-color: var(--border-300); }
a.card:active, .card.tap:active, .tool-card:active, .link-tile:active { transform: translateY(-1px) scale(.99); }
.tool-card .ic, .link-tile .ic, .stat-tile .ic { transition: transform .4s var(--ease-molla); }
.tool-card:hover .ic, .link-tile:hover .ic, .stat-tile:hover .ic { transform: scale(1.2) rotate(-6deg); }
.book-card, .book-cover { transition: transform .35s var(--ease-out), box-shadow .35s; } .book-card:hover { transform: translateY(-4px) rotate(-.6deg); }

/* ---------- campi, interruttori, tab, chip ---------- */
.vt-input, input, select, textarea { transition: border-color .25s, box-shadow .3s, background .25s; }
.switch .slider, .switch .slider::before, .toggle-row .toggle { transition: background .3s, transform .35s var(--ease-molla), border-color .3s; }
.seg button, .tabs a, .tabs button, .chip, .chips > * { transition: background .25s, color .25s, border-color .25s, transform .2s var(--ease-molla); }
.chip:hover, .chips > *:hover { transform: translateY(-1px); } .chip:active, .chips > *:active { transform: scale(.94); }
.seg button:active, .tabs a:active { transform: scale(.96); }
.status-pill, .count-pill, .avg-pill { animation: gb-pop-badge .5s var(--ease-molla) both; }
.loan-bar > *, .task-bar > *, .onb-bar > *, .task-progress > * { transition: width .9s var(--ease-out); }

/* ---------- avvisi, finestre, notifiche ---------- */
.alert { animation: gb-giu .45s var(--ease-out) both; }
@keyframes gb-giu { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.gb-dlg-back { animation: gb-fade .25s ease-out both; }
.gb-dlg { animation: gb-pop .38s var(--ease-molla) both; }
.palette { animation: gb-fade .22s ease-out both; }
.toast { animation: toast-in .4s var(--ease-molla) both; }

/* ---------- vuoto, onboarding, foto ---------- */
.empty .emoji, .empty-mini .ic { display: inline-block; animation: gb-fluttua 3.4s ease-in-out infinite; }
@keyframes gb-fluttua { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
.avatar, .sb-user .av, .profile-id img { transition: transform .35s var(--ease-molla); } .avatar:hover { transform: scale(1.08) rotate(3deg); }
.hero { animation: gb-sale .7s var(--ease-out) both; }
.timeline > *, .lessons > *, .lesson, .timetable tr { animation: gb-sale .45s var(--ease-out) both; }
.lesson { transition: transform .25s var(--ease-out), background .22s; } .lesson:hover { transform: translateX(4px); }
.cal-cell { transition: background .22s, transform .25s var(--ease-molla), border-color .22s; } .cal-cell:hover { transform: scale(1.06); }

/* ---------- rispetto per chi riduce il movimento ---------- */
@media (prefers-reduced-motion: reduce) {
  .gb-rv { opacity: 1; transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
