/* =========================================================================
   REPORT DRILLDOWN DEMO (#reportDrilldownDemo).
   See src/components/ReportDrilldownDemo.astro for the storyboard.
   Timeline: public/js/report-drilldown-demo.js toggles `is-*` classes and
   positions `.rdd__cursor` at runtime.

   A single steady scene, no crossfade — Actual/Forecast/Budget already
   side by side, then a click opens a trace path to the source records
   behind one figure. Same --xxx-* palette likeness rules as every other
   demo on the site.
   ========================================================================= */

.rdd {
  --rdd-canvas: #FAF9F5;
  --rdd-card: #FFFFFF;
  --rdd-border: #DBDBDE;
  --rdd-line: #EAEAEA;
  --rdd-head: #F6F6F7;
  --rdd-ink: #2B2B2B;
  --rdd-ink2: #777777;
  --rdd-accent: #6A5BC6;
  --rdd-accent-soft: #ECECFF;
  --rdd-red: #B23B3B;
  --rdd-red-soft: #F8E3E3;
}

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

.rdd__topBar {
  flex: none; font-size: 11px; font-weight: 600; color: var(--rdd-ink);
  padding: 12px 14px 9px; border-bottom: 1px solid var(--rdd-line);
  white-space: nowrap;
}
.rdd__pane { flex: 1; min-height: 0; min-width: 0; padding: 18px 20px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.rddHead { margin: 0 0 2px; font-size: 12px; font-weight: 600; color: var(--rdd-ink); }

.rddGrid {
  display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr;
  background: var(--rdd-card); border: 1px solid var(--rdd-border); border-radius: 8px; overflow: hidden;
}
.rddCell {
  display: flex; align-items: center; justify-content: flex-end; gap: 5px;
  padding: 8px 10px; font-size: 10px; color: var(--rdd-ink2);
  border-bottom: 1px solid var(--rdd-line); border-right: 1px solid var(--rdd-line);
}
.rddGrid .rddCell:nth-child(4n) { border-right: none; }
.rddCell--head { background: var(--rdd-head); font-weight: 500; border-bottom: 1px solid var(--rdd-border); }
.rddCell--label { justify-content: flex-start; font-weight: 600; color: var(--rdd-ink); border-bottom: none; }
.rddCell--val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--rdd-ink); border-bottom: none; }
.rddCell--clickable { transition: outline-color .3s ease, background .3s ease; border-radius: 3px; }
.rdd.is-flash .rddCell--clickable { outline: 1.5px solid var(--rdd-accent); outline-offset: -1.5px; background: var(--rdd-accent-soft); }

.rddChev { display: inline-block; font-size: 10px; color: var(--rdd-ink2); margin-right: 3px; transition: transform .3s ease; }
.rdd.is-expanded .rddChev { transform: rotate(90deg); }

.rddVariance {
  align-self: flex-start; font-size: 9.5px; font-weight: 700; color: var(--rdd-red);
  background: var(--rdd-red-soft); border-radius: 999px; padding: 3px 9px;
}

.rddTrace {
  max-height: 0; overflow: hidden; transition: max-height .4s ease;
  background: var(--rdd-card); border: 0 solid var(--rdd-border); border-radius: 8px;
}
.rdd.is-expanded .rddTrace { max-height: 160px; border-width: 1px; }
.rddTrace__label { margin: 0; padding: 8px 12px 4px; font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--rdd-ink2); }
.rddTrace__row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; font-size: 10px; color: var(--rdd-ink); border-top: 1px solid var(--rdd-line);
}
.rddTrace__val { font-variant-numeric: tabular-nums; color: var(--rdd-ink2); }

.rdd__cursor {
  position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; z-index: 9;
  transition: left .6s cubic-bezier(.5, .05, .3, 1), top .6s cubic-bezier(.5, .05, .3, 1), opacity .3s ease;
}
.rdd.is-cursor-visible .rdd__cursor { opacity: 1; }

@media (max-width: 460px) {
  .rdd__stage { aspect-ratio: auto; min-height: 420px; }
  .rddGrid { grid-template-columns: 1.1fr 1fr 1fr 1fr; font-size: 9px; }
}
