/* Micro transitions across the platform: small, quick movements that answer what people do (hover, press, focus,
   open, close, arrive). Loaded last on every page, so it only adds motion and never changes layout or colours.
   Everything here stops for people who ask their computer for less motion (the block at the end). */

:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Pages arrive: the main blocks rise in, one after another. */
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }
main.page > *, main.workspace > *, .login-split > * { animation: rise-in 0.45s var(--ease-out) backwards; }
main.page > :nth-child(2), main.workspace > :nth-child(2), .login-split > :nth-child(2) { animation-delay: 0.05s; }
main.page > :nth-child(3), main.workspace > :nth-child(3) { animation-delay: 0.1s; }
main.page > :nth-child(4), main.workspace > :nth-child(4) { animation-delay: 0.15s; }
main.page > :nth-child(5) { animation-delay: 0.2s; }
main.page > :nth-child(n + 6) { animation-delay: 0.25s; }
/* Tiles count in one by one. */
.tiles > * { animation: rise-in 0.4s var(--ease-out) backwards; }
.tiles > :nth-child(2) { animation-delay: 0.04s; }
.tiles > :nth-child(3) { animation-delay: 0.08s; }
.tiles > :nth-child(4) { animation-delay: 0.12s; }
.tiles > :nth-child(n + 5) { animation-delay: 0.16s; }

/* Buttons lift a touch on hover and sink when pressed (splintr.css); primary ones glow a little. */
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn-primary:not(:disabled):hover { box-shadow: 0 6px 16px rgba(27, 58, 107, 0.22); }
.btn:not(:disabled):active { transform: translateY(1px) scale(0.985); transition-duration: 0.05s; }
.btn-ghost, .btn-secondary, .btn-link, .btn-sm { transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.12s var(--ease-out); }

/* Navigation: the current page's pill and hover colours ease in. */
.appnav .navlink { transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s var(--ease-out); }
.appnav a.navlink:active { transform: scale(0.97); }

/* Fields: the focus ring grows in rather than snapping on. */
.input, .select, .textarea, input[type="search"], textarea { transition: border-color 0.15s ease, box-shadow 0.2s var(--ease-out), background-color 0.15s ease; }
input[type="checkbox"], input[type="radio"] { transition: transform 0.12s var(--ease-spring); }
input[type="checkbox"]:active, input[type="radio"]:active { transform: scale(0.88); }

/* Cards and tiles that can be clicked lift on hover; table rows and chips ease their colours. */
.tile, .card { transition: box-shadow 0.2s ease, transform 0.2s var(--ease-out), border-color 0.2s ease; }
a.tile:hover, button.tile:hover, .tile.clickable:hover, a.card:hover, .card.clickable:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 29, 43, 0.1); }
table.data td { transition: background-color 0.15s ease; }
.chip, .badge, .gl-chip { transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s var(--ease-spring); }
.chip:active { transform: scale(0.95); }
.chip.is-active { animation: chip-pop 0.25s var(--ease-spring); }
@keyframes chip-pop { 50% { transform: scale(1.06); } }

/* Links: the underline colour eases in. */
a { transition: color 0.15s ease, text-decoration-color 0.15s ease; }

/* Folding sections: the content fades and slides in as it opens. */
details[open] > :not(summary) { animation: unfold 0.25s var(--ease-out); }
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } }

/* Toasts slide in with a little spring, and slide away when they go (js: .is-leaving). */
.toast { animation: toast-in 0.35s var(--ease-spring); transition: opacity 0.25s ease, transform 0.25s ease; }
.toast.is-leaving { opacity: 0; transform: translateX(16px); }
@keyframes toast-in { from { transform: translateY(10px) scale(0.98); opacity: 0; } }

/* Dialogs: the backdrop fades and the box scales up into place. */
.dlg-scrim { animation: fade-in 0.2s ease; }
.dlg { animation: pop-in 0.28s var(--ease-spring); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } }

/* The account menu drops open. */
.user-menu:not([hidden]) { animation: pop-in 0.2s var(--ease-out); transform-origin: top right; }

/* Less motion asked for: none of the above moves (spinners and other working signs elsewhere keep going). */
@media (prefers-reduced-motion: reduce) {
  main.page > *, main.workspace > *, .login-split > *, .tiles > *, .chip.is-active, details[open] > :not(summary),
  .toast, .dlg-scrim, .dlg, .user-menu:not([hidden]) { animation: none; }
  .btn, .tile, .card, .chip, .toast, .appnav .navlink, input[type="checkbox"], input[type="radio"] { transition: none; }
  .btn:not(:disabled):hover, .btn:not(:disabled):active, a.tile:hover, button.tile:hover, .tile.clickable:hover, a.card:hover, .card.clickable:hover,
  .chip:active, .appnav a.navlink:active, input[type="checkbox"]:active, input[type="radio"]:active { transform: none; }
}
