/* Amazon Finance — bespoke motion inside its story sheets (loaded after sheets.css).
   Every start state lives behind .osheet.os-motion, so with reduced motion or
   Pause Motion each diagram is simply drawn in its final state. */

/* ---------- bars that grow (SVG): .fin-gx grows from the left, .fin-gy from the floor ---------- */
.osheet .fin-gx, .osheet .fin-gy {
  transform-box: fill-box;
  transition: transform 1.3s cubic-bezier(.16,1,.3,1);
  transition-delay: calc(var(--d, 0) * 1ms);
}
.osheet .fin-gx { transform-origin: 0 50%; }
.osheet .fin-gx--r { transform-origin: 100% 50%; }
.osheet .fin-gy { transform-origin: 50% 100%; }
.osheet.os-motion [data-os]:not(.is-in) .fin-gx,
.osheet.os-motion .os-frame:not(.is-on) .fin-gx { transform: scaleX(0); transition-duration: .3s; transition-delay: 0s; }
.osheet.os-motion [data-os]:not(.is-in) .fin-gy,
.osheet.os-motion .os-frame:not(.is-on) .fin-gy { transform: scaleY(0); transition-duration: .3s; transition-delay: 0s; }

/* ---------- rows that fall back once a filter or a better channel takes over ---------- */
.osheet .fin-dim { opacity: var(--o, .22); transition: opacity .9s ease; transition-delay: calc(var(--d, 0) * 1ms); }
.osheet.os-motion .os-frame:not(.is-on) .fin-dim { opacity: 1; transition-duration: .2s; transition-delay: 0s; }

/* ---------- a queue that clears: squares walk from the line into the launched grid ---------- */
.osheet .fin-q {
  transform: translate(var(--x1), var(--y1));
  transition: transform 1.5s cubic-bezier(.16,1,.3,1), opacity .6s;
  transition-delay: calc(var(--i, 0) * 70ms + 350ms);
}
.osheet.os-motion .os-frame:not(.is-on) .fin-q { transform: translate(var(--x0), var(--y0)); opacity: .55; transition-duration: .2s; transition-delay: 0s; }

/* ---------- the balance: the beam settles level as the block arrives ---------- */
.osheet .fin-beam {
  transform-box: view-box; transform-origin: 280px 128px;
  transition: transform 2.6s cubic-bezier(.34,1.56,.64,1) .45s;
}
.osheet.os-motion .fin-beam-stage[data-os]:not(.is-in) .fin-beam { transform: rotate(-9deg); }
.osheet .fin-balanced { transition: opacity .8s ease 2.2s; }
.osheet.os-motion .fin-beam-stage[data-os]:not(.is-in) .fin-balanced { opacity: 0; transition-delay: 0s; }

/* ---------- Abacus: a rule built one step at a time, invalid until it is complete ---------- */
.fin-rule { padding: clamp(22px, 4vw, 48px); }
.fin-rule-card {
  max-width: 560px; margin: 0 auto; border-radius: 20px; padding: 24px 24px 12px;
  background: #0c0c0e; box-shadow: inset 0 0 0 1px var(--os-line), 0 30px 60px rgba(0,0,0,.35);
}
.fin-rule-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--os-line); }
.fin-rule-head > span { font-size: var(--t-caption); letter-spacing: .14em; text-transform: uppercase; color: var(--gray); }
.fin-rule-state { position: relative; display: grid; font-style: normal; font-size: var(--t-caption); letter-spacing: .06em; }
.fin-rule-state s, .fin-rule-state b {
  grid-area: 1 / 1; text-decoration: none; font-weight: 500; padding: 6px 14px; border-radius: 999px; text-align: center;
  transition: opacity .6s ease, transform .7s cubic-bezier(.34,1.56,.64,1); transition-delay: 2.1s;
}
.fin-rule-state s { color: var(--shu-text); box-shadow: inset 0 0 0 1px rgba(247,34,91,.5); opacity: 0; }
.fin-rule-state b { color: var(--ink); background: rgba(195,21,55,.24); box-shadow: inset 0 0 0 1px var(--shu); }
.fin-rule-state b::before { content: "\2713\00a0"; color: var(--shu-text); }
.osheet.os-motion .fin-rule[data-os]:not(.is-in) .fin-rule-state s { opacity: 1; transition-delay: 0s; }
.osheet.os-motion .fin-rule[data-os]:not(.is-in) .fin-rule-state b { opacity: 0; transform: scale(.7); transition-delay: 0s; }
.fin-rule-steps { list-style: none; margin: 0; padding: 0; }
.fin-rule-steps li { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 4px 16px; padding: 18px 0; border-bottom: 1px solid rgba(245,242,235,.06); }
.fin-rule-steps li:last-child { border-bottom: 0; }
.fin-rule-steps i {
  font-style: normal; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: var(--t-caption); color: var(--ink); background: rgba(195,21,55,.18); box-shadow: inset 0 0 0 1px var(--shu);
  transition: background .5s, box-shadow .5s, color .5s; transition-delay: calc(var(--d, 0) * 1ms + 500ms);
}
.fin-rule-steps span { font-size: var(--t-body); color: var(--ink); }
.fin-rule-steps u { grid-column: 2; display: block; height: 4px; border-radius: 4px; background: rgba(245,242,235,.07); overflow: hidden; }
.fin-rule-steps u::before {
  content: ""; display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7a0e24, var(--shu));
  transform-origin: 0 50%; transition: transform .9s cubic-bezier(.65,0,.35,1); transition-delay: calc(var(--d, 0) * 1ms);
}
.osheet.os-motion .fin-rule[data-os]:not(.is-in) .fin-rule-steps u::before { transform: scaleX(0); transition-delay: 0s; }
.osheet.os-motion .fin-rule[data-os]:not(.is-in) .fin-rule-steps i { background: transparent; box-shadow: inset 0 0 0 1px var(--os-line); color: var(--gray); transition-delay: 0s; }

/* ---------- small fixes for the modules inside these sheets ---------- */
/* a single stat should not stretch its rule across the whole column */
.osheet .os-stats:has(> .os-stat:only-child) { grid-template-columns: minmax(0, 360px); }

/* ---------- pills added to the page ---------- */
.finance-impact > .pill-row { grid-column: 1 / -1; margin-top: 8px; }
.story-aside > .pill-row { margin-top: 36px; }
.story-result > .pill-row { margin-top: 44px; }
.ov-act > .pill-row { margin-top: 48px; }
#ov-scope .ov-lede { max-width: 62ch; }

@media (prefers-reduced-motion: reduce) {
  .osheet .fin-gx, .osheet .fin-gy, .osheet .fin-dim, .osheet .fin-q, .osheet .fin-beam, .osheet .fin-balanced,
  .fin-rule-state s, .fin-rule-state b, .fin-rule-steps i, .fin-rule-steps u::before { transition: none !important; }
}

/* five big figures need wider columns than the default stat grid */
.osheet .fin-stats-wide { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* glossary: the sticky search and letter rail sit on a solid band, so terms never show through the letters */
#ovGlossary .os-gloss-tools { background: var(--os-bg); }
#ovGlossary .os-gloss-tools::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 22px; background: linear-gradient(var(--os-bg), rgba(12,12,14,0)); pointer-events: none; }
