:root {
  --ease-out-expo: cubic-bezier(.16, 1, .3, 1);
  --ease-soft: cubic-bezier(.22, .61, .36, 1);
}

/* A small, consistent motion vocabulary across the whole library. */
.nav-item, .filter-tabs button, .discovery-tags button, .resource-view-tabs button,
.resource-filters button, .related-terms button, .source-term-links button {
  transition: color .2s, background-color .2s, border-color .2s, transform .3s var(--ease-out-expo);
}
.motion-on .nav-item:hover { transform: translateX(3px); }
.motion-on .discovery-tags button:hover, .motion-on .related-terms button:hover,
.motion-on .source-term-links button:hover { transform: translateY(-2px); }
.icon-button, .primary-button, .surprise-button, .save-button, .preview-toggle,
.secondary-save, .quiet-button, .motion-toggle {
  transition: transform .32s var(--ease-out-expo), background-color .2s, color .2s,
    border-color .2s, box-shadow .25s;
}
.motion-on button:active { transform: scale(.97); }
.motion-on .nav-item:active { transform: translateX(2px) scale(.98); }
.motion-on .save-button:active { transform: scale(.82); }
.save-button svg { transition: fill .2s, stroke .2s, transform .4s var(--ease-out-expo); }
.motion-on .save-button.is-saved svg { animation: motif-bookmark-pop .45s var(--ease-out-expo) both; }
.motion-on .surprise-button:hover svg { transform: rotate(-12deg); }
.surprise-button svg, .quiet-button svg { transition: transform .4s var(--ease-out-expo); }
.motion-on .quiet-button:hover svg { transform: rotate(12deg); }
.motion-on .term-card {
  transition: transform .5s var(--ease-out-expo), box-shadow .5s, border-color .3s;
}
.motion-on .term-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 30px -16px #2e34252c;
  border-color: #cdd3c1;
}
.motion-on .term-card:active { transform: translateY(-2px); }
.demo-cta { transition: opacity .3s, transform .4s var(--ease-out-expo); }
.motion-on .term-card:hover .demo-cta { transform: translate(0, 0) rotate(-5deg); }
.searchbox { transition: box-shadow .3s, border-color .3s, background-color .3s; }
.motion-on .searchbox:focus-within { box-shadow: 0 0 0 4px #e7eadc; }
.filter-tabs button { position: relative; }
.filter-tabs button::after { transition: transform .35s var(--ease-out-expo), opacity .25s; transform-origin: left; }
.motion-on .hero .art-glass { animation: motif-glass-drift 7s ease-in-out infinite; }
.motion-on .hero .art-black-ball { animation: motif-ball-drift 6s ease-in-out infinite; }
.motion-on .hero .art-lime-dot { animation: motif-lime-drift 5s ease-in-out infinite; }
.motion-on .hero .art-chip { animation: motif-chip-drift 8s ease-in-out infinite; }
.motion-on .hero .art-star { animation: motif-star-turn 24s linear infinite; }
.motion-on .hero .orbit-one { animation: motif-orbit-one 20s ease-in-out infinite; }
.motion-on .hero .orbit-two { animation: motif-orbit-two 25s ease-in-out infinite; }
.motion-on .brand:hover .brand-icon { transform: rotate(90deg); }
.brand-icon { transition: transform .7s var(--ease-out-expo); }
.motion-on dialog[open] { animation: motif-dialog-in .4s var(--ease-out-expo) both; }
.motion-on dialog[open]::backdrop { animation: motif-backdrop-in .3s ease-out both; }
.motion-on .empty-asterisk { animation: motif-empty-turn 8s ease-in-out infinite; display: inline-block; }
.motion-on .toast.show { transition-timing-function: var(--ease-out-expo); }
.scroll-progress {
  position: fixed; top: 0; left: 225px; right: 0; z-index: 45;
  height: 2px; background: #f55b35; opacity: .7; pointer-events: none;
  transform: scaleX(0); transform-origin: left center;
}
.motion-on .scroll-progress { transition: transform .12s linear; }

/* Only visible demos consume animation work; hover remains available when paused. */
.motion-on .term-card:not(.in-viewport) .demo *,
.motion-on .term-card:not(.in-viewport) .demo *::before,
.motion-on .term-card:not(.in-viewport) .demo *::after { animation-play-state: paused; }
body:not(.motion-on) .hero-art *, body.page-backgrounded .hero-art *,
body.page-backgrounded .term-card .demo *, body.page-backgrounded .term-card .demo *::before,
body.page-backgrounded .term-card .demo *::after { animation-play-state: paused; }
.hero.motion-offscreen .hero-art * { animation-play-state: paused; }
body:not(.motion-on) .term-card .demo *,
body:not(.motion-on) .term-card .demo *::before,
body:not(.motion-on) .term-card .demo *::after { animation-play-state: paused; }
body:not(.motion-on) .term-card:hover { transform: none; }
body:not(.motion-on) .resource-grid-card:hover .resource-art-image { transform: none; }

@keyframes motif-glass-drift {
  0%,100% { transform: translate(0,0) rotate(-12deg); }
  50% { transform: translate(2px,-9px) rotate(-8deg); }
}
@keyframes motif-ball-drift {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(-4px,-11px); }
}
@keyframes motif-lime-drift {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(4px,7px); }
}
@keyframes motif-chip-drift {
  0%,100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-5px) rotate(-2deg); }
}
@keyframes motif-star-turn {
  from { transform: rotate(5deg); }
  to { transform: rotate(365deg); }
}
@keyframes motif-orbit-one {
  0%,100% { transform: rotate(-25deg); }
  50% { transform: rotate(-12deg); }
}
@keyframes motif-orbit-two {
  0%,100% { transform: rotate(33deg); }
  50% { transform: rotate(45deg); }
}
@keyframes motif-bookmark-pop {
  0% { transform: scale(.65); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes motif-dialog-in {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes motif-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes motif-empty-turn {
  0%,70%,100% { transform: rotate(0); }
  85% { transform: rotate(90deg); }
}
@media(max-width:760px) {
  .scroll-progress { left: 0; }
  .sidebar { transition: transform .4s var(--ease-out-expo); }
}
@media(hover:none) {
  .motion-on .term-card:hover { transform: none; box-shadow: none; }
}
@media(prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .scroll-progress { display: none; }
  .motion-on .term-card:hover, .motion-on .nav-item:hover,
  .motion-on button:active, .motion-on .discovery-tags button:hover { transform: none; }
}
