/*
 * motion.css — app-wide gentle motion layer (paired with static/js/motion.js)
 *
 * - Cross-page navigation cross-fades (View Transitions, where supported)
 * - Soft transitions on interactive controls
 * - Everything is switched off for users who prefer reduced motion
 *
 * Opt an element (and its subtree) out of JS motion with data-motion="off".
 */

:root {
  --motion-ease: cubic-bezier(.4, 0, .2, 1);
  --motion-ease-out: cubic-bezier(.16, 1, .3, 1);
  --motion-fast: 160ms;
  --motion-base: 240ms;
}

html { scroll-behavior: smooth; }

/* ── Page-to-page cross-fade (Chrome/Edge 126+, Safari 18.2+; ignored elsewhere) ── */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: var(--motion-ease);
}
::view-transition-old(root) { animation-name: motionPageOut; }
::view-transition-new(root) { animation-name: motionPageIn; }

/* Keep the sidebar perfectly still while the page content changes */
#app-sidebar { view-transition-name: app-sidebar; }
::view-transition-group(app-sidebar) { animation: none; }

@keyframes motionPageOut { to { opacity: 0; } }
@keyframes motionPageIn  { from { opacity: 0; transform: translateY(6px); } }

/* ── Interactive controls ── */
a, button, [role="button"], input, select, textarea, label, summary {
  transition-timing-function: var(--motion-ease);
}
input, select, textarea {
  transition-property: border-color, box-shadow, background-color, color;
  transition-duration: var(--motion-fast);
}

/* Native <details> open/close (Chrome 131+, progressive) */
details::details-content {
  transition: block-size var(--motion-base) var(--motion-ease),
              content-visibility var(--motion-base) allow-discrete;
  block-size: 0;
  overflow: clip;
}
details[open]::details-content { block-size: auto; }
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
}

/* ── Reduced motion: turn it all off ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  @view-transition { navigation: none; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
