/* ==========================================================================
   K10 Data Visualization — page styles (kit/data-viz.html)
   ========================================================================== */

/* Honest-chart rules ----------------------------------------------------- */
.dv-rules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 10px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.dv-rules__item {
  padding-top: 10px;
  border-top: 2px solid var(--ink);
}

/* Reveal animation --------------------------------------------------------
   data-viz.js sets [data-viz="pending"] until the charts scroll into view,
   then "shown". Without JS the charts are simply static.                  */
.dv {
  margin-top: 40px;
}

.dv .bars__bar {
  transform-origin: bottom;
  transition: transform 560ms cubic-bezier(.16, 1, .3, 1) var(--delay, 0ms);
}

.dv .stack__block {
  transform-origin: bottom;
  transition: transform 360ms ease-out;
}

.dv .funnel__bar {
  transform-origin: left;
  transition: transform 560ms cubic-bezier(.16, 1, .3, 1);
}

.dv[data-viz="pending"] .bars__bar,
.dv[data-viz="pending"] .stack__block {
  transform: scaleY(0);
}

.dv[data-viz="pending"] .funnel__bar {
  transform: scaleX(0);
}

/* KPI tiles -------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.kpi__label {
  font-size: 13px;
  color: var(--ink-2);
}

.kpi__value {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.kpi__delta {
  align-self: flex-start;
}

.kpi__spark {
  display: block;
  width: 100%;
}

.kpi__spark polyline {
  fill: none;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.kpi__spark--pos polyline { stroke: var(--pos); }
.kpi__spark--neg polyline { stroke: var(--neg); }

.kpi__base {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* Chart cards ------------------------------------------------------------ */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 14px;
  margin-top: 14px;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
}

.chart--roomy {
  gap: 14px;
}

.chart__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.chart__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.chart__caption {
  font-size: 13px;
  color: var(--ink-2);
}

.chart__x-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

/* Aligns the x-axis with the plot area (axis column 40px + gap 8px) */
.chart__x-axis--offset {
  padding-left: 48px;
}

/* Vertical bars: height set per bar via --h ----------------------------- */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border-bottom: 1px solid var(--line-2);
}

.bars__bar {
  flex: 1;
  height: var(--h);
  border-radius: 4px 4px 0 0;
  background: var(--c1);
}

.bars__bar--current   { background: var(--ink); }
.bars__bar--detractor { background: var(--neg); }
.bars__bar--passive   { background: var(--line-2); }
.bars__bar--promoter  { background: var(--pos); }

/* MRR chart: y-axis labels + gridded plot */
.mrr {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  height: 200px;
}

.mrr__axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-align: right;
}

.mrr__plot {
  background: linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 50%;
}

/* NPS distribution */
.nps-bars {
  height: 120px;
}

.nps-bars .bars__bar {
  border-radius: 3px 3px 0 0;
}

/* Activation funnel ------------------------------------------------------ */
.funnel {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 70px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.funnel__track {
  height: 22px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
}

.funnel__bar {
  display: block;
  width: var(--w);
  height: 100%;
  border-radius: 4px;
  background: var(--c1);
}

.funnel__pct {
  font-family: var(--font-mono);
  text-align: right;
}

/* Cohort heatmap: cell color = --mix of --c1 into the surface ----------- */
.heatmap {
  display: grid;
  grid-template-columns: 52px repeat(8, minmax(0, 1fr));
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.heatmap__week {
  text-align: center;
  color: var(--ink-3);
}

.heatmap__row-label {
  align-self: center;
  color: var(--ink-3);
}

.heatmap__cell {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 4px;
  background: color-mix(in oklab, var(--c1) var(--mix), var(--surface));
  color: var(--ink);
}

/* Values above 55% get white text for contrast */
.heatmap__cell--strong {
  color: #fff;
}

.heatmap__cell--empty {
  background: var(--surface-2);
}

/* Ship velocity: one block per release, stacked bottom-up --------------- */
.velocity {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  border-bottom: 1px solid var(--line-2);
}

.stack {
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 2px;
  height: 100%;
}

.stack__block {
  height: 18px;
  border-radius: 3px;
}

.stack__block--new      { background: var(--c3); }
.stack__block--improved { background: var(--c1); }
.stack__block--fixed    { background: var(--c2); }

/* Legends ---------------------------------------------------------------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend__swatch {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--swatch);
}

/* Feedback volume: 100% stacked bar + two-column legend ----------------- */
.stacked-bar {
  display: flex;
  height: 28px;
  overflow: hidden;
  border-radius: 6px;
}

.stacked-bar__seg {
  width: var(--w);
  background: var(--swatch);
}

.theme-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.theme-legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-legend__name {
  flex: 1;
}

.theme-legend__value {
  font-family: var(--font-mono);
  color: var(--ink-2);
}
