/* ==========================================================================
   TeamTrek — the coverage ribbon
   --------------------------------------------------------------------------
   The BPO and KPO instrument, inside the shared panel frame.

   A service floor is not a list of people. It is a question about the
   clock: at four in the afternoon, how many seats are answering? A table of
   agents cannot show that -- it shows who, not when -- so this draws the
   day itself. Sixteen hours across, a column per hour showing how many of
   the roster are on, the three shift bands underneath, and a line marking
   the moment being read.

   The frame around it lives in panel.css. Everything here is the
   instrument.
   ========================================================================== */

/* The instrument fills the left side of the panel body. It is a column of
   three parts -- the hours, the bands, the footing -- so each part can keep
   its own height while the chart takes what is left. */
.cov {
  display: grid; grid-template-rows: minmax(0, 1fr) auto auto;
  min-width: 0;
  padding: 1rem .875rem .5rem;
}

/* ----------------------------------------------------------- the columns */
.cov__chart {
  position: relative;
  display: grid; grid-template-columns: repeat(var(--hours, 16), minmax(0, 1fr));
  align-items: end; gap: 3px;
  min-height: 0;
}

/* Each hour. The column is the whole slot so the hover target is the hour
   rather than the bar, and the bar grows from the floor. */
.cov__hour {
  position: relative;
  display: flex; align-items: flex-end;
  height: 100%;
  border-radius: var(--r-xs);
}
.cov__hour > span {
  display: block; width: 100%;
  /* 6% floor, so an hour with one seat on is a mark rather than nothing. */
  height: calc(6% + (94% * var(--on, 0) / var(--seats, 8)));
  border-radius: var(--r-xs) var(--r-xs) 2px 2px;
  background: var(--primary-200);
  transition: background-color var(--dur-ui) var(--ease-ui);
}
/* The hour being read. One column carries the colour, so the eye lands on
   the moment the figures in the rail describe. */
.cov__hour.is-now > span { background: var(--primary-500); }
/* Thin cover: the floor is under the line the roster was planned for. */
.cov__hour--thin > span { background: var(--warning-tint); }
.cov__hour--thin.is-now > span { background: var(--warning-fill); }

/* The line the roster was planned for, drawn across the chart rather than
   written beside it. */
.cov__plan {
  position: absolute; left: 0; right: 0;
  bottom: calc(6% + (94% * var(--at, 0) / var(--seats, 8)));
  border-top: 1px dashed var(--neutral-300);
}
.cov__planlabel {
  position: absolute; right: 0; top: -1.125rem;
  font-size: .625rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--neutral-400);
}

/* The moment being read, straight down the chart and the bands. */
.cov__now {
  position: absolute; top: -.25rem; bottom: -.25rem;
  left: var(--at, 50%);
  width: 2px; margin-left: -1px;
  background: var(--primary-600);
  border-radius: 1px;
  transition: left var(--dur-ui) linear;
}
.cov__now::before {
  content: ""; position: absolute; left: 50%; top: -3px;
  width: 7px; height: 7px; margin-left: -3.5px;
  border-radius: 50%; background: var(--primary-600);
}

/* ------------------------------------------------------------- the hours */
.cov__clock {
  display: grid; grid-template-columns: repeat(var(--hours, 16), minmax(0, 1fr));
  gap: 3px;
  margin: .5rem 0 0;
  font-size: .625rem; color: var(--neutral-400);
  font-variant-numeric: tabular-nums;
}
.cov__clock span { text-align: center; }
/* Every other hour is labelled: sixteen labels in this width is a smudge. */
.cov__clock span:nth-child(odd) { color: transparent; }

/* ------------------------------------------------------------- the bands */
.cov__bands {
  position: relative;
  display: grid; gap: .3125rem;
  margin-top: .75rem; padding-top: .75rem;
  border-top: 1px solid var(--neutral-150);
}
.cov__band {
  position: relative;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--neutral-100);
}
/* The shift itself, positioned on the same scale as the chart above it, so
   a band and an hour always line up. */
.cov__band > span {
  position: absolute; top: 0; bottom: 0;
  left: var(--from, 0%); right: calc(100% - var(--to, 100%));
  display: flex; align-items: center;
  padding: 0 .5rem;
  border-radius: var(--r-pill);
  background: var(--primary-100);
  font-size: .625rem; font-weight: 700; color: var(--primary-800);
  white-space: nowrap; overflow: hidden;
}
.cov__band--evening > span { background: var(--primary-50); color: var(--primary-700); }
.cov__band--night > span {
  background: var(--neutral-150); color: var(--neutral-600);
}

@media (prefers-reduced-motion: reduce) {
  .cov__now { transition: none; }
  .cov__hour > span { transition: none; }
}

/* ------------------------------------------------------------- narrower */
@media (max-width: 959px) {
  .cov { padding: .875rem .75rem .5rem; }
  .cov__chart { min-height: 160px; }
  /* Four labels instead of eight: the columns are half the width here. */
  .cov__clock span:not(:nth-child(4n+1)) { color: transparent; }
}

/* --------------------------------------------------------------- phones */
/* Nothing under 12px. The clock drops to every fourth hour to pay for it,
   and the roster label moves inside the chart where there is room. */
@media (max-width: 599px) {
  .cov { padding: .75rem .625rem .5rem; }

  /* Every fourth hour, and said positively: the rule above hides the odd
     ones, so a :not() here left the whole clock blank. */
  .cov__clock { font-size: .75rem; }
  .cov__clock span { color: transparent; }
  .cov__clock span:nth-child(4n+1) { color: var(--neutral-500); }

  /* The roster label is positioned on the dashed line itself, so there is
     nowhere on a 339px chart to put it that is not over a column. It comes
     off, and the rail underneath says the same thing in a sentence: "7 of
     8 seats on, at or above the roster". */
  .cov__planlabel { display: none; }

  .cov__bands { margin-top: 1.5rem; }
  .cov__band { height: 26px; }
  /* The windows come off the labels rather than the labels coming off the
     bands: "Day" and "Evening" fit here, "Day · 09:00–18:00" does not. */
  .cov__band > span { font-size: .75rem; padding: 0 .375rem; }
  .cov__window { display: none; }
  /* The night band is a sliver of the day at this width, and a word inside
     it is three clipped letters. The legend in the rail names it. */
  .cov__band--night > span { font-size: 0; }
}
