/* =========================================================================
   COLLABORATE HERO DEMO (#collaborateHeroDemo).
   See src/components/CollaborateHeroDemo.astro for the storyboard.
   Timeline: public/js/collaborate-hero-demo.js toggles `is-*` classes and
   positions two `.cbd__cursor` elements at runtime.

   Extends BudgetMultiplayerDemo/TeamModelDemo's two-cursor pattern: one
   collaborator edits a value, the other drops a comment, then a
   permissions note lands. Same --xxx-* palette likeness rules as every
   other demo on the site, plus a second player accent (blue).
   ========================================================================= */

.cbd {
  --cbd-canvas: #FAF9F5;
  --cbd-card: #FFFFFF;
  --cbd-border: #DBDBDE;
  --cbd-line: #EAEAEA;
  --cbd-head: #F6F6F7;
  --cbd-ink: #2B2B2B;
  --cbd-ink2: #777777;
  --cbd-flash-a: #E3F5E9;
  --cbd-flash-b: #E7EEFC;
}

.cbd__stage {
  position: relative; overflow: hidden; width: 100%;
  aspect-ratio: 3 / 2; min-height: 380px; max-width: 640px; margin: 0 auto;
  background: var(--cbd-canvas);
  display: flex; flex-direction: column;
  transition: opacity .5s ease;
}
.cbd.is-out .cbd__stage { opacity: 0; }

.cbd__topBar {
  flex: none; font-size: 11px; font-weight: 600; color: var(--cbd-ink);
  padding: 12px 14px 9px; border-bottom: 1px solid var(--cbd-line);
  white-space: nowrap;
}
.cbd__pane { flex: 1; min-height: 0; min-width: 0; padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }

.cbdHead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cbdHead__title2 { font-size: 12px; font-weight: 600; color: var(--cbd-ink); }
.cbdHead__sub { font-size: 9.5px; color: var(--cbd-ink2); }

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

.cbdCell.is-flash-a { outline: 1.5px solid #2C8E45; outline-offset: -1.5px; background: var(--cbd-flash-a); }
.cbdCell.is-flash-b { outline: 1.5px solid #3D6FD6; outline-offset: -1.5px; background: var(--cbd-flash-b); }
.cbd.is-total-flash [data-el="total"] { background: var(--cbd-head); }

/* the comment bubble Marcus drops on Sales instead of editing it. */
.cbdComment {
  position: absolute; left: 8px; top: calc(100% + 4px); z-index: 5;
  background: #fff; border: 1px solid #3D6FD6; color: var(--cbd-ink);
  font-size: 8.5px; font-weight: 500; white-space: nowrap;
  padding: 4px 8px; border-radius: 6px; box-shadow: 0 6px 14px -8px rgba(20,19,15,.35);
  opacity: 0; transform: translateY(-3px); transition: opacity .3s ease, transform .3s ease;
}
.cbd.is-commented .cbdComment { opacity: 1; transform: none; }

.cbdPresence { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.cbdPresence__chip { display: inline-flex; align-items: center; gap: 5px; font-size: 9.5px; font-weight: 500; color: var(--cbd-ink2); }
.cbdPresence__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;
}

.cbdPermissions {
  margin-top: 10px; font-size: 9.5px; font-weight: 600; color: var(--cbd-ink2);
  opacity: 0; transform: translateY(4px); transition: opacity .4s ease, transform .4s ease;
}
.cbd.is-resolved .cbdPermissions { opacity: 1; transform: none; }

.cbd__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;
}
.cbd.is-cursorA-visible [data-el="cursorA"],
.cbd.is-cursorB-visible [data-el="cursorB"] { opacity: 1; }
.cbd__cursorArrow { display: block; }
.cbd__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;
}
