/* ==========================================================================
   Statistics deck Week view (RFC #80 §4, issue #135)
   View-specific rules only; the frame, rows and profile splits live in statistics-deck.css.
   Zero-scroll from the Laptop minimum (760 CSS px) up: every text size here follows the box
   it is given (container query units) so nothing overflows a cell.
   ========================================================================== */

.sd-wk .sd-row-graph {
  grid-template-columns: var(--sd-wk-cols, minmax(0, 1fr));
}

/* ---------------------------------------------------------------- KPI tiles */

.sd-wk .sd-wk-kpi {
  container-type: size;
  align-items: flex-start;
  justify-content: center;
  gap: 0.15em;
  line-height: 1.15;
}

.sd-wk-kpi-label,
.sd-wk-kpi-sub {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: clamp(8px, 10cqh, 12px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sd-wk-kpi-label {
  color: var(--color-text-muted, #7c8797);
}

.sd-wk-kpi-sub {
  color: var(--color-text-muted, #7c8797);
}

.sd-wk-kpi-value {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  font-family: "Archivo Black", "Inter", "JetBrains Mono", ui-monospace, sans-serif;
  font-weight: 900;
  font-size: min(var(--sd-kpi-size, 2rem), 38cqh, 17cqw);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--color-text-primary, #eaeaea);
}

.sd-wk-kpi-value.sd-wk-dash,
.sd-wk-kpi-value.sd-wk-pending {
  color: var(--color-text-dim, #454f5e);
}

/* ---------------------------------------------------------------- graph cells */

.sd-wk .sd-wk-graph {
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.35rem;
}

.sd-wk-graph-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 1em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sd-wk-graph-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-primary, #eaeaea);
}

/* Pushed right; when it does not fit it is clipped at its end, never its start. */
.sd-wk-legend {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  display: flex;
  gap: 1em;
  overflow: hidden;
  color: var(--color-text-muted, #7c8797);
  font-size: 10px;
}

.sd-wk-key {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.sd-wk-key i {
  display: inline-block;
  width: 14px;
  height: 8px;
}

.sd-wk-key-current i {
  background: var(--color-telemetry-cyan, #00e5ff);
  opacity: 0.55;
}

.sd-wk-key-previous i {
  height: 2px;
  background: var(--color-text-muted, #7c8797);
}

.sd-wk-key-last-year i {
  height: 0;
  border-top: 2px dashed var(--color-text-primary, #eaeaea);
  opacity: 0.7;
}

/* A text-only entry: a unit, or a reference named with "—" and its reason. */
.sd-wk-key-none i {
  display: none;
}

.sd-wk-body {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------------------------------------------------------------- day × hour heatmap */

.sd-wk-heatmap-wrap {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sd-wk-heatmap {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: max-content repeat(var(--sd-wk-hours, 1), minmax(0, 1fr));
  grid-template-rows: auto repeat(7, minmax(0, 1fr));
  gap: 1px;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.sd-wk-hm-hour {
  overflow: hidden;
  text-align: center;
  color: var(--color-text-dim, #454f5e);
}

.sd-wk-hm-day {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-height: 0;
  padding: 0 0.5em 0 0.2em;
  overflow: hidden;
  white-space: nowrap;
  color: var(--color-text-muted, #7c8797);
}

.sd-wk-hm-day small {
  color: var(--color-telemetry-cyan, #00e5ff);
  font-size: 9px;
}

.sd-wk-hm-day i {
  font-style: normal;
  color: var(--color-warning-amber, #ffb000);
}

.sd-wk-hm-cell {
  min-height: 0;
  background-color: color-mix(
    in srgb,
    var(--color-telemetry-cyan, #00e5ff) calc(var(--sd-wk-level, 0) * 85%),
    var(--color-bg-elevated, #181c22)
  );
}

/* Gap hours, Unreliable days and Estimate day labels carry the shell's shared .sd-swatch-*
   styles (RFC §4.1); these rules only set what the swatch leaves open (the intensity colour). */

/* An open day without data: one hatched band, not a row of zero-traffic cells. */
.sd-wk-hm-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  color: var(--color-text-muted, #7c8797);
  letter-spacing: 0.3em;
}

/* A Closed Day is shown as closed, not as missing data. */
.sd-wk-hm-closed {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  background: var(--color-bg-base, #0a0a0a);
  color: var(--color-text-dim, #454f5e);
  letter-spacing: 0.3em;
}

.sd-wk-hm-scale {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  font-size: 10px;
  color: var(--color-text-muted, #7c8797);
}

.sd-wk-hm-scale i {
  width: 14px;
  height: 8px;
  background-color: color-mix(
    in srgb,
    var(--color-telemetry-cyan, #00e5ff) calc(var(--sd-wk-level, 0) * 85%),
    var(--color-bg-elevated, #181c22)
  );
}

.sd-wk-hm-scale span {
  margin-right: 0.4em;
}

.sd-wk-hm-scale data {
  margin-left: 0.4em;
}

/* ---------------------------------------------------------------- entrance share */

.sd-wk-entrances {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(var(--sd-wk-rows, 1), minmax(0, 2.2em));
  align-content: start;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
}

.sd-wk-entrance {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 4.5em;
  align-items: center;
  gap: 0.6em;
  overflow: hidden;
}

.sd-wk-ent-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-transform: uppercase;
}

.sd-wk-ent-name {
  color: var(--color-text-primary, #eaeaea);
}

.sd-wk-other .sd-wk-ent-name {
  color: var(--color-text-muted, #7c8797);
}

.sd-wk-ent-bar {
  height: 55%;
  max-height: 14px;
  min-height: 2px;
  background: var(--color-bg-elevated, #181c22);
}

.sd-wk-ent-bar i {
  display: block;
  height: 100%;
  background: var(--color-telemetry-cyan, #00e5ff);
  opacity: 0.6;
}

.sd-wk-ent-share {
  text-align: right;
  color: var(--color-text-primary, #eaeaea);
}

/* ---------------------------------------------------------------- short screens */

@media (max-height: 700px) {
  .sd-wk .sd-cell {
    padding: 0.3rem 0.5rem;
  }

  .sd-wk-graph-head {
    font-size: 10px;
  }
}

/* Below the Laptop minimum the deck stacks and scrolls (RFC §3.1). */
@media (max-width: 759.98px) {
  .sd-wk .sd-row-graph {
    grid-template-columns: minmax(0, 1fr);
  }

  .sd-wk .sd-wk-kpi {
    container-type: normal;
  }

  .sd-wk-kpi-value {
    font-size: 1.75rem;
  }

  .sd-wk-kpi-label,
  .sd-wk-kpi-sub {
    font-size: 10px;
  }
}
