/* ==========================================================================
   K09 · Patterns, K10 · Data Visualization  (kit/patterns.html)
   ========================================================================== */

/* Kit page frame ---------------------------------------------------------- */

/* Sections carry their own padding and hairline, so <main> has none */
.kit-intro {
  max-width: 62ch;
  margin-bottom: 48px;
}

/* Small mono heading inside a kit section, e.g. "STATES" */
.kit-subhead--spaced {
  margin-top: 56px;
}

.kit-footnote {
  margin-top: 24px;
  font: 12px/1.6 var(--w-mono);
  color: var(--w-text-3);
}

/* K09 · Flows ------------------------------------------------------------- */

.flows {
  display: grid;
  gap: 12px;
}

.flow {
  display: grid;
  grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  border: 1px solid rgba(230, 234, 237, .12);
  border-radius: 4px;
  background: #0E1317;
}

@media (max-width: 600px) {
  .flow {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
}

.flow__name {
  margin-bottom: 6px;
  font: 500 16px var(--w-sans);
}

.flow__note {
  font: 12px/1.5 var(--w-mono);
  color: var(--w-text-3);
}

.flow__live {
  display: inline-block;
  margin-top: 8px;
  font: 12px var(--w-mono);
}

.flow__steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Step chip. Modifiers: --cv = conversion step, --em = emergency exit */
.flow__step {
  --step-line: var(--w-line-2);
  --step-bg: transparent;
  position: relative;
  padding: 7px 10px;
  border: 1px solid var(--step-line);
  border-radius: 2px;
  background: var(--step-bg);
  font: 13px var(--w-sans);
  color: var(--w-text);
}

/* Arrow to the next step, drawn in the 6px gap + its own width */
.flow__step:not(:last-child) {
  margin-right: 13px;
}

.flow__step:not(:last-child)::after {
  content: "\2192" / ""; /* → */
  position: absolute;
  top: 50%;
  left: calc(100% + 7px);
  transform: translateY(-50%);
  font: 12px var(--w-mono);
  color: #5B646D;
}

.flow__step--cv {
  --step-line: var(--w-action);
  --step-bg: rgba(139, 125, 255, .14);
}

.flow__step--em {
  --step-line: rgba(230, 80, 85, .6);
  --step-bg: var(--w-emergency-soft);
}

/* K09 · States ------------------------------------------------------------ */

.states {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}

/* --c = state color, --r = dot radius (round = calm, square = attention) */
.state {
  --c: var(--w-text-2);
  --r: 50%;
  padding: 18px;
  border: 1px solid rgba(230, 234, 237, .12);
  border-radius: 4px;
}

.state--loading { --c: var(--w-action); }
.state--error   { --c: var(--w-sev-critical); --r: 0; }
.state--success { --c: var(--w-ok); }
.state--warn    { --c: var(--w-warn); --r: 0; }

.state__kind {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font: 11px var(--w-mono);
  color: var(--c);
}

.state__kind::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--r);
  background: var(--c);
}

.state__title {
  margin-bottom: 6px;
  font: 500 15px var(--w-sans);
}

.state__text {
  font: 13px/1.5 var(--w-sans);
  color: var(--w-text-2);
}

/* K10 · Rules ------------------------------------------------------------- */

.chart-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 48px;
}

.chart-rules li {
  padding: 8px 12px;
  border: 1px solid var(--w-line-2);
  border-radius: 999px;
  font: 13px var(--w-sans);
  color: var(--w-text-2);
}

/* K10 · Chart cards ------------------------------------------------------- */

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  gap: 16px;
}

.chart {
  border: 1px solid var(--w-line-2);
  border-radius: 4px;
  background: var(--w-surface-1);
}

.chart--wide {
  grid-column: 1 / -1;
  overflow-x: auto;
}

.chart__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--w-line);
  font: 12px var(--w-mono);
  color: var(--w-text-2);
}

.chart__head > :first-child {
  color: var(--w-text);
}

.chart__body {
  padding: 14px;
}

