/* CCI Dashboard — page layer.
   Consumes root tokens from kit/valverde-theme.css + kit/styles.css.
   Supplies only the structural layout and behavior the root components
   do not cover: page frame, working tabs, filters, chart canvases,
   equity heatmap, recommendation cards, and the chart modal.
   Load order: kit/fonts/local-fonts.css → kit/valverde-theme.css →
   kit/styles.css → this file. */

/* ---- Page frame ---- */
.cci-page {
  max-width: var(--content);
  margin: 0 auto;
  padding: 118px var(--gutter) 64px;
}

.cci-masthead {
  padding: 34px 0 30px;
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: flex-end;
  border-bottom: 1px solid var(--rule);
}

.cci-masthead h1 {
  margin: 12px 0 0;
  color: var(--blue-night);
  font: 500 clamp(34px, 4.6vw, 56px)/1.02 var(--font-display);
  letter-spacing: -0.045em;
}

.cci-masthead h1 em {
  font: italic 400 0.92em/inherit var(--font-editorial);
  color: var(--blue-deep);
}

.cci-masthead .cci-lede {
  max-width: 66ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.cci-masthead__aside {
  display: grid;
  gap: 8px;
  justify-items: end;
  text-align: right;
  flex-shrink: 0;
}

.cci-masthead__aside .microcopy {
  max-width: 34ch;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.5;
}

/* ---- Global filters ---- */
.cci-filters {
  margin: 24px 0;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.cci-filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font: 700 8px/1 var(--font-display);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.cci-filters select {
  min-width: 170px;
  min-height: 38px;
  padding: 0 10px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font: 500 12px/1 var(--font-body);
}

.cci-filters .cci-filters__note {
  margin-left: auto;
  color: var(--faint);
  font-size: 9px;
  max-width: 30ch;
  text-align: right;
}

/* ---- Working tabs (ARIA tablist in the product chrome) ---- */
.product-chrome { flex-wrap: wrap; }

.product-tabs::-webkit-scrollbar { display: none; }
.product-tabs { overflow-x: auto; scrollbar-width: none; max-width: 100%; }

.product-tab { white-space: nowrap; }

/* ---- Panels ---- */
.cci-panel[hidden] { display: none; }

.cci-panel-note {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 10px;
}

/* ---- Chart cards ---- */
.cci-chart-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.cci-chart-grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.dashboard-card--chart { display: flex; flex-direction: column; }

.cci-canvas {
  position: relative;
  flex: 1;
  min-height: 300px;
  margin-top: 18px;
}

.cci-canvas--tall { min-height: 420px; }
.cci-canvas--short { min-height: 240px; }

.cci-expandable { cursor: zoom-in; transition: box-shadow var(--ease); }
.cci-expandable:hover { box-shadow: var(--shadow-card-hover); }
.cci-expandable:focus-visible { outline: 3px solid var(--blue-light); outline-offset: 3px; }

/* ---- KPI grid: allow 5-up variant, responsive collapse ---- */
.kpi-grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

@media (max-width: 1000px) {
  .kpi-grid, .kpi-grid--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .cci-masthead { flex-direction: column; align-items: flex-start; }
  .cci-masthead__aside { justify-items: start; text-align: left; }
}

@media (max-width: 560px) {
  .kpi-grid, .kpi-grid--5 { grid-template-columns: 1fr; }
  .cci-filters select { min-width: 130px; }
}

/* KPI change signals — non-color cue is the arrow glyph itself */
.cci-change { font-size: 10px; font-weight: 600; }
.cci-change--up { color: var(--success); }
.cci-change--down { color: var(--danger-deep); }
.cci-change--flat { color: var(--muted); }

/* State status chip: colors carry the state dashboard's five levels */
.cci-status {
  min-height: 22px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: #fff;
  font: 700 7px/1 var(--font-display);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* ---- School selector chips ---- */
.cci-school-row {
  margin: 22px 0 0;
  padding: 4px;
  display: inline-flex;
  gap: 4px;
  overflow-x: auto;
  max-width: 100%;
  background: var(--surface-container);
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.cci-school-row button {
  min-height: 34px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  white-space: nowrap;
  font: 600 8px/1 var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cci-school-row button.is-active {
  color: #fff;
  background: var(--blue);
}

/* ---- Equity heatmap ---- */
.cci-heatmap-wrap { margin-top: 20px; overflow-x: auto; }

.cci-heatmap {
  border-collapse: separate;
  border-spacing: 2px;
  min-width: 760px;
}

.cci-heatmap th {
  padding: 8px 8px;
  color: var(--muted);
  border-bottom: 0;
  font: 700 8px/1 var(--font-display);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: center;
}

.cci-heatmap th.cci-heatmap__rowhead {
  text-align: left;
  min-width: 190px;
}

.cci-heatmap td.cci-heatmap__label {
  padding: 6px 10px;
  border-bottom: 0;
  color: var(--ink-soft);
  font: 600 10px/1.3 var(--font-body);
  white-space: nowrap;
}

.cci-heatmap-cell {
  width: 64px;
  height: 34px;
  border-bottom: 0;
  border-radius: 2px;
  text-align: center;
  vertical-align: middle;
  font: 600 10px/1 var(--font-body);
  cursor: default;
}

.cci-heatmap-cell:hover,
.cci-heatmap-cell:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

.cci-heatmap-cell.col-highlight { outline: 2px solid var(--blue); outline-offset: -2px; }
.cci-heatmap th.col-highlight { color: var(--blue); }

/* Heat ramp from the district theme */
.cci-heat-0 { background: var(--kit-heat-1); color: var(--faint); }
.cci-heat-1 { background: var(--kit-heat-2); color: var(--blue-night); }
.cci-heat-2 { background: var(--kit-heat-3); color: #fff; }
.cci-heat-3 { background: var(--kit-heat-4); color: #fff; }
.cci-heat-4 { background: var(--kit-heat-5); color: #fff; }

.cci-heat-legend {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 9px;
}

.cci-heat-legend i {
  width: 14px;
  height: 10px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}

.cci-tooltip {
  position: fixed;
  z-index: 70;
  display: none;
  max-width: 260px;
  padding: 10px 12px;
  color: #fff;
  background: var(--blue-night);
  border-radius: var(--radius);
  box-shadow: var(--shadow-window);
  pointer-events: none;
  font-size: 10px;
  line-height: 1.5;
}

/* ---- Recommendation cards ---- */
.cci-rec-group { margin-top: 30px; }

.cci-rec-group > h3 {
  margin: 0 0 4px;
  color: var(--blue-night);
  font: 600 16px/1.2 var(--font-display);
}

.cci-rec-group > p {
  margin: 0 0 14px;
  color: var(--faint);
  font-size: 10px;
}

.cci-rec {
  margin-bottom: 14px;
  padding: 20px 22px;
  background: var(--surface-elevated);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
}

.cci-rec--critical { border-left-color: var(--danger); }
.cci-rec--high { border-left-color: var(--red); /* district gold */ }

.cci-rec__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
}

.cci-rec__priority {
  min-width: 30px;
  min-height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--blue-night);
  background: var(--surface-container);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font: 700 9px/1 var(--font-display);
}

.cci-rec h4 {
  margin: 0 0 8px;
  color: var(--blue-night);
  font: 600 15px/1.3 var(--font-display);
}

.cci-rec p { margin: 0 0 10px; color: var(--ink-soft); font-size: 11px; }

.cci-rec__impact { color: var(--success); font: 600 10px/1.4 var(--font-body); }

.cci-rec__frame {
  margin: 10px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--rule-strong);
  color: var(--muted);
  font: italic 400 11px/1.5 var(--font-body);
}

.cci-rec details { margin-top: 10px; font-size: 10px; }
.cci-rec summary { color: var(--blue); font-weight: 600; cursor: pointer; }
.cci-rec details p { margin: 8px 0 0; color: var(--muted); }

/* ---- Schedule impact ---- */
.cci-conflict-chip {
  display: inline-flex;
  margin: 2px 3px;
  padding: 3px 8px;
  color: var(--danger-deep);
  background: rgba(var(--kit-danger-rgb), 0.07);
  border: 1px solid rgba(var(--kit-danger-rgb), 0.19);
  border-radius: 999px;
  font: 600 9px/1.4 var(--font-body);
  white-space: nowrap;
}

.cci-singleton td { background: rgba(var(--kit-danger-rgb), 0.04); }

/* ---- Chart modal ---- */
.cci-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  background: rgba(var(--kit-primary-night-rgb), 0.62);
}

.cci-modal-overlay.is-open { display: flex; }

.cci-modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1100px, 96vw);
  max-height: 92vh;
  padding: 24px 26px 22px;
  background: var(--surface-elevated);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  box-shadow: var(--shadow-window);
}

.cci-modal__eyebrow {
  color: var(--muted);
  font: 700 8px/1 var(--font-display);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.cci-modal__title {
  margin: 8px 44px 16px 0;
  color: var(--blue-night);
  font: 600 20px/1.2 var(--font-display);
}

.cci-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font: 400 18px/1 var(--font-body);
}

.cci-modal__close:hover { color: var(--blue-night); background: var(--surface-container); }

.cci-modal__canvas {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-height: 76vh;
}

.cci-modal__canvas canvas { max-width: 100%; max-height: 76vh; }

/* ---- Footer receipt ---- */
.cci-receipt {
  margin-top: 46px;
  padding-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: 9px;
}

.cci-receipt strong { color: var(--muted); font-weight: 600; }

/* ---- Motion & print ---- */
@media (prefers-reduced-motion: reduce) {
  .cci-expandable, .cci-filters select, .cci-school-row button { transition: none; }
  html { scroll-behavior: auto; }
}

@media print {
  .site-header, .cci-filters, .cci-modal-overlay, .product-actions { display: none !important; }
  .cci-page { padding-top: 20px; }
  .product-window { box-shadow: none; }
  .dashboard-card, .queue-card { break-inside: avoid; }
}
