/* Motion (after app.css). Only opacity and transform move, so nothing shifts the layout; every effect is off under
   prefers-reduced-motion. Durations are tokens so the whole feel can be tuned in one place. */
:root {
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --t-fast: .15s;
  --t-rise: .45s;
  --stagger: 70ms;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* page transition: a quick fade of the whole screen */
.screen { animation: fade-in .18s ease-out both; }

/* cards rise in, staggered */
.screen > *, .report > *, .stats > *, .shortcuts > *, .tpl-row > *, .risk-grid > *, .builder-form > * {
  animation: rise var(--t-rise) var(--ease-out) both;
}
.screen > :nth-child(2), .report > :nth-child(2), .stats > :nth-child(2), .shortcuts > :nth-child(2),
.tpl-row > :nth-child(2), .risk-grid > :nth-child(2), .builder-form > :nth-child(2) { animation-delay: calc(var(--stagger) * 1); }
.screen > :nth-child(3), .report > :nth-child(3), .stats > :nth-child(3), .shortcuts > :nth-child(3),
.tpl-row > :nth-child(3), .risk-grid > :nth-child(3), .builder-form > :nth-child(3) { animation-delay: calc(var(--stagger) * 2); }
.screen > :nth-child(4), .report > :nth-child(4), .stats > :nth-child(4), .tpl-row > :nth-child(4),
.risk-grid > :nth-child(4), .builder-form > :nth-child(4) { animation-delay: calc(var(--stagger) * 3); }
.screen > :nth-child(5), .report > :nth-child(5), .stats > :nth-child(5), .risk-grid > :nth-child(5),
.builder-form > :nth-child(5) { animation-delay: calc(var(--stagger) * 4); }
.screen > :nth-child(n+6), .report > :nth-child(n+6), .risk-grid > :nth-child(n+6),
.builder-form > :nth-child(n+6) { animation-delay: calc(var(--stagger) * 5); }
/* the builder form re-renders on structural edits: rise only on the first paint of the screen */
.builder-form.settled > * { animation: none; }

/* hover lift on clickable cards and buttons */
.btn, .tab, .shortcut, .tpl, .stat {
  transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease, background-color var(--t-fast) ease,
    border-color var(--t-fast) ease;
}
/* clickable cards lift a little; buttons only change colour (and press in) */
.shortcut:hover, .tpl:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 24, 40, .06);
}
.btn:active:not(:disabled) { transform: scale(.98); }

/* equity curve draws in (the path carries pathLength="1"); the dashed gross line fades in after */
.eq-net { stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw 1.4s cubic-bezier(.4, 0, .2, 1) .2s both; }
.eq-gross { animation: fade-in .6s ease 1.1s both; }

/* count-up numbers keep their width steady */
.stat-value, .tabular { font-variant-numeric: tabular-nums; }

/* backtest progress: an indeterminate bar */
.bar { position: relative; height: 6px; margin: 16px auto 12px; max-width: 360px; overflow: hidden; border-radius: 999px; background: var(--brand-soft); }
.bar::before { content: ''; position: absolute; inset: 0; width: 40%; border-radius: inherit; background: var(--brand); animation: slide 1.4s var(--ease-out) infinite; }
[dir="rtl"] .bar::before { animation-direction: reverse; }

/* skeleton loaders (same box as the content they stand for) */
.skeleton { display: grid; gap: 12px; }
.sk { height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--line) 25%, var(--ground) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-title { height: 22px; width: 40%; }
.sk-row { height: 40px; }
.sk-short { width: 60%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .eq-net { stroke-dasharray: none; }
  .shortcut:hover, .tpl:hover, .btn:active:not(:disabled) { transform: none; }
}