.chart__foot {
  padding: 0 14px 14px;
  font: 11px var(--w-mono);
  color: var(--w-text-3);
}

.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  font: 11px var(--w-mono);
  color: var(--w-text-2);
}

.chart__legend span {
  white-space: nowrap;
}

.chart__legend-alt {
  color: #56B4E9;
}

.chart__legend-note {
  margin-left: auto;
  color: var(--w-text-3);
}

/* SVG marks */
.chart__svg {
  width: 100%;
  height: auto;
}

.chart__axis {
  stroke: rgba(230, 234, 237, .25);
}

.chart__grid {
  stroke: rgba(230, 234, 237, .08);
}

.chart__tick {
  fill: var(--w-text-3);
  font: 9px var(--w-mono);
}

.chart__value {
  fill: var(--w-text);
  font: 10px var(--w-mono);
}

.chart__line {
  fill: none;
  stroke: var(--w-action);
  stroke-width: 1.5;
}

/* Second series: colorblind-safe blue, dashed */
.chart__line--alt {
  stroke: #56B4E9;
  stroke-dasharray: 4 3;
}

.chart__point {
  fill: var(--w-action);
}

/* Risk matrix: 1 axis column + 5 likelihood columns */
.risk {
  display: grid;
  grid-template-columns: 20px repeat(5, 1fr);
  gap: 3px;
  padding: 14px;
}

.risk__axis,
.risk__cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1.6;
  border-radius: 1px;
  font: 12px var(--w-mono);
}

.risk__axis {
  color: var(--w-text-3);
}

.risk__cell {
  --a: .1;
  background: rgba(139, 125, 255, var(--a));
  color: var(--w-text);
}

/* Dark text on the saturated cells (likelihood × impact > 12) */
.risk__cell.is-high {
  color: var(--w-canvas);
}

/* Bar chart */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 178px;
  padding: 14px;
}

.bars__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}

.bars__col span {
  font: 10px var(--w-mono);
  color: var(--w-text-2);
  text-align: center;
}

.bars__bar {
  flex: none;
  height: var(--h);
  background: var(--w-action);
  opacity: .75;
}

/* Gantt */
.gantt {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.gantt__row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 10px;
  align-items: center;
  font: 11px var(--w-mono);
}

.gantt__row > span {
  color: var(--w-text-2);
}

.gantt__track {
  position: relative;
  height: 16px;
  background: rgba(230, 234, 237, .04);
}

.gantt__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--l);
  width: var(--w);
}

.gantt__bar--detect  { background: #56B4E9; }
.gantt__bar--contain { background: var(--w-action); }
.gantt__bar--recover { background: #009E73; }

.gantt__row--scale {
  font-size: 10px;
}

.gantt__row .gantt__scale {
  display: flex;
  justify-content: space-between;
  color: var(--w-text-3);
}

/* KPI tiles */
.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--w-line);
}

.kpi {
  padding: 14px;
  background: var(--w-surface-1);
}

.kpi__label {
  margin-bottom: 6px;
  font: 11px var(--w-mono);
  color: var(--w-text-3);
}

.kpi__value {
  margin-bottom: 8px;
  font: 400 22px var(--w-mono);
}

.kpi__spark {
  width: 100%;
  height: 24px;
}

.kpi__spark polyline {
  fill: none;
  stroke: var(--w-action);
  stroke-width: 1.2;
}

/* Sortable data table */
.data-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font: 13px var(--w-mono);
}

.data-table th {
  padding: 0;
  border-bottom: 1px solid var(--w-line-2);
  font-weight: 400;
  text-align: left;
}

.data-table th button {
  width: 100%;
  height: 36px;
  padding: 0 14px;
  border: 0;
  background: none;
  color: var(--w-text-3);
  font: 11px var(--w-mono);
  text-align: left;
}

.data-table th[aria-sort="ascending"] button,
.data-table th[aria-sort="descending"] button {
  color: var(--w-text);
}

.data-table td {
  height: 36px;
  padding: 0 14px;
  border-bottom: 1px solid var(--w-line);
}
