/* ==========================================================================
   TeamTrek — the commitment grid
   --------------------------------------------------------------------------
   The workforce-planning instrument, inside the shared panel frame.

   Planning is a question about weeks, not about months or people: which
   week is already spoken for and which one still has room. So the figure is
   teams down the side, the next eight weeks across, and one cell for how
   committed that team's week already is.

   Four steps rather than a continuous shade. A planner does not act on the
   difference between 71% and 74%; they act on "full", "nearly full", "some
   room", "free", and four steps say that without pretending to a precision
   the plan does not have.

   The frame around it lives in panel.css. Everything here is the
   instrument.
   ========================================================================== */
.cap {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  padding: .875rem .875rem .5rem;
}

/* The weeks, above the rows. The name column matches the rows' own, so a
   heading sits over its own column. */
.cap__weeks,
.cap__row {
  display: grid;
  grid-template-columns: 8rem repeat(8, minmax(0, 1fr)) 5rem;
  gap: .25rem;
  align-items: center;
}
.cap__weeks {
  margin: 0 0 .5rem;
  font-size: .625rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--neutral-500);
}
.cap__weeks span { text-align: center; }
.cap__weeks span:first-child { text-align: left; }
.cap__weeks span:last-child { text-align: right; }

/* ------------------------------------------------------------- the rows */
.cap__rows { display: grid; grid-auto-rows: minmax(0, 1fr); gap: .25rem; min-height: 0; }

.cap__who { min-width: 0; font-size: .75rem; color: var(--neutral-500); }
.cap__who b {
  display: block;
  font-size: .8125rem; font-weight: 700; color: var(--neutral-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* One team's week. The four steps run from the hue's weight down to
   nothing, so a free week is a gap in the grid rather than another colour
   to decode. */
.cap__cell {
  height: 100%; min-height: 26px;
  border-radius: var(--r-xs);
  background: var(--neutral-100);
  transition: background-color var(--dur-ui) var(--ease-ui);
}
.cap__cell--full { background: var(--primary-700); }
.cap__cell--most { background: var(--primary-500); }
.cap__cell--some { background: var(--primary-300); }
.cap__cell--free { background: var(--primary-100); }

/* The week being read, from the rail. */
.cap__col.is-now .cap__cell,
.cap__cell.is-now { box-shadow: inset 0 0 0 2px var(--primary-800); }
.cap__weeks span.is-now { color: var(--primary-700); }

.cap__free {
  text-align: right;
  font-size: .8125rem; font-weight: 700; color: var(--neutral-900);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- the key */
.cap__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: .375rem 1rem;
  margin: .75rem 0 0; padding-top: .625rem;
  border-top: 1px solid var(--neutral-150);
  font-size: .625rem; color: var(--neutral-500);
}
.cap__key { display: inline-flex; align-items: center; gap: .375rem; }
.cap__key i { width: 11px; height: 11px; border-radius: 3px; background: var(--primary-700); }
.cap__key--most i { background: var(--primary-500); }
.cap__key--some i { background: var(--primary-300); }
.cap__key--free i { background: var(--primary-100); }

@media (prefers-reduced-motion: reduce) {
  .cap__cell { transition: none; }
}

/* ------------------------------------------------------------- narrower */
@media (max-width: 959px) {
  .cap { padding: .75rem .75rem .5rem; }
  .cap__weeks,
  .cap__row { grid-template-columns: 6.5rem repeat(8, minmax(0, 1fr)) 4rem; }
  .cap__rows { grid-auto-rows: 40px; }
}

/* --------------------------------------------------------------- phones */
@media (max-width: 599px) {
  .cap { padding: .625rem .5rem .5rem; }
  .cap__weeks,
  .cap__row { grid-template-columns: 5rem repeat(8, minmax(0, 1fr)) 3.25rem; gap: .1875rem; }
  .cap__weeks { font-size: .75rem; letter-spacing: 0; }
  /* Eight week numbers is a smudge at this width; the ends carry the span
     and the rail names the week being read. */
  .cap__weeks span:not(:first-child):not(:nth-child(2)):not(:last-child):not(:nth-last-child(2)) { font-size: 0; }
  .cap__who b { font-size: .75rem; }
  .cap__who { font-size: 0; }
  .cap__free { font-size: .75rem; }
  .cap__foot { font-size: .75rem; gap: .25rem .75rem; }
}

/* ==========================================================================
   The planner rows, in section 04
   --------------------------------------------------------------------------
   Four teams, one project, and what happens to the quarter when it moves.
   The bars share one scale and each team's capacity is a line across its
   own bar, so a team past its capacity is drawn past the line rather than
   coloured as a mistake.

   The moved project is a second, lighter segment on the end of the bar,
   which is the whole point of the figure: a reader can see which part of
   the length arrived because of their last click.
   ========================================================================== */
.plan__picks {
  display: flex; flex-wrap: wrap; gap: .375rem;
  padding: .875rem 1.25rem 0;
}
.plan__pick {
  padding: .3125rem .75rem;
  border: 1px solid var(--neutral-200); border-radius: var(--r-pill);
  background: #fff;
  font-size: .8125rem; font-weight: 600; color: var(--neutral-600);
  cursor: pointer;
}
.plan__pick:hover { border-color: var(--primary-200); color: var(--neutral-900); }
.plan__pick.is-active {
  background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-800);
}
.plan__pick:focus-visible { outline: 2px solid var(--primary-600); outline-offset: 2px; }

.plan__rows { padding: .75rem 1.25rem 0; }

.plan__row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) 5rem 6.5rem;
  gap: .75rem; align-items: center;
  padding: .4375rem 0;
  border-bottom: 1px solid var(--neutral-150);
}
.plan__row:last-child { border-bottom: 0; }

.plan__who { min-width: 0; font-size: .75rem; color: var(--neutral-500); }
.plan__who b {
  display: block;
  font-size: .8125rem; font-weight: 700; color: var(--neutral-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.plan__bar {
  position: relative;
  display: flex; gap: 2px;
  height: 20px;
  border-radius: var(--r-xs);
  background: var(--neutral-100);
}
.plan__fill {
  flex: 0 0 auto;
  width: calc(var(--w, 0) * 1%);
  border-radius: 2px;
  background: var(--primary-600);
  transition: width var(--dur-ui) var(--ease-ui);
}
/* The project the reader just moved here. */
.plan__fill--moved { background: var(--primary-300); }
/* This team's own capacity, across its own bar. */
.plan__cap {
  position: absolute; top: -3px; bottom: -3px;
  left: calc(var(--t, 100) * 1%);
  width: 0;
  border-left: 2px dashed var(--neutral-400);
}

.plan__hours {
  text-align: right;
  font-size: .8125rem; font-weight: 700; color: var(--neutral-900);
  font-variant-numeric: tabular-nums;
}
.plan__room {
  text-align: right;
  font-size: .8125rem; color: var(--neutral-500);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* Past capacity. Stated, not scolded: no red, no icon, just the number and
   the word. */
.plan__room--over { font-weight: 700; color: var(--neutral-900); }

@media (prefers-reduced-motion: reduce) {
  .plan__fill { transition: none; }
}

@media (max-width: 859px) {
  .plan__row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: .375rem;
  }
  .plan__bar { grid-column: 1 / -1; }
  .plan__hours { grid-column: 1; text-align: left; }
  .plan__room { grid-column: 2; }
}
