/* =========================================================================
   TEAM MODEL DEMO (#teamModelDemo).
   See src/components/TeamModelDemo.astro for the storyboard.
   Timeline: public/js/team-model-demo.js toggles `is-*` classes and
   positions two `.tmd__cursor` elements at runtime.

   Adapts BudgetMultiplayerDemo's two-cursor pattern to a compact headcount
   table, plus a resolve pill (same motif as FinanceRigorDemo). Same
   --xxx-* palette likeness rules as every other demo on the site, plus a
   second player accent (blue) to tell the two collaborators apart.
   ========================================================================= */

.tmd {
  --tmd-canvas: #FAF9F5;
  --tmd-card: #FFFFFF;
  --tmd-border: #DBDBDE;
  --tmd-line: #EAEAEA;
  --tmd-head: #F6F6F7;
  --tmd-ink: #2B2B2B;
  --tmd-ink2: #777777;
  --tmd-accent: #6A5BC6;
  --tmd-green: #2C8E45;
  --tmd-green-soft: #C4EECF;
  --tmd-flash-a: #E3F5E9;
  --tmd-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 pattern has hit before). */
.tmd__stage {
  position: relative; overflow: hidden; width: 100%;
  aspect-ratio: 3 / 2; min-height: 380px; max-width: 640px; margin: 0 auto;
  background: var(--tmd-canvas);
  display: flex; flex-direction: column;
  transition: opacity .5s ease;
}
.tmd.is-out .tmd__stage { opacity: 0; }

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

.tmd__pane { flex: 1; min-height: 0; min-width: 0; padding: 12px 14px; display: flex; flex-direction: column; justify-content: center; }

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

/* ---------- card grid ---------- */
.tmdGrid {
  display: grid; grid-template-columns: 1fr 70px;
  background: var(--tmd-card); border: 1px solid var(--tmd-border); border-radius: 8px;
  overflow: hidden; max-width: 100%;
}
.tmdCell {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 7px 9px; font-size: 10px; color: var(--tmd-ink2);
  border-bottom: 1px solid var(--tmd-line); border-right: 1px solid var(--tmd-line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .3s ease, outline-color .3s ease;
}
.tmdGrid .tmdCell:nth-child(2n) { border-right: none; }
.tmdCell--head { background: var(--tmd-head); font-weight: 500; border-bottom: 1px solid var(--tmd-border); }
.tmdCell--label { justify-content: flex-start; font-weight: 600; color: var(--tmd-ink); }
.tmdCell--val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--tmd-ink); position: relative; }
.tmdCell--total { font-weight: 700; color: var(--tmd-ink); border-top: 1px solid var(--tmd-border); border-bottom: none; }

/* a cell just edited by Player A / Player B — same "just changed" flash
   language as the rest of the site's demos. */
.tmdCell.is-flash-a { outline: 1.5px solid #2C8E45; outline-offset: -1.5px; background: var(--tmd-flash-a); }
.tmdCell.is-flash-b { outline: 1.5px solid #3D6FD6; outline-offset: -1.5px; background: var(--tmd-flash-b); }
.tmd.is-total-flash [data-el="total"] { background: var(--tmd-head); }

/* ---------- presence chips — who's in this model right now ---------- */
.tmdPresence { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.tmdPresence__chip { display: inline-flex; align-items: center; gap: 5px; font-size: 9.5px; font-weight: 500; color: var(--tmd-ink2); }
.tmdPresence__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;
}

/* ---------- the resolve pill — fades in once the round has landed. ---------- */
.tmdResolve {
  margin-top: 12px; display: flex; justify-content: center;
  opacity: 0; transform: translateY(var(--motion-rise));
  transition: opacity var(--motion-base) ease, transform var(--motion-base) var(--ease-enter);
}
.tmd.is-resolved .tmdResolve { opacity: 1; transform: none; }
.tmdResolve__flag {
  font-size: 9.5px; font-weight: 700; color: var(--tmd-green);
  background: #E3F5E9; border: 1px solid var(--tmd-green-soft); border-radius: 999px;
  padding: 5px 12px; white-space: nowrap;
}

/* ---------- cursors — two independent, colored, name-tagged pointers,
   positioned at runtime (JS sets left/top in px via getBoundingClientRect
   against .tmd__stage). Targets sit in the right-hand value column, close
   to the stage's clipped right edge, so the tag renders to the LEFT of
   the arrow to avoid overflowing .tmd__stage's overflow:hidden. ---------- */
.tmd__cursor {
  position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; z-index: 9;
  color: var(--pc);
  transition: left .6s var(--ease-move), top .6s var(--ease-move), opacity .3s ease;
}
.tmd.is-cursorA-visible [data-el="cursorA"],
.tmd.is-cursorB-visible [data-el="cursorB"] { opacity: 1; }
.tmd__cursorArrow { display: block; }
.tmd__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;
}
