/* An explainer animation of a request through the gateway. Two layouts:
   wide (16:9, the website and a landscape video) and reel (9:16, social
   video). ?format=reel picks the vertical one; ?loop=1 restarts at the end
   (the website); ?speed=0.5 slows everything down. */
:root {
  --bg: #0a0a0a; --panel: #141414; --line: #2a2a2a; --fg: #ffffff; --muted: #9ca3af;
  --brand: #ff6b35; --teal: #2dd4bf; --ok: #34d399; --bad: #fb7185; --warn: #fbbf24; --violet: #c084fc; --sky: #38bdf8; --rose: #f472b6;
}
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
svg { display: block; width: 100vw; height: 100vh; }
text { font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Background: a soft gradient, two glows and a faint grid. */
.bg-grid { stroke: rgba(255,107,53,.06); stroke-width: 1; }
.glow { filter: blur(90px); opacity: .55; animation: drift 14s ease-in-out infinite alternate; }
.glow.b { animation-duration: 18s; animation-direction: alternate-reverse; }
@keyframes drift { from { transform: translate(0,0); } to { transform: translate(60px, 40px); } }

/* Nodes: a card with a coloured icon tile and a colour bar on top. */
.node rect.card { fill: var(--panel); stroke: var(--line); stroke-width: 2; rx: 22; transition: stroke .25s, filter .25s; }
.node rect.bar { rx: 4; }
.node .tile { rx: 16; }
.node .icon { fill: none; stroke: #0b0b17; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.node .title { font-weight: 800; fill: var(--fg); }
.node .sub { fill: var(--muted); }
.node.on rect.card { stroke: var(--c); filter: drop-shadow(0 0 18px color-mix(in srgb, var(--c) 55%, transparent)); }
.node.on .tile { animation: pulse .6s ease-out; }
.node.bad rect.card { stroke: var(--bad); filter: drop-shadow(0 0 20px rgba(251,113,133,.6)); }
.node.bad .tile { animation: shake .5s ease-in-out; }
.node.warn rect.card { stroke: var(--warn); filter: drop-shadow(0 0 20px rgba(251,191,36,.6)); }
@keyframes pulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.node .tile, .node .icon { transform-box: fill-box; transform-origin: center; }

/* Wires: dashed, and the dashes run while a packet travels. */
.wire { fill: none; stroke: var(--line); stroke-width: 4; stroke-dasharray: 10 12; stroke-linecap: round; }
.wire.on { stroke: var(--teal); animation: ants .6s linear infinite; }
.wire.on.bad { stroke: var(--bad); }
@keyframes ants { to { stroke-dashoffset: -22; } }

/* Packets: a glowing dot with a tail and a label riding along. */
.pkt .dot { fill: var(--teal); filter: drop-shadow(0 0 10px rgba(45,212,191,.9)); }
.pkt .tail { fill: none; stroke: var(--teal); stroke-width: 6; stroke-linecap: round; opacity: .35; }
.pkt.bad .dot { fill: var(--bad); filter: drop-shadow(0 0 10px rgba(251,113,133,.9)); }
.pkt.bad .tail { stroke: var(--bad); }
.pkt .label rect { fill: rgba(10,10,30,.9); stroke: var(--line); rx: 8; }
.pkt .label text { fill: var(--fg); font-weight: 600; }

/* Badges pop in. */
.badge { transform-box: fill-box; transform-origin: center; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
.badge text { font-weight: 800; fill: #0b0b17; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* The rate-limit meter. */
.meter .track { fill: rgba(255,255,255,.08); rx: 6; }
.meter .fill { fill: var(--ok); rx: 6; transition: width .4s ease, fill .3s; }
.meter text { fill: var(--muted); }

/* Captions slide up; the headline. */
.caption rect { fill: rgba(12,12,34,.94); stroke: var(--line); }
.caption text { font-weight: 650; fill: var(--fg); }
.caption.in { animation: up .4s ease-out; }
@keyframes up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.headline { font-weight: 800; fill: var(--fg); }
.step text { font-weight: 700; }
.fade { transition: opacity .35s; }
.hidden { opacity: 0; }
.brand text { font-weight: 800; }

/* The trace card at the end. */
.trace rect.card { fill: var(--panel); stroke: var(--line); rx: 18; }
.trace .row { fill: var(--muted); }
.trace .row.ok { fill: var(--ok); }
.trace .bar { rx: 6; }
.trace .code { fill: var(--teal); font-weight: 700; }

/* The closing card. */
.closing .big { font-weight: 800; fill: var(--fg); }
.closing .url { fill: var(--teal); font-weight: 700; }
.closing .small { fill: var(--muted); }
@media (prefers-reduced-motion: reduce) { .glow, .wire.on { animation: none; } }
