/* Motion for the whole site (2026-11-21, owner asked for transitions that feel
   professional, elegant and organic). One quiet vocabulary, in the spirit of
   Apple's: short, soft, decelerating - things settle into place rather than
   bounce. Nothing moves for its own sake, and a device set to reduce motion
   gets none of it.
     --mo-ease    general easing (decelerates)
     --mo-spring  sheets and pop-overs settling (iOS-style curve, no overshoot)
     --mo-fast    presses, colour changes   --mo  menus, fades   --mo-slow  windows */
:root {
  --mo-ease: cubic-bezier(.22, .61, .36, 1);
  --mo-spring: cubic-bezier(.32, .72, 0, 1);
  --mo-fast: 120ms;
  --mo: 180ms;
  --mo-slow: 320ms;
}

/* ── Controls: colour changes fade; a press sinks a touch ─────────────── */
button, .btn, .button, a.btn, a.button, [role="button"], [role="tab"], summary, .chip,
.tb-links a, .on-page a, .tool-tiles a, .free-links a, .wf-group a, .quick-actions a, .levels a, .site-results a, .tnav-menu a, .tnav-find-list a {
  transition: background-color var(--mo) var(--mo-ease), color var(--mo) var(--mo-ease), border-color var(--mo) var(--mo-ease),
    box-shadow var(--mo) var(--mo-ease), opacity var(--mo) var(--mo-ease), transform var(--mo-fast) var(--mo-ease);
}
button:active:not(:disabled), .btn:active, .button:active, [role="button"]:active, .tool-tiles a:active, .free-links a:active, .on-page a:active, .quick-actions a:active {
  transform: scale(.975);
  transition-duration: 60ms;
}
input, select, textarea { transition: border-color var(--mo) var(--mo-ease), box-shadow var(--mo) var(--mo-ease), background-color var(--mo) var(--mo-ease); }
a { transition: color var(--mo) var(--mo-ease), background-color var(--mo) var(--mo-ease); }

/* ── Windows: the backdrop fades, the panel rises and settles; and back ─ */
@keyframes mo-fade { from { opacity: 0; } }
@keyframes mo-rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }
@keyframes mo-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes mo-reveal { from { opacity: 0; transform: translateY(-3px); } }
[role="dialog"].open, .teacher-login-overlay { animation: mo-fade var(--mo) var(--mo-ease); }
[role="dialog"].open > :first-child, .teacher-login-overlay > :first-child { animation: mo-rise var(--mo-slow) var(--mo-spring); }
/* closing fades out too where the browser can animate display (no script change) */
@supports (transition-behavior: allow-discrete) {
  /* (the student app's windows, which all open with .open) */
  html[data-app="student"] [id$="-modal"][role="dialog"]:not(#progress-modal):not(.app-tab-panel *) {
    transition: opacity var(--mo) var(--mo-ease), display var(--mo) allow-discrete, overlay var(--mo) allow-discrete;
  }
  html[data-app="student"] [id$="-modal"][role="dialog"]:not(.open):not(#progress-modal):not(.app-tab-panel *) { opacity: 0; }
}

/* ── Menus, search results, pop-overs: unfold from where you clicked ─── */
.tnav-group.open > .tnav-menu, .site-results:not([hidden]), .tnav-find-list:not([hidden]), .ra-voice-menu, .tnav-header nav.tnav-open, header.site-header.nav-open nav, header.site-header.search-open .site-search {
  animation: mo-pop var(--mo) var(--mo-spring);
  transform-origin: top center;
}
.tnav-menu { transform-origin: top left; }

/* ── Switching what's shown: tabs, levels, folds - the new content fades in ─ */
.app-tab-panel.active, .tab-panel.active, section.level:not([hidden]), .view.active, #tb-browse:not([hidden]) {
  animation: mo-fade 220ms var(--mo-ease);
}
details[open] > :not(summary) { animation: mo-reveal 220ms var(--mo-ease); }
.check-result.ok, .check-result.no, [role="status"]:not(:empty) { animation: mo-fade 200ms var(--mo-ease); }

/* ── Between pages: a soft cross-fade; the header stays put ─────────────── */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 200ms; animation-timing-function: var(--mo-ease); }
header.site-header, .tnav-header, body > header { view-transition-name: site-header; }
::view-transition-group(site-header) { animation-duration: 0s; }

/* ── Light and dark: switching fades rather than flashes (set briefly by the switch) ─ */
html.theme-switching, html.theme-switching * { transition: background-color 280ms var(--mo-ease), color 280ms var(--mo-ease), border-color 280ms var(--mo-ease) !important; }

/* ── Reduce motion: none of it ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  @view-transition { navigation: none; }
}
@media print { *, *::before, *::after { animation: none !important; transition: none !important; } }
