/* Universal Probability Analyzer — Beta 3.3
   Decorative, compositor-friendly motion layer shared by all four pages.
   Deliberately independent of numerical calculations and model state. */

@media (prefers-reduced-motion: no-preference) {
  /* Small, consistent interaction feedback throughout the interface. */
  .nav-item .nav-icon,
  .icon-button svg,
  .primary-button svg,
  .secondary-button svg,
  .text-button svg,
  .home-text-action svg {
    transition: transform .24s cubic-bezier(.2,.8,.2,1), color .24s ease;
  }
  .nav-item:hover .nav-icon { transform: translateX(3px); }
  .icon-button:hover svg { transform: scale(1.10); }
  .primary-button:not(:disabled):hover svg,
  .secondary-button:not(:disabled):hover svg,
  .text-button:hover svg { transform: translateX(3px); }
  .primary-button:not(:disabled),
  .secondary-button:not(:disabled),
  .preset-button, .segmented label, .wheel-toggle label,
  .home-text-action, .home-primary-action {
    transition: transform .2s ease, box-shadow .25s ease,
                background-color .25s ease, border-color .25s ease, filter .25s ease;
  }
  .primary-button:not(:disabled):hover,
  .home-primary-action:hover { box-shadow: 0 9px 26px rgba(101,129,246,.24); filter: brightness(1.07); }
  .primary-button:not(:disabled):active,
  .secondary-button:not(:disabled):active,
  .preset-button:active,
  .home-lab-card:active { transform: scale(.985); }
  input[type="range"]::-webkit-slider-thumb {
    transition: box-shadow .24s ease, border-color .24s ease, scale .24s ease;
  }
  input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 7px rgba(115,145,249,.12); scale: 1.08; }
  input[type="range"]::-moz-range-thumb { transition: box-shadow .2s ease; }
  input[type="range"]:hover::-moz-range-thumb { box-shadow: 0 0 0 7px rgba(115,145,249,.12); }

  /* Fast initial reveal: never blocks reading or keyboard navigation. */
  .topbar { animation: upa-header-in .52s cubic-bezier(.16,.85,.3,1) both; }
  .hero, .welcome-hero { animation: upa-hero-in .68s cubic-bezier(.15,.8,.25,1) both; }
  .hero .eyebrow, .welcome-hero .home-eyebrow { animation: upa-copy-in .58s .10s both; }
  .hero h1, .welcome-hero h1 { animation: upa-copy-in .65s .18s both; }
  .hero-copy > p, .welcome-copy > p { animation: upa-copy-in .62s .28s both; }
  .hero-tags, .home-hero-actions, .home-proof { animation: upa-copy-in .6s .36s both; }

  /* Progressive enhancement: only elements explicitly observed by motion.js
     are ever hidden before their first viewport entrance. */
  .motion-wait:not(.motion-in-view) { opacity:0; translate:0 17px; }
  .motion-wait {
    transition: opacity .6s cubic-bezier(.16,.8,.2,1),
                translate .6s cubic-bezier(.16,.8,.2,1);
  }
  .motion-in-view { opacity:1; translate:0 0; }

  .home-lab-card { isolation:isolate; }
  .home-lab-card::after {
    content:""; position:absolute; inset:0; pointer-events:none; border-radius:inherit;
    box-shadow:inset 0 0 0 1px rgba(166,190,255,.27), 0 0 35px rgba(107,119,232,.065);
    opacity:0; transition:opacity .34s ease;
  }
  .home-lab-card:hover::after, .home-lab-card:focus-visible::after { opacity:1; }
  .home-card-graphic { transition:filter .4s ease; }
  .home-lab-card:hover .home-card-graphic { filter:brightness(1.12); }
  .home-step { transition:border-color .3s ease, background-color .3s ease, box-shadow .3s ease; }
  .home-step:hover { border-color:#40587e; box-shadow:0 12px 28px rgba(0,0,0,.16); }
  .home-step-top svg { transition:transform .32s cubic-bezier(.15,.85,.3,1); }
  .home-step:hover .home-step-top svg { transform:translateY(-3px) scale(1.06); }

  /* The home hero's chart and decorative tokens are intentionally slow. */
  .art-plot { animation: upa-chart-float 6.5s ease-in-out infinite; }
  .art-orbit { animation: upa-home-orbit 38s linear infinite; }
  .art-orbit.orbit-b { animation-direction:reverse; animation-duration:48s; }
  .art-orbit::before {
    content:""; position:absolute; width:6px; height:6px; left:calc(50% - 3px);
    top:-3px; background:#97c7ff; border-radius:50%;
    box-shadow:0 0 10px rgba(135,190,255,.8),0 0 24px rgba(135,190,255,.3);
  }
  .art-orbit.orbit-b::before { width:4px; height:4px; background:#67d5c2; }
  .art-math-token { animation:upa-token-drift 7s ease-in-out infinite; }
  .art-math-token.token-two { animation-delay:-3s; }
  .art-bars i { transform-origin:center bottom; animation:upa-bar-grow .75s cubic-bezier(.13,.8,.3,1) both; }
  .art-bars i:nth-child(2n) { animation-delay:.07s; }
  .art-bars i:nth-child(3n) { animation-delay:.13s; }
  .art-bars i.peak { animation-delay:.17s; }

  /* Three laboratory illustrations. Keep canvas/wheel interaction untouched. */
  .hero-visual .die-one { animation:upa-die-bob 5.4s ease-in-out infinite; }
  .hero-visual .die-two { animation:upa-die-bob 6.3s -2.1s ease-in-out infinite reverse; }
  .hero-visual .orbit { animation:upa-ring-glow 8s ease-in-out infinite; }
  .roulette-hero-graphic .halo-ring:not(.halo-inner) { animation:upa-roulette-ring 42s linear infinite; }
  .roulette-hero-graphic .halo-ring.halo-inner { animation:upa-roulette-ring-reverse 46s linear infinite; }
  .slots-hero-art span { animation:upa-slot-shimmer 5.2s ease-in-out infinite; }
  .slots-hero-art span:nth-child(2) { animation-delay:-1.6s; }
  .slots-hero-art span:nth-child(3) { animation-delay:-3.1s; }
  .slot-led, .home-lights i { animation:upa-led-glow 3.8s ease-in-out infinite; }
  .home-lights i:nth-child(2n) { animation-delay:-1.9s; }
  .home-mini-wheel { animation:upa-mini-wheel 35s linear infinite; }
  .home-lab-roulette:hover .home-mini-wheel { animation-duration:12s; }
  .home-mini-reels span { animation:upa-mini-reel 5.2s ease-in-out infinite; }
  .home-mini-reels span:nth-child(2) { animation-delay:-1.75s; }
  .home-mini-reels span:nth-child(3) { animation-delay:-3.5s; }

  /* Dashboard visuals update fluidly; values themselves are never changed. */
  .metric-card { transition:border-color .27s ease, box-shadow .27s ease, background-color .27s ease; }
  .metric-card:hover { border-color:rgba(137,167,228,.42); box-shadow:0 13px 28px rgba(0,0,0,.15); }
  .mini-bar-fill,.progress-fill,.color-theory,.color-observed,
  .slots-bar-exact,.slots-bar-observed,.match-fill { transition:width .44s cubic-bezier(.2,.7,.3,1); }
  #distribution-chart rect[fill="#607ec5"],
  #distribution-chart rect[fill="#aa8bfc"] {
    transform-box:fill-box; transform-origin:center bottom;
    animation:upa-svg-bar .48s cubic-bezier(.15,.8,.4,1) both;
  }
  .computed-pill .status-light, .live-badge .status-light { animation:upa-led-glow 4s ease-in-out infinite; }
  .motion-value-glow { animation:upa-value-glow .5s ease-out; }

  /* Pause ongoing decoration while browser tab is hidden. */
  .motion-page-hidden .art-plot, .motion-page-hidden .art-orbit,
  .motion-page-hidden .home-mini-wheel, .motion-page-hidden .home-mini-reels span,
  .motion-page-hidden .hero-visual .die-one, .motion-page-hidden .hero-visual .die-two,
  .motion-page-hidden .roulette-hero-graphic .halo-ring,
  .motion-page-hidden .slots-hero-art span,
  .motion-page-hidden .home-lights i { animation-play-state:paused; }

  @keyframes upa-header-in { from { opacity:0; translate:0 -8px; } to { opacity:1; translate:0 0; } }
  @keyframes upa-hero-in { from { opacity:.72; translate:0 12px; } to { opacity:1; translate:0 0; } }
  @keyframes upa-copy-in { from { opacity:0; translate:0 10px; } to { opacity:1; translate:0 0; } }
  @keyframes upa-chart-float { 0%,100% {translate:0 0;} 50% {translate:0 -7px;} }
  @keyframes upa-home-orbit { from {transform:translate(-50%,-50%) rotate(0deg);} to {transform:translate(-50%,-50%) rotate(360deg);} }
  @keyframes upa-token-drift { 0%,100% {translate:0 0;} 50% {translate:0 -9px;} }
  @keyframes upa-bar-grow { from {transform:scaleY(.06); opacity:.35;} to {transform:scaleY(1); opacity:1;} }
  @keyframes upa-die-bob { 0%,100% {translate:0 0;} 50% {translate:0 -8px;} }
  @keyframes upa-ring-glow { 0%,100% {opacity:.55;} 50% {opacity:1;} }
  @keyframes upa-roulette-ring { from {transform:rotate(28deg);} to {transform:rotate(388deg);} }
  @keyframes upa-roulette-ring-reverse { from {transform:rotate(13deg);} to {transform:rotate(-347deg);} }
  @keyframes upa-slot-shimmer { 0%,100% {filter:brightness(1);} 50% {filter:brightness(1.16);} }
  @keyframes upa-led-glow { 0%,100% {opacity:.65;} 50% {opacity:1;box-shadow:0 0 12px rgba(112,230,204,.58);} }
  @keyframes upa-mini-wheel { from {transform:rotate(0deg);} to {transform:rotate(360deg);} }
  @keyframes upa-mini-reel { 0%,100% {translate:0 0;} 50% {translate:0 -4px;} }
  @keyframes upa-svg-bar { from {transform:scaleY(.08);opacity:.38;} to {transform:scaleY(1);opacity:1;} }
  @keyframes upa-value-glow { 0% {filter:brightness(1.4);} 100% {filter:brightness(1);} }
}

/* Motion is an enhancement, never an accessibility requirement. */
@media (prefers-reduced-motion: reduce) {
  .motion-wait,.motion-in-view { opacity:1 !important; translate:none !important; transition:none !important; }
  .motion-value-glow { animation:none !important; }
  .progress-fill,.mini-bar-fill,.color-theory,.color-observed,
  .slots-bar-exact,.slots-bar-observed,.match-fill { transition:none !important; }
}
