/* Animated building blocks for blog articles.
 *
 * Post bodies pass through HTMLPurifier on save, which strips <style>, <svg>,
 * data-* attributes and animation CSS. Everything here is therefore driven by
 * plain class names (and an inline width on chart bars, which the purifier
 * keeps), so authors can write ordinary <div class="sx-..."> markup.
 *
 * Elements start in their final state; the reveal script adds .sx-js to the
 * body first, so if JS never runs nothing is left hidden.
 */

/* ---------- reveal on scroll ---------- */
.sx-js .sx-reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.sx-js .sx-reveal.sx-in { opacity: 1; transform: none; }

/* ---------- key-number cards ---------- */
.sx-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 8px 0 26px; }
.sx-stat { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 16px 16px; }
.sx-stat::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--primary), var(--teal)); }
.sx-stat__num { display: block; font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--ink); }
.sx-stat__label { display: block; margin-top: 6px; font-size: 13px; line-height: 1.45; color: var(--secondary); }
.sx-stat--teal::before { background: var(--teal); }
.sx-stat--warn::before { background: #f59e0b; }
.sx-js .sx-stats.sx-in .sx-stat { animation: sx-pop .55s cubic-bezier(.2, .8, .3, 1.2) both; }
.sx-js .sx-stats.sx-in .sx-stat:nth-child(2) { animation-delay: .08s; }
.sx-js .sx-stats.sx-in .sx-stat:nth-child(3) { animation-delay: .16s; }
.sx-js .sx-stats.sx-in .sx-stat:nth-child(4) { animation-delay: .24s; }

/* ---------- horizontal bar chart ----------
 * <div class="sx-chart"><div class="sx-chart__title">..</div>
 *   <div class="sx-bar"><span class="sx-bar__label">..</span>
 *     <span class="sx-bar__track"><span class="sx-bar__fill" style="width:62%"></span></span>
 *     <span class="sx-bar__value">..</span></div></div>
 */
.sx-chart { background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; padding: 20px 20px 14px; margin: 8px 0 26px; }
.sx-chart__title { font-size: 14.5px; font-weight: 700; color: var(--ink); margin-bottom: 14px; }
.sx-chart__note { font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.sx-bar { display: grid; grid-template-columns: minmax(110px, 30%) 1fr auto; align-items: center; gap: 12px; margin-bottom: 11px; font-size: 13.5px; }
.sx-bar__label { color: var(--body); line-height: 1.35; }
.sx-bar__track { height: 12px; background: var(--divider); border-radius: 99px; overflow: hidden; }
.sx-bar__fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #a07af7); transform-origin: left center; }
.sx-bar--teal .sx-bar__fill { background: linear-gradient(90deg, var(--teal-deep), var(--teal)); }
.sx-bar--warn .sx-bar__fill { background: linear-gradient(90deg, #d97706, #fbbf24); }
.sx-bar--muted .sx-bar__fill { background: #c9c9d6; }
.sx-bar__value { font-weight: 700; color: var(--ink); white-space: nowrap; }
.sx-js .sx-chart .sx-bar__fill { transform: scaleX(0); }
.sx-js .sx-chart.sx-in .sx-bar__fill { animation: sx-grow 1.1s cubic-bezier(.2, .7, .2, 1) forwards; }
.sx-js .sx-chart.sx-in .sx-bar:nth-of-type(2) .sx-bar__fill { animation-delay: .12s; }
.sx-js .sx-chart.sx-in .sx-bar:nth-of-type(3) .sx-bar__fill { animation-delay: .24s; }
.sx-js .sx-chart.sx-in .sx-bar:nth-of-type(4) .sx-bar__fill { animation-delay: .36s; }
.sx-js .sx-chart.sx-in .sx-bar:nth-of-type(5) .sx-bar__fill { animation-delay: .48s; }
.sx-js .sx-chart.sx-in .sx-bar:nth-of-type(6) .sx-bar__fill { animation-delay: .6s; }

/* ---------- step timeline ---------- */
.sx-steps { counter-reset: sx-step; position: relative; margin: 8px 0 26px; padding-left: 4px; }
.sx-step { position: relative; padding: 0 0 18px 50px; }
.sx-step::before { counter-increment: sx-step; content: counter(sx-step); position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: #fff; background: var(--primary); box-shadow: 0 0 0 5px var(--primary-tint); }
.sx-step::after { content: ''; position: absolute; left: 16px; top: 38px; bottom: 2px; width: 2px; background: linear-gradient(var(--primary-tint-border), transparent); }
.sx-step:last-child::after { display: none; }
.sx-step__title { display: block; font-weight: 700; color: var(--ink); margin-bottom: 3px; line-height: 1.4; }
.sx-step__text { display: block; font-size: 14.5px; color: var(--secondary); line-height: 1.65; }
.sx-js .sx-steps.sx-in .sx-step::before { animation: sx-ping 2.4s ease-out 1; }
.sx-js .sx-steps.sx-in .sx-step:nth-child(2)::before { animation-delay: .3s; }
.sx-js .sx-steps.sx-in .sx-step:nth-child(3)::before { animation-delay: .6s; }
.sx-js .sx-steps.sx-in .sx-step:nth-child(4)::before { animation-delay: .9s; }
.sx-js .sx-steps.sx-in .sx-step:nth-child(5)::before { animation-delay: 1.2s; }
.sx-js .sx-steps.sx-in .sx-step:nth-child(6)::before { animation-delay: 1.5s; }

/* ---------- callouts ---------- */
.sx-callout { position: relative; border-radius: 14px; padding: 16px 18px 16px 52px; margin: 6px 0 24px; font-size: 14.5px; line-height: 1.65; background: var(--primary-tint); border: 1px solid var(--primary-tint-border); color: var(--body); }
.sx-callout::before { content: '!'; position: absolute; left: 16px; top: 16px; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.sx-callout strong:first-child { color: var(--ink); }
.sx-callout--tip { background: var(--teal-tint); border-color: var(--teal-tint-border); }
.sx-callout--tip::before { content: '\2713'; background: var(--teal-deep); }
.sx-callout--warn { background: #fdf3e3; border-color: #f6dfb8; }
.sx-callout--warn::before { background: #d97706; }
.sx-js .sx-callout.sx-in::before { animation: sx-pulse 1.8s ease-out 2; }

/* ---------- comparison table ---------- */
.sx-table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 8px 0 26px; font-size: 14px; border: 1px solid var(--hairline); border-radius: 14px; overflow: hidden; background: var(--surface); }
.sx-table th { background: var(--surface-violet); color: var(--ink); font-weight: 700; text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--hairline); }
.sx-table td { padding: 11px 14px; border-bottom: 1px solid var(--divider); vertical-align: top; color: var(--body); }
.sx-table tr:last-child td { border-bottom: 0; }
.sx-table tr:hover td { background: var(--surface-2); }
.sx-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- key takeaways box ---------- */
.sx-takeaways { position: relative; background: var(--charcoal); color: #e9e9f1; border-radius: 16px; padding: 20px 22px 8px; margin: 4px 0 28px; overflow: hidden; }
.sx-takeaways::after { content: ''; position: absolute; width: 220px; height: 220px; right: -70px; top: -90px; border-radius: 50%; background: radial-gradient(circle, rgba(122, 59, 240, .55), transparent 70%); animation: sx-float 7s ease-in-out infinite; }
.sx-takeaways__title { position: relative; z-index: 1; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #b9a2f8; margin-bottom: 10px; }
.sx-takeaways ul { position: relative; z-index: 1; margin: 0 0 12px; padding-left: 20px; }
.sx-takeaways li { margin-bottom: 8px; line-height: 1.6; }
.sx-takeaways strong { color: #fff; }

/* ---------- inline figure ---------- */
.sx-figure { margin: 8px 0 26px; }
.sx-figure img { width: 100%; border-radius: 14px; border: 1px solid var(--hairline); margin: 0; }
.sx-figure__caption { display: block; font-size: 12.5px; color: var(--muted); margin-top: 8px; text-align: center; }

/* ---------- sources list ---------- */
.sx-sources { font-size: 13px; color: var(--muted); border-top: 1px solid var(--hairline); padding-top: 14px; margin-top: 30px; }
.sx-sources ol { padding-left: 20px; }
.sx-sources li { margin-bottom: 6px; }
.sx-sources a { font-weight: 500; word-break: break-word; }

@keyframes sx-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes sx-pop { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes sx-ping { 0% { box-shadow: 0 0 0 0 rgba(122, 59, 240, .5); } 70% { box-shadow: 0 0 0 14px rgba(122, 59, 240, 0); } 100% { box-shadow: 0 0 0 5px var(--primary-tint); } }
@keyframes sx-pulse { 0% { box-shadow: 0 0 0 0 rgba(122, 59, 240, .45); } 100% { box-shadow: 0 0 0 12px rgba(122, 59, 240, 0); } }
@keyframes sx-float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-24px, 18px); } }

@media (max-width: 600px) {
    .sx-bar { grid-template-columns: 1fr auto; }
    .sx-bar__label { grid-column: 1 / -1; }
    .sx-stat__num { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    .sx-js .sx-reveal, .sx-js .sx-chart .sx-bar__fill { opacity: 1; transform: none; transition: none; animation: none !important; }
    .sx-stat, .sx-step::before, .sx-callout::before, .sx-takeaways::after { animation: none !important; }
}
