/* ============================================================================
   Animated infrastructure diagrams - marketing surfaces only.

   Deliberately CSS/SVG animations rather than a canvas engine or a library:
   the page already ships ~70KB of HTML and adding a motion runtime to draw six
   nodes would be absurd. These are compositor-friendly (transform/opacity only)
   and every one of them stops dead under prefers-reduced-motion.

   The governing rule for this file: ANIMATION MUST CARRY INFORMATION. A packet
   travelling left to right shows a request's path; a reservation bar shrinking
   shows money being spent. Nothing here moves for decoration alone.
   ========================================================================= */

/* ------------------------------------------------------------- 1. routing */
.lc-diag {
  border: 1px solid var(--lc-line);
  border-radius: 14px;
  background: var(--lc-bg-2);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.lc-diag-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.lc-diag-head b { font-size: 12.5px; font-weight: 600; color: var(--lc-ink); }
.lc-diag-head span { font-size: 10.5px; color: var(--lc-ink-4); }

/* The three-column routing flow: client -> gateway -> provider. */
.lc-flow {
  display: grid;
  /* Wires get a FIXED track and nodes get the flexible ones. The previous
     `1fr auto 1fr auto 1fr` gave the flexible track to the wires, which then
     resolved to 0px and drew nothing. */
  grid-template-columns: minmax(0,1fr) 42px minmax(0,1fr) 42px minmax(0,1fr);
  align-items: center;
  gap: 0;
  position: relative;
}
@media (max-width: 620px) {
  .lc-flow { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 620px) {
  /* Stack, because three columns of labelled nodes cannot fit 390px without
     text dropping below 10px. The arrows rotate to point down. */
  .lc-flow { grid-template-columns: 1fr; gap: 10px; }
  .lc-flow .lc-wire {
    height: 22px; width: 2px; justify-self: center;
    background-image: repeating-linear-gradient(
        to bottom, var(--lc-line-2) 0 5px, transparent 5px 9px);
  }
  .lc-flow .lc-wire::after {
    right: 50%; top: auto; bottom: -1px; transform: translateX(50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--lc-line-2);
    border-bottom: 0;
  }
  .lc-flow .lc-wire i { animation-name: lc-wire-v; }
}

.lc-node {
  border: 1px solid var(--lc-line);
  border-radius: 10px;
  background: #fff;
  padding: 11px 12px;
  min-width: 0;
  position: relative;
  z-index: 2;
  transition: border-color .3s var(--lc-ease), box-shadow .3s var(--lc-ease);
}
.lc-node small {
  display: block; font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--lc-ink-4); margin-bottom: 3px;
}
.lc-node b { display: block; font-size: 12px; font-weight: 600; color: var(--lc-ink);
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-node .lc-node-sub { font-size: 10px; color: var(--lc-ink-3); margin-top: 2px;
                        overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* A long model id is the honest label; let it wrap rather than truncate to
   something that looks like a rendering fault. */
.lc-node-model { white-space: normal !important; overflow-wrap: anywhere;
                 line-height: 1.25; }
/* Nodes are equal height and centre-aligned so a two-line model id does not
   leave a dead band under its neighbours. */
.lc-flow .lc-node { display: flex; flex-direction: column; justify-content: center;
                    align-self: stretch; }

/* The wire between nodes. A 2px track with one travelling packet. */
/* The wire must read as a CONNECTION even when the packet is mid-flight or the
   frame is a still screenshot, so it carries a permanent dashed track plus an
   arrowhead. The moving packet rides on top of it. */
.lc-wire {
  height: 2px; width: 100%; justify-self: stretch;
  background-image: repeating-linear-gradient(
      to right, var(--lc-line-2) 0 5px, transparent 5px 9px);
  position: relative; overflow: visible;
}
.lc-wire::after {
  content: ""; position: absolute; right: -1px; top: 50%;
  width: 0; height: 0; transform: translateY(-50%);
  border-left: 6px solid var(--lc-ink-4, #98A2B3);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.lc-wire i {
  position: absolute; top: -2px; left: 0;
  width: 14px; height: 6px; border-radius: 999px;
  background: var(--lc-brand);
  animation: lc-wire-h 2.4s var(--lc-ease) infinite;
  opacity: 0;
}
.lc-wire:nth-of-type(2) i { animation-delay: .55s; }

@keyframes lc-wire-h {
  0%   { left: -14px; opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}
@keyframes lc-wire-v {
  0%   { top: -14px; opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* Gateway pulses when a packet arrives. One keyframe, no continuous motion,
   so six diagrams on a page do not become a light show. */
.lc-node.is-gateway {
  border-color: color-mix(in srgb, var(--lc-brand) 35%, var(--lc-line));
  background: linear-gradient(180deg, #FBFAFF, #fff);
  animation: lc-gate 2.4s var(--lc-ease) infinite;
}
@keyframes lc-gate {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,58,237,0); }
  40%      { box-shadow: 0 0 0 4px rgba(124,58,237,.07); }
}

/* ------------------------------------------------- 2. live provider list */
/* Horizontal auto-fit grid: one line on a wide screen, wrapping on a phone.
   No horizontal scrolling, no marquee. */
.lc-provstrip-wrap { overflow: hidden; }
.lc-provstrip {
  display: grid;
  /* An uncapped auto-fit put 10 chips on the first row and 2 on the second,
     which reads as a mistake. Cap the columns so the set divides evenly
     (12 items -> 2 rows of 6, or 3 rows of 4 on a tablet), then step down. */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 1000px) { .lc-provstrip { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 700px)  { .lc-provstrip { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 460px)  { .lc-provstrip { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.lc-provstrip .lc-provrow b {
  /* Never ellipsise a provider name, but wrap at WORD BOUNDARIES ONLY.
     `overflow-wrap: anywhere` broke names mid-word ("Dee pSe ek"), which is
     worse than an ellipsis. `break-word` only splits a single unbreakable word
     that cannot fit at all. */
  white-space: normal; overflow: visible; text-overflow: clip;
  overflow-wrap: break-word; word-break: normal; hyphens: none;
  line-height: 1.25;
}
/* Give the name the space it needs and let the "connected" label sit under it
   on narrow chips rather than squeezing the name. */
.lc-provstrip .lc-provrow { flex-wrap: wrap; row-gap: 1px; }
.lc-provstrip .lc-provrow b { flex: 1 1 auto; }
.lc-provstrip .lc-provrow {
  border: 1px solid var(--lc-line);
  border-radius: 9px;
  background: #fff;
}

.lc-provlist { display: grid; gap: 1px; background: var(--lc-line); border-radius: 10px;
               overflow: hidden; border: 1px solid var(--lc-line); }
.lc-provrow {
  display: flex; align-items: center; gap: 9px;
  background: #fff; padding: 8px 11px; font-size: 11.5px;
}
.lc-provrow .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--lc-ok);
  flex: 0 0 auto; box-shadow: 0 0 0 0 rgba(18,161,80,.5);
  animation: lc-ping 2.6s ease-out infinite;
}
.lc-provrow:nth-child(2) .dot { animation-delay: .5s; }
.lc-provrow:nth-child(3) .dot { animation-delay: 1.0s; }
.lc-provrow:nth-child(4) .dot { animation-delay: 1.5s; }
.lc-provrow b { flex: 1 1 auto; font-weight: 500; color: var(--lc-ink); min-width: 0;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-provrow span { font-size: 10px; color: var(--lc-ink-4); flex: 0 0 auto; }
@keyframes lc-ping {
  0%   { box-shadow: 0 0 0 0 rgba(18,161,80,.45); }
  70%  { box-shadow: 0 0 0 5px rgba(18,161,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(18,161,80,0); }
}

/* ------------------------------------------------------- 3. wallet spend */
/* A bar that drains and refills, mirroring how a prepaid balance behaves. */
.lc-wallet-live .lc-wallet-bar i {
  width: 100%;
  transform-origin: left center;
  animation: lc-drain 7s var(--lc-ease) infinite;
}
@keyframes lc-drain {
  0%   { transform: scaleX(1);    background: var(--lc-brand); }
  55%  { transform: scaleX(.22);  background: var(--lc-brand); }
  62%  { transform: scaleX(.22);  background: #E8590C; }   /* low-balance warn */
  78%  { transform: scaleX(1);    background: var(--lc-brand); } /* reloaded */
  100% { transform: scaleX(1);    background: var(--lc-brand); }
}

/* Bars grow from the baseline once revealed. --h is the target height. */
.lc-bars i {
  transform-origin: bottom center;
  transform: scaleY(.04);
  opacity: .55;
}
.lc-in .lc-bars i, .lc-reveal.in .lc-bars i {
  animation: lc-grow .7s var(--lc-ease) forwards;
  animation-delay: calc(var(--i2, 0) * 34ms);
}
@keyframes lc-grow {
  to { transform: scaleY(1); opacity: 1; }
}

/* --------------------------------------------- 4. charge breakdown split */
/* Shows provider cost vs our margin as one stacked bar, so the split is
   visible rather than described. Widths come from real percentages. */
.lc-splitbar {
  display: flex; height: 9px; border-radius: 999px; overflow: hidden;
  background: #EDEEF2; margin-top: 10px;
}
.lc-splitbar .cost  { background: #98A2B3; }
.lc-splitbar .margin{ background: var(--lc-brand); }
.lc-splitbar-legend {
  display: flex; gap: 14px; margin-top: 8px; font-size: 10.5px; color: var(--lc-ink-3);
  flex-wrap: wrap;
}
.lc-splitbar-legend i {
  display: inline-block; width: 7px; height: 7px; border-radius: 2px;
  margin-right: 5px; vertical-align: middle;
}

/* ------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .lc-wire i,
  .lc-node.is-gateway,
  .lc-provrow .dot,
  .lc-wallet-live .lc-wallet-bar i,
  .lc-bars i,
  .lc-in .lc-bars i,
  .lc-reveal.in .lc-bars i {
    animation: none !important;
  }
  /* Restore the end state the animation would have produced, so nothing is
     left mid-drain or at 4% height. */
  .lc-bars i { transform: scaleY(1); opacity: 1; }
  .lc-wire i { opacity: 0; }
  .lc-wallet-live .lc-wallet-bar i { transform: none; }
}
