/* sim.css — styles for the "Understand the Purchase Journey" simulation.
   Money-movement animations + an SSMS-flavoured database grid. */

/* ---------------- realistic card-tap scene ----------------
   Customer → hand+card with contactless waves → terminal on merchant counter,
   ending on an APPROVED indicator. Self-explanatory without reading. */
.sim-tap-scene { display: flex; align-items: flex-end; justify-content: center; gap: clamp(8px, 4vw, 48px); min-height: 190px; padding: 10px 0 20px; }
.sim-emoji { font-size: 3.2rem; line-height: 1; }
.sim-tap-label { font-size: 11px; color: #94a3b8; margin-top: 6px; text-align: center; white-space: nowrap; }
.sim-tap-customer { animation: sim-walkin 1s cubic-bezier(.2,.7,.2,1) both; text-align: center; }
@keyframes sim-walkin { 0% { transform: translateX(-30px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }

/* hand holding the card, leaning in to tap then back */
.sim-tap-hand-wrap { position: relative; align-self: center; width: 90px; height: 90px; display: grid; place-items: center; }
.sim-tap-hand { position: relative; font-size: 2.4rem; animation: sim-lean 2.6s ease-in-out infinite; }
.sim-tap-card { position: absolute; right: -10px; top: 4px; font-size: 1.5rem; transform: rotate(18deg); }
@keyframes sim-lean { 0%,100% { transform: translateX(-6px); } 45%,60% { transform: translateX(14px); } }
/* contactless waves emanating toward the terminal */
.sim-wave { position: absolute; right: 6px; top: 50%; width: 14px; height: 34px; border: 2px solid #22e88a; border-left: 0;
  border-radius: 0 22px 22px 0; transform: translateY(-50%); opacity: 0; animation: sim-wave 2.6s ease-out infinite; }
@keyframes sim-wave { 0% { opacity: 0; transform: translateY(-50%) scale(.4) translateX(-6px); } 45% { opacity: .9; } 75% { opacity: 0; transform: translateY(-50%) scale(1.3) translateX(10px); } 100% { opacity: 0; } }

/* card terminal on a merchant counter */
.sim-tap-counter { position: relative; text-align: center; }
.sim-terminal { width: 84px; margin: 0 auto; background: linear-gradient(180deg,#1a2230,#0d1420); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px 12px 6px 6px; padding: 8px 8px 10px; box-shadow: 0 10px 24px -10px rgba(0,0,0,.6); animation: sim-pop .5s .3s both; }
.sim-terminal-screen { background: #04120b; border: 1px solid rgba(0,210,106,.25); border-radius: 6px; height: 46px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; overflow: hidden; }
.sim-terminal-amt { font-size: 13px; font-weight: 800; color: #cdeee0; font-family: ui-monospace, monospace; animation: sim-amt-out 2.6s infinite; }
.sim-terminal-approved { font-size: 9px; font-weight: 800; letter-spacing: .05em; color: #22e88a; opacity: 0; animation: sim-approved 2.6s infinite; }
@keyframes sim-amt-out { 0%,55% { opacity: 1; } 65%,100% { opacity: .25; } }
@keyframes sim-approved { 0%,55% { opacity: 0; transform: scale(.7); } 70% { opacity: 1; transform: scale(1.1); } 85%,100% { opacity: 1; transform: scale(1); } }
.sim-terminal-keys { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }
.sim-terminal-keys span { width: 14px; height: 8px; border-radius: 2px; background: rgba(255,255,255,.1); }
.sim-counter-top { width: 120px; height: 8px; margin: 6px auto 0; border-radius: 3px;
  background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.04)); }

/* ---------------- money-movement flow ---------------- */
.sim-flow { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-wrap: nowrap; overflow-x: auto; padding: 8px 2px; }
.sim-flow-node { display: flex; flex-direction: column; align-items: center; shrink: 0; animation: sim-pop .5s cubic-bezier(.2,.7,.2,1) both; }
.sim-node-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(0,210,106,.22), rgba(0,210,106,.05)); border: 1px solid rgba(0,210,106,.25); }
@keyframes sim-pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.sim-flow-track { position: relative; flex: 1; min-width: 40px; height: 2px; background: rgba(255,255,255,.12); border-radius: 2px; align-self: flex-start; margin-top: 27px; }
.sim-flow-track::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, #22e88a, transparent); border-radius: 2px; animation: sim-line 2s ease-in-out infinite; }
@keyframes sim-line { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.sim-packet { position: absolute; top: -11px; left: 0; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; color: #041; background: linear-gradient(135deg,#00d26a,#57f7ab);
  padding: 3px 8px; border-radius: 99px; white-space: nowrap; box-shadow: 0 4px 14px -4px rgba(0,210,106,.7);
  animation: sim-travel 2.4s cubic-bezier(.5,0,.5,1) infinite; }
@keyframes sim-travel { 0% { left: 0; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
.sim-flow[data-reverse="1"] .sim-packet { animation-direction: reverse; }
.sim-flow[data-reverse="1"] .sim-flow-track::after { animation-direction: reverse; }

/* ---------------- ledger hub diagram (step 3 animation) ---------------- */
.sim-hub { position: relative; min-height: 230px; display: grid; place-items: center; padding: 10px; }
.sim-hub-center { width: 84px; height: 84px; border-radius: 22px; background: linear-gradient(135deg,#00d26a,#00a957);
  display: grid; place-items: center; box-shadow: 0 12px 34px -8px rgba(0,210,106,.6); z-index: 2; animation: sim-hub-pulse 3s ease-in-out infinite; }
@keyframes sim-hub-pulse { 0%,100% { box-shadow: 0 12px 34px -8px rgba(0,210,106,.5); } 50% { box-shadow: 0 12px 44px -6px rgba(0,210,106,.85); } }
.sim-hub-node { position: absolute; width: 74px; display: flex; flex-direction: column; align-items: center;
  opacity: 0; transition: opacity .5s; }
/* place the five satellites around the hub */
.sim-hub-node[style*="--i:0"] { top: 4%; left: 50%; transform: translateX(-50%); }
.sim-hub-node[style*="--i:1"] { top: 30%; right: 4%; }
.sim-hub-node[style*="--i:2"] { bottom: 6%; right: 16%; }
.sim-hub-node[style*="--i:3"] { bottom: 6%; left: 16%; }
.sim-hub-node[style*="--i:4"] { top: 30%; left: 4%; }
.sim-hub-node.is-shown { opacity: 1; animation: sim-pop .5s cubic-bezier(.2,.7,.2,1) both; }
.sim-hub-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--glass); border: 1px solid rgba(0,210,106,.3); }

/* ---------------- real-time decision engine ---------------- */
.sim-decision { display: flex; align-items: center; gap: clamp(12px, 4vw, 40px); flex-wrap: wrap; justify-content: center; }
.sim-redis { display: flex; flex-direction: column; align-items: center; shrink: 0; }
.sim-redis-core { width: 82px; height: 82px; border-radius: 20px; background: linear-gradient(150deg,#d8362a,#a5231a);
  display: grid; place-items: center; box-shadow: 0 10px 30px -6px rgba(216,54,42,.55); animation: sim-hub-pulse 2s ease-in-out infinite; }
/* stylised Redis stacked-cube mark */
.sim-redis-logo { font-size: 26px; line-height: 1; color: #fff; transform: scaleY(.82); text-shadow: 0 2px 0 rgba(0,0,0,.25); }
@keyframes sim-redis-pulse { 0%,100% { box-shadow: 0 10px 30px -6px rgba(216,54,42,.45); } 50% { box-shadow: 0 12px 40px -4px rgba(216,54,42,.75); } }
.sim-redis-core { animation: sim-redis-pulse 2s ease-in-out infinite; }
.sim-check { cursor: pointer; text-align: left; width: 100%; }
.sim-check.is-open { border-color: rgba(0,210,106,.5); background: rgba(0,210,106,.1); }
.sim-check:hover { border-color: rgba(0,210,106,.4); }
.sim-checks { display: grid; gap: 6px; flex: 1; min-width: 240px; }
.sim-check { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--glass-brd); opacity: 0; transform: translateX(-8px);
  animation: sim-check-in .4s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: var(--d); }
@keyframes sim-check-in { to { opacity: 1; transform: translateX(0); } }
.sim-check-icon { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: rgba(0,210,106,.12); shrink: 0; }
.sim-check-label { font-size: 12px; color: #cbd5e1; flex: 1; }
.sim-check-tick { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,210,106,.2); color: #22e88a; opacity: 0; animation: sim-tick .3s ease forwards; animation-delay: calc(var(--d) + .25s); }
@keyframes sim-tick { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
/* approved response travelling back */
.sim-return-flow { border-top: 1px solid var(--glass-brd); padding-top: 14px; }
.sim-return-chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sim-return-node { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px;
  background: rgba(0,210,106,.08); border: 1px solid rgba(0,210,106,.2); font-size: 11.5px; color: #cbd5e1;
  opacity: 0; animation: sim-check-in .4s cubic-bezier(.2,.7,.2,1) forwards; }

/* ---------------- money-movement flow (How Money Moves lesson) ---------------- */
.sim-money-flow { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0 2px; }
.sim-money-flow.is-none { padding: 4px 0; }
.sim-money-none { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: #94a3b8;
  padding: 8px 14px; border-radius: 12px; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.2); }
.sim-money-node { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; color: #cbd5e1; }
.sim-money-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(0,210,106,.22), rgba(0,210,106,.05)); border: 1px solid rgba(0,210,106,.25); }
.sim-money-track { position: relative; width: 90px; height: 2px; background: rgba(255,255,255,.12); border-radius: 2px; }
.sim-money-track::after { content: ''; position: absolute; inset: 0; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #22e88a, transparent); animation: sim-line 2s ease-in-out infinite; }
.sim-money-coin { position: absolute; top: -11px; left: 0; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg,#00d26a,#57f7ab); color: #041; font-weight: 800; font-size: 12px;
  display: grid; place-items: center; box-shadow: 0 3px 10px -2px rgba(0,210,106,.6); animation: sim-coin 2.4s cubic-bezier(.5,0,.5,1) infinite; }
@keyframes sim-coin { 0% { left: 0; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { left: 100%; opacity: 0; transform: translateX(-100%); } }

/* ---------------- purchase cascade (step 3) ---------------- */
.sim-cascade { display: flex; flex-direction: column; gap: 0; }
.sim-cascade-row { transition: all .4s cubic-bezier(.2,.7,.2,1); }
.sim-cascade-row.is-hidden { opacity: .3; }
.sim-cascade-row.is-shown { animation: sim-drop .5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes sim-drop { 0% { transform: translateY(-10px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
.sim-cascade-arrow { display: grid; place-items: center; color: #57f7ab; height: 22px; opacity: 0; transition: opacity .3s; }
.sim-cascade-arrow.is-shown { opacity: 1; }
.ml-13 { margin-left: 3.25rem; }

/* ---------------- SQL blocks ---------------- */
.sim-sql { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5;
  color: #9ff3c4; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; overflow-x: auto; }

/* ---------------- SSMS-style database ---------------- */
.ssms { background: #0b0f14; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
html.light .ssms { background: #f4f6f9; }
.ssms-titlebar { background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); border-bottom: 1px solid rgba(255,255,255,.1); }
html.light .ssms-titlebar { background: #e7ebf1; }
.ssms-explorer { background: rgba(255,255,255,.02); }
html.light .ssms-explorer { background: #eef1f6; }
.ssms-query { background: rgba(0,0,0,.25); }
html.light .ssms-query { background: #fbfcfe; }
.ssms-status { background: rgba(255,255,255,.02); }

.ssms-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.ssms-grid th { background: rgba(255,255,255,.05); color: #94a3b8; font-weight: 600; text-align: left;
  padding: 7px 12px; border: 1px solid rgba(255,255,255,.08); white-space: nowrap; position: sticky; top: 0; }
html.light .ssms-grid th { background: #dfe4ec; color: #475569; border-color: #cbd3df; }
.ssms-grid td { padding: 6px 12px; border: 1px solid rgba(255,255,255,.06); color: #cbd5e1; white-space: nowrap; }
html.light .ssms-grid td { color: #334155; border-color: #e2e8f0; }
.ssms-grid tbody tr:hover td { background: rgba(0,210,106,.05); }

/* newly-inserted row highlight */
.ssms-new td { animation: ssms-flash 1.4s ease-out; }
.ssms-new td:first-child { border-left: 2px solid #22e88a; }
@keyframes ssms-flash { 0% { background: rgba(0,210,106,.35); } 100% { background: rgba(0,210,106,.06); } }
.ssms-new td { background: rgba(0,210,106,.06); }

/* highlighted columns */
.ssms-key { color: #7dd3fc !important; font-weight: 600; }        /* primary-ish id */
.ssms-id { color: #c4b5fd !important; }                            /* foreign/reference ids */
.ssms-type-cell { text-align: left; }

/* transaction-type pills */
.ssms-type { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
.ssms-type-purchase   { background: rgba(0,210,106,.18); color: #7bf3b4; }
.ssms-type-settle     { background: rgba(96,165,250,.18); color: #93c5fd; }
.ssms-type-payment    { background: rgba(52,211,153,.18); color: #6ee7b7; }
.ssms-type-refund     { background: rgba(251,191,36,.18); color: #fcd34d; }
.ssms-type-return     { background: rgba(251,191,36,.18); color: #fcd34d; }
.ssms-type-reverse,
.ssms-type-reversal   { background: rgba(251,146,60,.18); color: #fdba74; }
.ssms-type-chargeback { background: rgba(244,63,94,.2); color: #fda4af; }
.ssms-type-fee        { background: rgba(168,85,247,.2); color: #d8b4fe; }
.ssms-type-fee_refund { background: rgba(168,85,247,.14); color: #c4b5fd; }
.ssms-type-auth       { background: rgba(148,163,184,.2); color: #cbd5e1; }

.ssms-status-pill { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 10.5px;
  background: rgba(255,255,255,.06); color: #94a3b8; }

/* confirmed vs to-be-confirmed column headers */
.ssms-th-confirmed { color: #7dd3fc !important; }
.ssms-th-tbc { color: #94a3b8; font-style: italic; }
html.light .ssms-th-tbc { color: #64748b; }
.ssms-tbc-tag { display: inline-block; font-size: 8.5px; font-weight: 700; font-style: normal; letter-spacing: .04em;
  padding: 0 4px; border-radius: 4px; vertical-align: middle; margin-left: 3px;
  background: rgba(251,191,36,.16); color: #fcd34d; border: 1px solid rgba(251,191,36,.3); }

/* payment-schedule "just paid" flash */
.sim-sched-flash { animation: sim-sched-flash 1.2s ease-out; }
@keyframes sim-sched-flash { 0% { box-shadow: 0 0 0 0 rgba(0,210,106,.5); } 100% { box-shadow: 0 0 0 8px rgba(0,210,106,0); } }

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sim-tap-hand, .sim-wave, .sim-terminal, .sim-terminal-amt, .sim-terminal-approved,
  .sim-hub-center, .sim-hub-node.is-shown, .sim-flow-track::after, .sim-packet, .sim-node-icon,
  .sim-cascade-row.is-shown, .ssms-new td, .sim-sched-flash, .sim-tap-customer { animation: none !important; }
  .sim-terminal-approved { opacity: 1 !important; }
}
