/*
 * styleDashboard.css — Session 5 styles: game layout with the dashboard
 * column, card-based KPI panels, stat tiles, budget gauge, stacked bar,
 * legends, hand-rolled SVG charts and the debrief report. Split from
 * style.css to honour the 300-line file cap. The state colour language
 * itself is applied from config by the JS; these classes carry layout,
 * typography and the restrained neutral-plus-accent palette.
 */

/* --- Game layout: map column + dashboard column --- */

.game-layout {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  max-width: 1340px;
}

.game-main {
  flex: 1 1 620px;
  min-width: 460px;
}

.dash-panel {
  flex: 0 0 400px;
  min-width: 320px;
}

@media (max-width: 1000px) {
  .game-layout { flex-wrap: wrap; }
  .dash-panel { flex: 1 1 100%; }
}

/* --- Cards --- */

.card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 0.8rem 1rem 0.9rem;
  margin-bottom: 0.8rem;
  box-shadow: 0 1px 2px rgba(20, 30, 40, 0.04);
}

/* Compact time strip at the top of the panel — label and value inline. */
.card-time { padding: 0.5rem 1rem; }
.card-time .stat { display: flex; align-items: baseline; gap: 0.6rem; }
.card-time .stat-label { margin-bottom: 0; }
.card-time .stat-value { font-size: 1.25rem; }

.card-title {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a919a;
}

/* --- Stat tiles: large legible headline numbers --- */

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.6rem;
  align-items: flex-end;
}

.stat { position: relative; min-width: 7.5rem; }

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: #8a919a;
  margin-bottom: 0.1rem;
}

.stat-value {
  display: block;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.15;
  color: #24303c;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

.stat-small .stat-value { font-size: 1.05rem; font-weight: 600; }

.stat-sub {
  display: block;
  font-size: 0.72rem;
  color: #98a0a8;
  margin-top: 0.1rem;
}

.stat-negative { color: #c62828; }

/* Gentle pulse as each tick's numbers land (no jarring snaps). */
@keyframes stat-pulse {
  0% { color: #2e5e8c; }
  100% { color: inherit; }
}
.stat-value.stat-tick { animation: stat-pulse 0.9s ease; }

/* Budget refusal shake reuses style.css's hud-shake keyframes. */
.stat.shake { animation: hud-shake 0.4s ease; }
.stat.shake .stat-value { color: #c62828; }

/* --- Budget gauge (accent colour reserved for budget/spend) --- */

.gauge {
  height: 0.55rem;
  margin-top: 0.6rem;
  border-radius: 999px;
  background: #e8ebef;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 999px;
  background: #2e5e8c;
  transition: width 0.6s ease;
}

.gauge-note { margin-top: 0.3rem; font-size: 0.72rem; color: #98a0a8; }

/* --- Stacked length-share bar (state colours set from config by JS) --- */

.stacked-bar {
  display: flex;
  height: 1.5rem;
  border-radius: 6px;
  overflow: hidden;
}

.bar-seg { flex-basis: 0; flex-grow: 0; min-width: 0; transition: flex-grow 0.6s ease; }

/* --- Legends --- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin-top: 0.5rem;
}

.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }

.legend-chip { width: 0.7rem; height: 0.7rem; border-radius: 3px; display: inline-block; }

.legend-text { font-size: 0.72rem; color: #6a727b; }

/* Spend-series chips: accent for treatments, RM blue (= ui.rmDotColour). */
.legend-chip-treatment { background: #2e5e8c; }
.legend-chip-rm {
  background: repeating-linear-gradient(90deg,
    #1565c0 0 4px, transparent 4px 7px);
  border-radius: 0;
  height: 3px;
}

/* --- SVG charts --- */

.chart { margin-top: 0.4rem; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: #e7eaee; stroke-width: 1; }
.chart-grid-year { stroke: #eef0f3; }
.chart-axis { stroke: #b9c0c7; stroke-width: 1; }
.chart-y-label { fill: #8a919a; font-size: 10px; text-anchor: end; }
.chart-x-label { fill: #8a919a; font-size: 10px; text-anchor: middle; }
.chart-band { stroke: none; }
.chart-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.chart-line-treatment { stroke: #2e5e8c; }
.chart-line-rm { stroke: #1565c0; stroke-dasharray: 5 4; stroke-width: 2; }

/* --- Debrief report --- */

.debrief {
  max-width: 1340px;
  margin-top: 1.4rem;
  padding-top: 0.4rem;
  border-top: 2px solid #d8dce1;
}

.debrief-title { font-size: 1.25rem; margin: 0.6rem 0 0.15rem; }
.debrief-meta { font-size: 0.85rem; color: #6a727b; margin: 0 0 0.9rem; }

.debrief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.debrief-grid .card { margin-bottom: 0; }
.debrief-score, .card-risk { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .debrief-grid { grid-template-columns: 1fr; }
}

/* Report-scale stat tiles: bigger headline numbers than the live panel. */
.debrief-score .stat-value { font-size: 2.4rem; }
.debrief-spend .stat-value { font-size: 1.5rem; }

/* --- Risk-reveal map --- */

.risk-map { max-width: 760px; margin: 0 auto; }

.risk-road { transition: none; } /* static report — no live recolouring */

/* Acquired masked defects: dashed casing over the risk-ramp colour. */
.risk-acquired {
  fill: none;
  stroke: #c62828;
  stroke-width: 2.4;
  stroke-dasharray: 6 4;
  stroke-linecap: butt;
  pointer-events: none;
}

.risk-legend { margin-top: 0.6rem; }

.risk-ramp {
  display: inline-block;
  width: 5.5rem;
  height: 0.7rem;
  border-radius: 3px;
  /* Endpoints match debrief.js RAMP_LOW → RAMP_HIGH. */
  background: linear-gradient(90deg, #a9b3bd, #4a148c);
}

.legend-chip-acquired {
  background: repeating-linear-gradient(90deg,
    #c62828 0 6px, transparent 6px 10px);
  border-radius: 0;
  height: 3px;
}

/* --- Tables (per-year summary, share comparison) --- */

.year-table, .compare-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.year-table th, .compare-table th {
  text-align: left;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8a919a;
  border-bottom: 1px solid #d8dce1;
  padding: 0.3rem 0.6rem 0.3rem 0;
}

.year-table td, .compare-table td {
  padding: 0.28rem 0.6rem 0.28rem 0;
  border-bottom: 1px solid #eef0f3;
  color: #3a444e;
}

.year-table .year-forfeited td:nth-child(5) { color: #c62828; }

/* --- Share code --- */

.share-code, .share-input {
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccd2d8;
  border-radius: 6px;
  color: #3a444e;
  background: #fafbfc;
}

.share-row { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

.share-button {
  padding: 0.35rem 0.9rem;
  border: none;
  border-radius: 6px;
  background: #2e5e8c;
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}
.share-button:hover { background: #24496d; }

.share-result { margin-top: 0.6rem; font-size: 0.85rem; }
.share-error { color: #c62828; }
.share-note { font-size: 0.75rem; color: #8a919a; margin: 0.4rem 0 0; }
