/* motion: view enters, station tuning, press spring, celebration bits, loading and empty states, hardware details.
   transform and opacity only. every block is off under calm motion, reduced motion or the "sparkle effects" device switch (html.nojuice) */

/* ---------- 1. staggered rise when a view opens (--i is set per child, capped at 8) ---------- */
@media (prefers-reduced-motion: no-preference) {
  html:not(.calm):not(.nojuice):not([data-enter="none"]) .view.entering :is(.mod, .card-list > *, .panel):not(.panel .panel) {
    animation: jx-rise 0.42s var(--spring) backwards;
    animation-delay: calc(var(--i, 0) * 45ms);
  }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(2) { --i: 1; }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(3) { --i: 2; }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(4) { --i: 3; }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(5) { --i: 4; }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(6) { --i: 5; }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(7) { --i: 6; }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(8) { --i: 7; }
  .view.entering :is(.mod, .card-list > *, .panel):nth-child(n+9) { --i: 8; }
}
@keyframes jx-rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } }

/* ---------- station tuning: a static sweep over the page and a chromatic split on the title ---------- */
body { --jx-tint: transparent; }
body[data-station="home"] { --jx-tint: rgba(77, 232, 255, 0.10); }
body[data-station="plan"] { --jx-tint: rgba(91, 227, 161, 0.10); }
body[data-station="studio"] { --jx-tint: rgba(255, 120, 200, 0.10); }
body[data-station="practice"] { --jx-tint: rgba(255, 201, 77, 0.10); }
body[data-station="money"] { --jx-tint: rgba(120, 220, 120, 0.10); }
body[data-station="tools"] { --jx-tint: rgba(160, 140, 255, 0.10); }
body[data-station="core"] { --jx-tint: rgba(255, 110, 110, 0.10); }
#content::after {
  content: ""; position: absolute; inset: 0; z-index: 30; pointer-events: none; opacity: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.10) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, transparent 0 40%, var(--jx-tint) 50%, transparent 60%) 0 0 / 100% 200% no-repeat,
    var(--jx-tint);
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: no-preference) {
  html:not(.calm):not(.nojuice) body.tuning #content::after { animation: jx-sweep 0.45s steps(9) 1; }
  html:not(.calm):not(.nojuice) body.tuning .view.active h1 { animation: jx-split 0.45s steps(3) 1; }
}
@keyframes jx-sweep {
  0% { opacity: 0.9; transform: translateY(-100%); }
  70% { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(0); }
}
@keyframes jx-split {
  0%, 60% { text-shadow: 2px 0 rgba(255, 0, 90, 0.7), -2px 0 rgba(0, 255, 240, 0.7); transform: translateX(-2px); }
  100% { text-shadow: none; transform: none; }
}

/* ---------- 2. press: spring back on release, scan ring on primary keys, springier switches ---------- */
:is(button, .pill, .chip, .card, .tile, .sticky-note, .scrap).is-pressed { scale: 0.96; }
@media (prefers-reduced-motion: no-preference) {
  html:not(.calm):not(.nojuice) .jx-rel { animation: jx-spring 0.34s cubic-bezier(0.3, 1.5, 0.5, 1); }
  html:not(.calm):not(.nojuice) .jx-pop { animation: jx-pop 0.45s var(--spring); }
  html:not(.calm):not(.nojuice) .toggle-track i { transition-timing-function: cubic-bezier(0.3, 1.6, 0.5, 1); }
  html:not(.calm):not(.nojuice) .toggle input:checked + .toggle-track i { animation: jx-led 0.5s ease-out; }
  html:not(.calm):not(.nojuice) .switch-thumb { transition-timing-function: cubic-bezier(0.3, 1.45, 0.5, 1); }
}
@keyframes jx-spring { 0% { scale: 0.96; } 50% { scale: 1.035; } 100% { scale: 1; } }
@keyframes jx-pop { 0% { scale: 1; } 35% { scale: 1.35; } 100% { scale: 1; } }
@keyframes jx-led { 0% { filter: brightness(2.2); } 100% { filter: none; } }
.jx-scan {
  position: fixed; z-index: 200; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; pointer-events: none;
  border: 1px solid var(--chi); box-shadow: 0 0 10px var(--chi), inset 0 0 10px var(--chi);
  animation: jx-scan 0.5s ease-out forwards;
}
@keyframes jx-scan { from { transform: scale(0.1); opacity: 0.9; } to { transform: scale(1); opacity: 0; } }

/* ---------- 3. celebration canvas ---------- */
.jx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 210; pointer-events: none; image-rendering: pixelated; }
.jx-canvas[hidden] { display: none; }
html.calm .jx-canvas, html.nojuice .jx-canvas { display: none; }

/* ---------- 4. loading skeleton and empty lists ---------- */
.skeleton, [aria-busy="true"] > .skeleton { position: relative; overflow: hidden; min-height: 56px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--chi-dim), transparent);
  animation: jx-shimmer 1.3s linear infinite;
}
@keyframes jx-shimmer { to { transform: translateX(100%); } }
.empty::before {
  content: ""; display: block; width: 36px; height: 22px; margin: 0 auto 10px; opacity: 0.55;
  background: repeating-linear-gradient(0deg, var(--ink-3) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, var(--line-2) 0 2px, transparent 2px 5px);
  box-shadow: 0 0 0 1px var(--line-2);
}
@media (prefers-reduced-motion: no-preference) {
  html:not(.calm):not(.nojuice) .empty::before { animation: jx-static 0.8s steps(4) infinite; }
}
@keyframes jx-static { 25% { transform: translateX(2px); } 50% { transform: translateX(-1px); opacity: 0.35; } 75% { transform: translateX(1px); } }
/* section rules draw in as their section scrolls into view, only where the browser can do it from CSS */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    html:not(.calm):not(.nojuice) .section-head > h2::after {
      transform-origin: left; animation: jx-draw linear both; animation-timeline: view(); animation-range: entry 0% entry 80%;
    }
  }
}
@keyframes jx-draw { from { transform: scaleX(0); opacity: 0.3; } }

/* ---------- 5. cursor glow, mouse only and never needed ---------- */
.jx-glow {
  position: fixed; left: 0; top: 0; z-index: 3; width: 360px; height: 360px; margin: -180px 0 0 -180px; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, var(--chi-dim), transparent 65%); transition: opacity 0.3s; will-change: transform;
}
.jx-glow.on { opacity: 0.55; }
html.calm .jx-glow, html.nojuice .jx-glow { display: none; }
@media (hover: none) { .jx-glow { display: none; } }
html.calm .skeleton::after, html.nojuice .skeleton::after { animation: none; }
