/* ==========================================================================
   TeamTrek — the heat grid
   --------------------------------------------------------------------------
   The healthcare instrument, inside the shared panel frame.

   An admin day has two dimensions, not one. A list of people answers "who",
   and a bar chart of departments answers "how much", but the question a
   practice manager actually asks is where the two cross: which desk is
   under water at eleven, and which one is quiet until two. That is a grid,
   so this draws a grid -- a row per workstream, a column per hour, and a
   cell whose weight is how many people were on it.

   The frame around it lives in panel.css. Everything here is the
   instrument.
   ========================================================================== */
.heat {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  padding: .875rem .875rem .5rem;
}

/* The hours, above the grid. The label column is the same width as the one
   the rows use, so an hour sits over its own column. */
.heat__clock,
.heat__row {
  display: grid;
  grid-template-columns: 9.5rem repeat(var(--hours, 10), minmax(0, 1fr));
  gap: 3px;
  align-items: center;
}
.heat__clock {
  margin: 0 0 .375rem;
  font-size: .625rem; color: var(--neutral-400);
  font-variant-numeric: tabular-nums;
}
.heat__clock span { text-align: center; }
.heat__clock span:first-child { text-align: left; }

/* ------------------------------------------------------------- the rows */
/* The rows take the height the panel gives them rather than a fixed one,
   so the grid fills its half of the frame instead of floating in it. */
.heat__rows {
  display: grid; grid-auto-rows: minmax(0, 1fr);
  gap: 4px; min-height: 0;
}

.heat__name {
  min-width: 0;
  font-size: .75rem; font-weight: 700; color: var(--neutral-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* A cell is one workstream in one hour. The weight carries the reading, so
   the grid is legible before any number is read -- and the whole scale is
   one hue, because five colours on a grid is a map nobody asked for. */
.heat__cell {
  height: 100%; min-height: 26px;
  border-radius: var(--r-xs);
  background: var(--neutral-100);
  transition: background-color var(--dur-ui) var(--ease-ui),
              box-shadow var(--dur-ui) var(--ease-ui);
}
.heat__cell[data-v="1"] { background: var(--primary-100); }
.heat__cell[data-v="2"] { background: var(--primary-200); }
.heat__cell[data-v="3"] { background: var(--primary-400); }
.heat__cell[data-v="4"] { background: var(--primary-600); }

/* The hour being read. The column lifts rather than changing colour, so the
   weight a reader is comparing is never altered by the highlight. */
.heat__cell.is-now {
  box-shadow: inset 0 0 0 2px var(--primary-700);
}
.heat__clock span.is-now { color: var(--primary-700); font-weight: 700; }

/* ------------------------------------------------------------ the scale */
.heat__foot {
  display: flex; align-items: center; gap: .75rem;
  margin: .75rem 0 0; padding-top: .625rem;
  border-top: 1px solid var(--neutral-150);
  font-size: .625rem; color: var(--neutral-500);
}
.heat__scale { display: flex; align-items: center; gap: 3px; }
.heat__scale i {
  width: 18px; height: 10px; border-radius: 2px;
  background: var(--neutral-100);
}
.heat__scale i:nth-child(2) { background: var(--primary-100); }
.heat__scale i:nth-child(3) { background: var(--primary-200); }
.heat__scale i:nth-child(4) { background: var(--primary-400); }
.heat__scale i:nth-child(5) { background: var(--primary-600); }

@media (prefers-reduced-motion: reduce) {
  .heat__cell { transition: none; }
}

/* ------------------------------------------------------------- narrower */
@media (max-width: 959px) {
  .heat { padding: .75rem .75rem .5rem; }
  /* The label column keeps the room the names need -- "Patient
     registration" and "Insurance follow-up" were both being cut at 7rem.
     The hours give the width up and the cells get narrower rather than the
     day getting shorter: the panel says it is showing 08:00 to 18:00, and
     a grid that quietly dropped four of those hours would be making the
     chip above it a lie. */
  .heat__clock,
  .heat__row {
    grid-template-columns: 8.5rem repeat(var(--hours, 10), minmax(0, 1fr));
    gap: 2px;
  }
  .heat__rows { grid-auto-rows: 26px; gap: 2px; }
  .heat__name { font-size: .6875rem; }
  .heat__clock { font-size: .5625rem; }
}

/* --------------------------------------------------------------- phones */
/* The hour labels were 9px here, which is a smudge rather than a number.
   At 12px only every third fits, so only every third is shown -- the cells
   still carry all ten hours, and the sentence under the panel reads them
   out in full. */
@media (max-width: 599px) {
  .heat { padding: .625rem .5rem .5rem; }
  .heat__clock,
  .heat__row { grid-template-columns: 7.5rem repeat(var(--hours, 10), minmax(0, 1fr)); }
  .heat__clock { font-size: .75rem; }
  .heat__clock span:not(:first-child):not(:nth-child(3n+2)) { color: transparent; }
  .heat__name { font-size: .75rem; }
  .heat__rows { grid-auto-rows: 30px; }
  .heat__foot { font-size: .75rem; }
}
