/* ==========================================================================
   TeamTrek — the billable stack
   --------------------------------------------------------------------------
   The finance instrument, inside the shared panel frame.

   A firm's week is not a list of matters. It is a proportion: of the hours
   that went in, which ones can be invoiced. A table can state that in a
   column; it cannot show it. A stacked column can -- the billable part and
   the rest of the day drawn on top of each other, five days side by side,
   so a Wednesday that went to internal work is visible before any figure is
   read.

   The frame around it lives in panel.css. Everything here is the
   instrument.
   ========================================================================== */
.stack {
  display: grid; grid-template-rows: minmax(0, 1fr) auto auto;
  min-width: 0;
  padding: 1rem .875rem .5rem;
}

/* ----------------------------------------------------------- the columns */
.stack__cols {
  position: relative;
  display: grid; grid-template-columns: repeat(var(--days, 5), minmax(0, 1fr));
  align-items: end; gap: .75rem;
  min-height: 0;
  padding-inline: .5rem;
}

/* One day. The slot is the full height so the column grows from the floor,
   and the stack inside it is as tall as that day's hours against the
   longest day of the week. */
.stack__day {
  position: relative;
  display: flex; align-items: flex-end;
  height: 100%;
}
.stack__bar {
  display: flex; flex-direction: column-reverse;
  width: 100%;
  height: calc(100% * var(--total) / var(--max));
  border-radius: var(--r-xs) var(--r-xs) 2px 2px;
  overflow: hidden;
}

/* Billable sits at the bottom, where a reader starts, and carries the
   colour. Everything else is the same grey the rest of the catalogue uses
   for time that is recorded but not invoiced. */
.stack__seg {
  display: block; width: 100%;
  height: calc(100% * var(--v) / var(--total));
  transition: background-color var(--dur-ui) var(--ease-ui);
}
.stack__seg--bill { background: var(--primary-400); }
.stack__seg--non  { background: var(--neutral-200); }

/* The day being read. The colour steps up rather than the bar changing
   size, so the proportion a reader is comparing is never altered. */
.stack__day.is-now .stack__seg--bill { background: var(--primary-600); }
.stack__day.is-now .stack__seg--non  { background: var(--neutral-300); }

/* The hours on top of the column, which is where the eye already is. */
.stack__val {
  position: absolute; left: 0; right: 0;
  bottom: calc((100% * var(--total) / var(--max)) + .375rem);
  text-align: center;
  font-size: .6875rem; font-weight: 700; color: var(--neutral-500);
  font-variant-numeric: tabular-nums;
}
.stack__day.is-now .stack__val { color: var(--primary-700); }

/* --------------------------------------------------------------- the days */
.stack__names {
  display: grid; grid-template-columns: repeat(var(--days, 5), minmax(0, 1fr));
  gap: .75rem;
  margin: .5rem 0 0; padding-inline: .5rem;
  font-size: .6875rem; color: var(--neutral-500);
}
.stack__names span { text-align: center; }
.stack__names span.is-now { color: var(--primary-700); font-weight: 700; }

/* --------------------------------------------------------------- the key */
.stack__foot {
  display: flex; align-items: center; gap: 1rem;
  margin: .75rem 0 0; padding-top: .625rem;
  border-top: 1px solid var(--neutral-150);
  font-size: .625rem; color: var(--neutral-500);
}
.stack__key { display: inline-flex; align-items: center; gap: .375rem; }
.stack__key i {
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--primary-400);
}
.stack__key--non i { background: var(--neutral-200); }

@media (prefers-reduced-motion: reduce) {
  .stack__seg { transition: none; }
}

/* ------------------------------------------------------------- narrower */
@media (max-width: 959px) {
  .stack { padding: .875rem .75rem .5rem; }
  .stack__cols { min-height: 180px; gap: .5rem; }
  .stack__names { gap: .5rem; }
}

/* --------------------------------------------------------------- phones */
@media (max-width: 599px) {
  .stack { padding: .75rem .5rem .5rem; }
  .stack__cols { min-height: 150px; gap: .375rem; }
  .stack__names { gap: .375rem; font-size: .75rem; }
  .stack__val { font-size: .75rem; }
  .stack__foot { flex-wrap: wrap; gap: .25rem .75rem; font-size: .75rem; }
}
