/* Question performance heatmap: spreadsheet style.
   Band colours are set at runtime by the palette dropdown; these are fallbacks. */

.hm {
  --hm-band-0-bg: #e5534b; --hm-band-0-fg: #ffffff;
  --hm-band-1-bg: #f0883e; --hm-band-1-fg: #1f2328;
  --hm-band-2-bg: #f2cc60; --hm-band-2-fg: #1f2328;
  --hm-band-3-bg: #8fce6b; --hm-band-3-fg: #1f2328;
  --hm-band-4-bg: #3fa35c; --hm-band-4-fg: #ffffff;
  --hm-none-bg: #f8f9fa;   --hm-none-fg: #adb5bd;

  --hm-line: #dee2e6;
  --hm-ink: #343a40;
  --hm-subset: #b7791f;
}

.hm [hidden] { display: none !important; }

.hm [data-band="0"]    { --hm-bg: var(--hm-band-0-bg); --hm-fg: var(--hm-band-0-fg); }
.hm [data-band="1"]    { --hm-bg: var(--hm-band-1-bg); --hm-fg: var(--hm-band-1-fg); }
.hm [data-band="2"]    { --hm-bg: var(--hm-band-2-bg); --hm-fg: var(--hm-band-2-fg); }
.hm [data-band="3"]    { --hm-bg: var(--hm-band-3-bg); --hm-fg: var(--hm-band-3-fg); }
.hm [data-band="4"]    { --hm-bg: var(--hm-band-4-bg); --hm-fg: var(--hm-band-4-fg); }
.hm [data-band="none"] { --hm-bg: var(--hm-none-bg);   --hm-fg: var(--hm-none-fg); }

/* Toolbar */
.hm-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.75rem; }
.hm-field { display: flex; flex-direction: column; gap: 0.2rem; min-width: 10rem; }
.hm-field-grow { flex: 1 1 14rem; }
.hm-field label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

/* Status bar */
.hm-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.75rem;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}
.hm-chip {
  padding: 0.1rem 0.45rem;
  border-radius: 0.25rem;
  background: #fff3cd;
  color: #7a5200;
  border: 1px solid #f1d98a;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Sheet */
.hm-sheet {
  overflow: auto;
  max-height: 32rem;
  border: 1px solid var(--hm-line);
  border-radius: 0.25rem;
}
.hm[data-subset="true"] .hm-sheet {
  outline: 2px dashed var(--hm-subset);
  outline-offset: 3px;
}

.hm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.hm-table th,
.hm-table td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--hm-line);
  text-align: center;
  white-space: nowrap;
}

/* Header */
.hm-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f1f3f5;
  font-weight: 600;
  color: var(--hm-ink);
  border-bottom: 2px solid var(--hm-ink);
}

/* Frozen first column */
.hm-student {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 11rem;
  max-width: 15rem;
  overflow: hidden;
  text-align: left !important;
  text-overflow: ellipsis;
  font-weight: 500;
  background: #fff;
}
.hm-table thead .hm-student { z-index: 4; }

/* Data cells */
.hm-cell {
  min-width: 3.5rem;
  color: var(--hm-fg);
  background-color: var(--hm-bg);
  cursor: default;
}
.hm-cell[data-band="none"] { font-weight: 400; }
.hm-cell:hover,
.hm-cell:focus-visible { outline: 2px solid var(--hm-ink); outline-offset: -2px; }

/* Totals: a heavy rule separates them from the data */
.hm-total-col { border-left: 2px solid var(--hm-ink) !important; font-weight: 700; }
.hm-total-row { border-top: 2px solid var(--hm-ink) !important; font-weight: 700; }
.hm-table tfoot .hm-student { border-top: 2px solid var(--hm-ink); background: #f1f3f5; font-weight: 700; }
.hm-table thead .hm-total-col { background: #e3e6ea; }

/* "Subset" chip on total labels while filtered */
.hm[data-subset="true"] .hm-total-label::after {
  content: "Subset";
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border-radius: 0.2rem;
  background: #fff3cd;
  color: #7a5200;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: 0.1rem;
}

/* Legend */
.hm-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}
.hm-legend > span:first-child { margin-right: 0.5rem; }
.hm-key {
  min-width: 4rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--hm-line);
  border-left-width: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--hm-fg);
  background: var(--hm-bg);
}
.hm-legend > span:nth-child(2) { border-left-width: 1px; border-radius: 0.25rem 0 0 0.25rem; }
.hm-key[data-band="none"] { margin-left: 1rem; border-left-width: 1px; border-radius: 0.25rem; }

/* Tooltip */
.hm-tooltip {
  position: fixed;
  z-index: 1080;
  max-width: 18rem;
  padding: 0.45rem 0.65rem;
  border-radius: 0.25rem;
  background: #212529;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.hm-tooltip strong { display: block; margin-bottom: 0.1rem; }