/* Motion: short, cheap (opacity and transform only), and switched off by prefers-reduced-motion in base.css. */

@keyframes fade { from { opacity: 0; } }
@keyframes pop  { from { opacity: 0; transform: scale(0.94); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-out { to { opacity: 0; transform: scale(0.96) translateY(6px); } }
@keyframes slide-out { to { opacity: 0; transform: translateX(18px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(28px) scale(0.96); } }

/* Pages and their cards ease in, one after another. */
.card { animation: rise 0.3s var(--ease-out) both; }
.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(n+4) { animation-delay: 0.12s; }

dialog[open] { animation: pop 0.28s var(--ease-spring); }
dialog[open]::backdrop { animation: fade 0.15s var(--ease-out); }
.toast { animation: slide-in 0.35s var(--ease-spring); }

button, .choice-btn, .rail-q { transition: background-color 0.12s, color 0.12s, filter 0.12s, opacity 0.12s, transform 0.08s; }
button:active:not(:disabled) { transform: scale(0.97); }
button { transition-property: background-color, color, filter, opacity, transform, border-color; }

/* The exam: a new question fades in; options respond to being picked and crossed out. */
.exam-panels { animation: fade 0.16s var(--ease-out); }
.choice { transition: background-color 0.15s, color 0.15s, opacity 0.15s; }
.choice.selected { animation: pop 0.32s var(--ease-spring); }
.rail-q.current { transition: outline-color 0.15s; }

/* The result: the competence bars and the "Where everyone is" cells fill in. */
.meter > span { transform-origin: left; animation: grow 0.7s var(--ease-out) both; }
.score { animation: pop 0.35s var(--ease-out) both; }
.gist { font-size: 0.85rem; margin: 0.1rem 0 0.3rem; line-height: 1.35; }

/* More life on the exam screen and around it. */
.exam-shell { animation: fade 0.25s var(--ease-out); }
.rail-q { animation: pop 0.25s var(--ease-out) both; }
.rail-q:nth-child(2) { animation-delay: 0.03s; } .rail-q:nth-child(3) { animation-delay: 0.06s; } .rail-q:nth-child(4) { animation-delay: 0.09s; }
.rail-q:nth-child(5) { animation-delay: 0.12s; } .rail-q:nth-child(n+6) { animation-delay: 0.15s; }
.rail-q:hover { transform: translateY(-2px); }
.choice-btn { transition: background-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.12s; }
.choice:hover .choice-btn:not(:disabled) { transform: translateX(3px); }
.choice-x { transition: opacity 0.15s; }
.dock-hint { animation: fade 0.12s var(--ease-out); transition: left 0.15s, right 0.15s, top 0.15s, bottom 0.15s, width 0.15s, height 0.15s; }
.exam-split::after { transition: background-color 0.15s; }
.lcd.low { animation: pulse-opacity 1s ease-in-out infinite; }
@keyframes pulse-opacity { 50% { opacity: 0.55; } }

/* Elsewhere: cards and tiles lift a little under the pointer, rows and badges fade in. */
.stat, .btn { transition: transform 0.12s, background-color 0.12s, border-color 0.12s; }
a.stat:hover { transform: translateY(-2px); }
.badge, .chip{ animation: pop 0.2s var(--ease-out) both; }
.presence-dot { animation: pulse-opacity 2s ease-in-out infinite; }
.presence.away .presence-dot, .presence.idle .presence-dot { animation: none; }

/* A page that has already shown its content does not replay the entrance animations when it refreshes. */
.settled, .settled .card, .settled .stat, .settled .plain-list > li, .settled .live-row, .settled .badge, .settled .chip, .settled .meter > span, .settled .score { animation: none !important; }

/* ---- dropdowns and disclosures ---- */
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } }

/* Menus (nav groups, "+ Novo", the user menu) drop down from their button. */

/* Details that unfold in the page: the answers under the score, "Nova matriz". */
details > summary { transition: color 0.12s; }
details > summary:hover { color: var(--accent); }

/* Where the browser allows it, closing eases too (details content can be transitioned in newer browsers). */
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
}

/* Selects and fields respond to focus and hover instead of snapping. */
select, input, textarea { transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s; }
select:hover, input:hover:not([type="checkbox"]), textarea:hover { border-color: var(--accent); }
select:focus-visible, input:focus-visible, textarea:focus-visible { box-shadow: inset 0 0 0 1px var(--accent); }

/* Navigation: the current-page underline grows, links ease their colour. */

/* Toasts leave as well as arrive; checkboxes and chips respond. */
.toast { animation: slide-in 0.2s var(--ease-out); }
.check:hover, .chip:hover { filter: brightness(0.96); }
 .chip, .check { transition: filter 0.12s; }
a { transition: color 0.12s; }

/* ---- leaving is animated too ---- */
dialog.closing { animation: pop-out 0.18s var(--ease-out) forwards; }
dialog.closing::backdrop { animation: fade-out 0.18s var(--ease-out) forwards; }
.toast.closing { animation: slide-out 0.22s var(--ease-out) forwards; }

/* ---- pages cross-fade (View Transitions, where the browser has them). The header stays put. ---- */
.site-header { view-transition-name: site-header; }
::view-transition-group(root) { animation-duration: 0.28s; }
::view-transition-old(root) { animation: fade-out 0.1s ease both; }
::view-transition-new(root) { animation: fade-in 0.16s ease both; }
@keyframes fade-in { from { opacity: 0; } }

/* ---- loading: a skeleton with a soft shimmer instead of a line of text ---- */
.loading { display: grid; gap: 0.7rem; padding: 0.4rem 0; opacity: 0; animation: show 0.2s ease 0.3s forwards; }
@keyframes show { to { opacity: 1; } }
.sk-line, .sk-block { position: relative; overflow: hidden; background: var(--surface-2); }
.sk-line { height: 1rem; }
.sk-title { width: 40%; height: 1.4rem; }
.sk-short { width: 65%; }
.sk-block { height: 6rem; }
.sk-line::after, .sk-block::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 45%), transparent);
  animation: shimmer 1.3s ease-in-out infinite;
}
[data-theme="dark"] .sk-line::after, [data-theme="dark"] .sk-block::after { background: linear-gradient(90deg, transparent, rgb(255 255 255 / 10%), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---- small feel-good details ---- */
.stat { transition: transform 0.25s var(--ease-spring), border-color 0.15s, background-color 0.15s; }
a.stat:hover { transform: translateY(-3px); border-color: var(--accent); }
a.stat:active { transform: translateY(-1px) scale(0.99); }
.card { transition: border-color 0.2s; }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary { transition: transform 0.2s var(--ease-spring), opacity 0.15s, background-color 0.15s; }
.choice-btn:active:not(:disabled) { transform: scale(0.99); }
.rail-q:active { transform: scale(0.94); }
.rail-q.answered { transition: background-color 0.3s var(--ease-out), transform 0.2s var(--ease-spring); }
.dd-item { transition: background-color 0.1s; }
.dd-list { animation: drop 0.18s var(--ease-out); transform-origin: top; }
.dd.up ~ .dd-list, .dd-list.up { transform-origin: bottom; }
