/* =========================================================================
   CAPACITY REVIEW DEMO (#capacityReviewDemo) — the "Agree the capacity
   plan with sales leadership" substep on /sales-capacity-planning.
   See src/components/CapacityReviewDemo.astro for the storyboard.
   Timeline: public/js/capacity-review-demo.js toggles `is-*` classes and
   positions `.crd__cursor` / `.crdTip` at runtime.

   A single steady scene (no crossfade — same pattern as
   BudgetMultiplayerDemo): the sales leader's scoped view and finance's
   consolidated strip stay on screen together, because the whole point is
   that they are one model. Same --xxx-* palette (product likeness) as
   every other demo on the site, plus the green sales-side player colour.
   ========================================================================= */

.crd {
  --crd-canvas: #FAF9F5;
  --crd-card: #FFFFFF;
  --crd-border: #DBDBDE;
  --crd-line: #EAEAEA;
  --crd-head: #F6F6F7;
  --crd-ink: #2B2B2B;
  --crd-ink2: #777777;
  --crd-accent: #6A5BC6;
  --crd-accent-soft: #ECECFF;
  --crd-sales: #2C8E45;
  --crd-sales-soft: #E3F5E9;
}

/* 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). */
.crd__stage {
  position: relative; overflow: hidden; width: 100%;
  aspect-ratio: 3 / 2; min-height: 380px; max-width: 640px; margin: 0 auto;
  background: var(--crd-canvas);
  display: flex; flex-direction: column;
  transition: opacity .5s ease;
}
.crd.is-out .crd__stage { opacity: 0; }

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

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

/* ---------- whose view this is, and how far it reaches ---------- */
.crdHead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crdHead__owner { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 600; color: var(--crd-ink); min-width: 0; }
.crdHead__owner i {
  width: 18px; height: 18px; border-radius: 50%; font-style: normal; flex: none;
  font-size: 7px; font-weight: 700; color: #fff; background: var(--c);
  display: inline-flex; align-items: center; justify-content: center;
}
.crdHead__lock {
  flex: none; font-size: 8.5px; font-weight: 600; color: var(--crd-ink2);
  background: var(--crd-head); border: 1px solid var(--crd-border); border-radius: 999px;
  padding: 3px 8px; white-space: nowrap;
}
.crdHead__title { margin: 9px 0 7px; font-size: 12px; font-weight: 600; color: var(--crd-ink); }

/* ---------- card grid — same card-style table as every other demo.
   Every row's last cell carries .crdCell--last rather than an nth-child
   rule, so column changes can't strand a vertical rule. ---------- */
.crdGrid {
  display: grid; grid-template-columns: 1fr 56px 84px;
  background: var(--crd-card); border: 1px solid var(--crd-border); border-radius: 8px;
  overflow: hidden; max-width: 100%;
}
.crdCell {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 7px 8px; font-size: 9.5px; color: var(--crd-ink2);
  border-bottom: 1px solid var(--crd-line); border-right: 1px solid var(--crd-line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .3s ease, outline-color .3s ease;
}
.crdCell--last { border-right: none; }
.crdCell--head { background: var(--crd-head); font-weight: 500; border-bottom: 1px solid var(--crd-border); }
.crdCell--label { justify-content: flex-start; font-weight: 600; color: var(--crd-ink); }
.crdCell--val { font-variant-numeric: tabular-nums; position: relative; }
.crdCell--total { font-weight: 700; color: var(--crd-ink); border-top: 1px solid var(--crd-border); border-bottom: none; }

/* cells she can change vs. cells restricted at the cell level — the
   masked ones read as deliberately withheld, not empty. */
.crdCell--edit { color: var(--crd-ink); font-weight: 600; }
.crdCell--masked { color: #B4B4B0; letter-spacing: .12em; background: repeating-linear-gradient(-45deg, #FBFBFA 0 3px, #F4F4F2 3px 6px); }

/* mid-edit, and just-recalculated — the sales-side green, so her edits
   are visibly hers and finance's roll-up is visibly downstream. */
.crdCell.is-editing {
  outline: 1.5px solid var(--crd-sales); outline-offset: -1.5px;
  background: var(--crd-sales-soft); color: var(--crd-ink);
  animation: crdCellPulse .8s ease-out;
}
@keyframes crdCellPulse {
  0% { box-shadow: 0 0 0 0 rgba(44, 142, 69, .40); }
  70% { box-shadow: 0 0 0 8px rgba(44, 142, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(44, 142, 69, 0); }
}
.crdCell.is-flash { outline: 1.5px solid var(--crd-sales); outline-offset: -1.5px; background: var(--crd-sales-soft); color: var(--crd-ink); }
.crdCell.is-denied { outline: 1.5px solid #C9C9C4; outline-offset: -1.5px; }

/* ---------- finance's consolidated strip ---------- */
.crdConsolidated {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px;
  margin-top: 10px; padding: 8px 10px;
  background: var(--crd-card); border: 1px solid var(--crd-border); border-radius: 8px;
  transition: background .3s ease, border-color .3s ease;
}
.crd.is-consolidated-flash .crdConsolidated { background: var(--crd-accent-soft); border-color: #CFC7EF; }
.crdConsolidated__tag {
  flex: none; font-size: 8px; font-weight: 700; color: var(--crd-accent);
  background: var(--crd-accent-soft); border: 1px solid #CFC7EF; border-radius: 999px; padding: 3px 8px;
}
.crdConsolidated__body { font-size: 9.5px; color: var(--crd-ink2); }
.crdConsolidated__val { font-size: 12px; font-weight: 700; color: var(--crd-ink); font-variant-numeric: tabular-nums; margin: 0 2px; }
.crdConsolidated__live { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 8.5px; font-weight: 600; color: var(--crd-ink2); }
.crdConsolidated__live i { width: 5px; height: 5px; border-radius: 50%; background: var(--crd-sales); animation: crdLive 2s ease-in-out infinite; }
@keyframes crdLive { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- restriction tooltip — positioned at runtime over whichever
   masked cell the cursor lands on, tail pointing down at it. Every
   masked cell sits in the right-hand column near the stage's clipped
   edge, so the bubble is right-anchored by the driver. ---------- */
.crdTip {
  position: absolute; z-index: 10; max-width: 190px;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  background: var(--crd-ink); color: #fff; border-radius: 7px;
  padding: 6px 9px; font-size: 8.5px; font-weight: 500; line-height: 1.35;
  transition: opacity .25s ease, transform .25s ease;
}
.crdTip::after {
  content: ''; position: absolute; top: 100%; right: 14px;
  border: 5px solid transparent; border-top-color: var(--crd-ink);
}
.crd.is-tip-shown .crdTip { opacity: 1; transform: none; }

/* ---------- cursor — hers, name-tagged and coloured like the
   multiplayer demo's players, positioned at runtime (JS sets left/top in
   px via getBoundingClientRect against .crd__stage). Targets sit in the
   right-hand columns near the clipped edge, so the tag renders to the
   LEFT of the arrow. ---------- */
.crd__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;
}
.crd.is-cursor-visible .crd__cursor { opacity: 1; }
.crd__cursorArrow { display: block; }
.crd__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;
}

/* ---------- responsive ---------- */
@media (max-width: 460px) {
  .crdGrid { grid-template-columns: 1fr 46px 62px; }
  .crdHead__lock { display: none; }
  .crdConsolidated__live { display: none; }
}
