/* =========================================================================
   BUDGET MULTIPLAYER DEMO (#budgetMultiplayerDemo).
   See src/components/BudgetMultiplayerDemo.astro for the storyboard.
   Timeline: public/js/budget-multiplayer-demo.js toggles `is-*` classes and
   positions two `.bmp__cursor` elements at runtime.

   A single steady scene (no crossfade) — the point is two people editing
   the same live vendor-level table at the same time, so the table never
   leaves view. Same --xxx-* palette likeness rules as every other demo on
   this page (webapp_v3 theme), plus a second player accent (blue) to tell
   the two collaborators apart.
   ========================================================================= */

.bmp {
  --bmp-canvas: #FAF9F5;
  --bmp-card: #FFFFFF;
  --bmp-border: #DBDBDE;
  --bmp-line: #EAEAEA;
  --bmp-head: #F6F6F7;
  --bmp-ink: #2B2B2B;
  --bmp-ink2: #777777;
  --bmp-accent: #6A5BC6;
  --bmp-accent-soft: #ECECFF;
  --bmp-flash-a: #E3F5E9;
  --bmp-flash-b: #E7EEFC;
}

/* standard product-demo dimensions (matches every other demo's stage —
   width:100% keeps aspect-ratio from computing width off the min-height
   floor in a narrow container, the bug this page has hit before). */
.bmp__stage {
  position: relative; overflow: hidden; width: 100%;
  aspect-ratio: 3 / 2; min-height: 380px; max-width: 640px; margin: 0 auto;
  background: var(--bmp-canvas);
  display: flex; flex-direction: column;
  transition: opacity .5s ease;
}
.bmp.is-out .bmp__stage { opacity: 0; }

.bmp__topBar {
  flex: none; font-size: 11px; font-weight: 600; color: var(--bmp-ink);
  padding: 12px 14px 9px; border-bottom: 1px solid var(--bmp-line);
  white-space: nowrap;
}

.bmp__pane { flex: 1; min-height: 0; min-width: 0; padding: 12px 14px; display: flex; flex-direction: column; }

/* ---------- panel header ---------- */
.bmpHead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.bmpHead__title2 { font-size: 12px; font-weight: 600; color: var(--bmp-ink); }
.bmpHead__sub { font-size: 9.5px; color: var(--bmp-ink2); }

/* ---------- card grid — same card-style table as the rest of the page ---------- */
.bmpGrid {
  display: grid; grid-template-columns: 1fr 90px;
  background: var(--bmp-card); border: 1px solid var(--bmp-border); border-radius: 8px;
  overflow: hidden; max-width: 100%;
}
.bmpCell {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 6px 8px; font-size: 9.5px; color: var(--bmp-ink2);
  border-bottom: 1px solid var(--bmp-line); border-right: 1px solid var(--bmp-line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .3s ease, outline-color .3s ease;
}
.bmpGrid .bmpCell:nth-child(2n) { border-right: none; }
.bmpCell--head { background: var(--bmp-head); font-weight: 500; border-bottom: 1px solid var(--bmp-border); }
.bmpCell--label { justify-content: flex-start; font-weight: 600; color: var(--bmp-ink); }
.bmpCell--val { font-variant-numeric: tabular-nums; position: relative; }
.bmpCell--total { font-weight: 700; color: var(--bmp-ink); border-top: 1px solid var(--bmp-border); border-bottom: none; }

/* a cell just edited by Player A / Player B — colored to match whichever
   cursor touched it (same colors as PLAYER_A/PLAYER_B in the .astro file),
   same "just changed" flash language as the rest of the page's demos. */
.bmpCell.is-flash-a { outline: 1.5px solid #2C8E45; outline-offset: -1.5px; background: var(--bmp-flash-a); }
.bmpCell.is-flash-b { outline: 1.5px solid #3D6FD6; outline-offset: -1.5px; background: var(--bmp-flash-b); }
.bmp.is-total-flash [data-el="total"] { background: var(--bmp-head); }

/* ---------- presence chips — who's in this budget right now ---------- */
.bmpPresence { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.bmpPresence__chip { display: inline-flex; align-items: center; gap: 5px; font-size: 9.5px; font-weight: 500; color: var(--bmp-ink2); }
.bmpPresence__chip i {
  width: 16px; height: 16px; border-radius: 50%; font-style: normal;
  font-size: 6.5px; font-weight: 700; color: #fff; background: var(--pc);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}

/* ---------- cursors — two independent, colored, name-tagged pointers,
   positioned at runtime (JS sets left/top in px via getBoundingClientRect
   against .bmp__stage) so both can travel to any cell at once. Every
   target in this demo is the right-hand FY27 value column, close to the
   stage's clipped right edge — so the tag renders to the LEFT of the
   arrow (not the more common right-side placement), which keeps it from
   overflowing .bmp__stage's overflow:hidden. */
.bmp__cursor {
  position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; z-index: 9;
  color: var(--pc);
  transition: left .6s cubic-bezier(.5, .05, .3, 1), top .6s cubic-bezier(.5, .05, .3, 1), opacity .3s ease;
}
.bmp.is-cursorA-visible [data-el="cursorA"],
.bmp.is-cursorB-visible [data-el="cursorB"] { opacity: 1; }
.bmp__cursorArrow { display: block; }
.bmp__cursorTag {
  position: absolute; top: 2px; right: calc(100% + 6px);
  background: var(--pc); color: #fff; font-size: 8px; font-weight: 600;
  padding: 2px 6px; border-radius: 999px; white-space: nowrap;
}
