/* ==========================================================================
   Statistics deck: Month view (RFC #80 §3–§4.1, issue #136)
   View-specific rules only; the frame, rows and profile splits live in statistics-deck.css.
   Zero-scroll: every box has min-height: 0 and clips instead of growing.
   ========================================================================== */

/* ---------------------------------------------------------------- rows */

/* Room's lead row: the day-by-day graph gets two thirds, the running total one third. */
.sd-view[data-profile="room"] .sdm-graphs-lead {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

/*
 * Room's month split (RFC #80 §3.5 lets a view adjust its split). One fixed split, not varied
 * by viewport: 17 / 50 / 33 gives the KPI row room for a value and two comparison lines down
 * to about 600 px of height, where the shell's 12% row cannot hold them.
 */
.sd-root[data-granularity="month"] .sd-view[data-profile="room"] {
  grid-template-rows: minmax(0, 17fr) minmax(0, 50fr) minmax(0, 33fr);
}

/* ---------------------------------------------------------------- KPI tiles */

.sd-cell.sdm-kpi {
  align-items: flex-start;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.75rem;
}

.sdm-kpi-label {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--color-text-muted, #7c8797);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.25;
}

.sdm-kpi-value {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  /* The profile sets the size; the viewport height caps it so short screens keep their lines. */
  font-size: min(var(--sd-kpi-size, 2.5rem), 4.4dvh);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--color-text-primary, #eaeaea);
}

.sdm-kpi-lines {
  max-width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
}

.sdm-kpi-line {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted, #7c8797);
}

.sdm-kpi-line > * + * {
  margin-left: 0.4em;
}

.sdm-kpi-line-value {
  color: var(--color-text-primary, #eaeaea);
}

.sdm-kpi-line-reason {
  color: var(--color-text-dim, #454f5e);
}

.sdm-missing .sdm-kpi-line-value,
.sdm-missing > data {
  color: var(--color-text-muted, #7c8797);
}

.sdm-missing .sdm-kpi-line-reason {
  color: var(--color-text-muted, #7c8797);
}

/* ---------------------------------------------------------------- graph cells */

.sd-cell.sdm-graph {
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
}

.sdm-graph-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sdm-graph-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-primary, #eaeaea);
}

.sdm-graph-note {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  overflow: hidden;
  color: var(--color-text-muted, #7c8797);
}

.sdm-graph-body {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.sdm-graph-body > .sd-graph-box {
  align-self: stretch;
}

.sdm-coverage {
  color: var(--color-warning-amber, #ffb000);
}

/* ---------------------------------------------------------------- legend swatches */

/* Legend keys stay whole; a long "—" reason is the part that gives way. */
.sdm-graph-note > .sdm-legend-item {
  flex: 0 0 auto;
}

.sdm-graph-note > .sdm-missing {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sdm-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  white-space: nowrap;
}

.sdm-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
}

.sdm-legend-holiday .sdm-swatch {
  height: 3px;
  background: var(--color-text-primary, #eaeaea);
}

.sdm-legend-closed .sdm-swatch {
  background: color-mix(in srgb, var(--color-text-dim, #454f5e) 35%, transparent);
  outline: 1px solid var(--color-text-dim, #454f5e);
}

.sdm-legend-current .sdm-swatch {
  height: 2px;
  background: var(--color-telemetry-cyan, #00e5ff);
}

.sdm-legend-previous .sdm-swatch {
  height: 2px;
  background: var(--color-text-muted, #7c8797);
}

/* ---------------------------------------------------------------- entrance share */

.sdm-entrances {
  align-self: stretch;
  flex: 1 1 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  /* Rows share the height; they shrink rather than overflow. */
  grid-template-rows: repeat(var(--sdm-rows, 1), minmax(0, 1fr));
  max-height: calc(var(--sdm-rows, 1) * 2.25rem);
  overflow: hidden;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sdm-entrance {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 4.5em minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  white-space: nowrap;
}

.sdm-entrance > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sdm-entrance-name {
  color: var(--color-text-primary, #eaeaea);
}

.sdm-entrance-bar {
  height: 0.6rem;
  background: var(--color-bg-elevated, #181c22);
}

.sdm-entrance-bar > i {
  display: block;
  height: 100%;
  background: var(--color-telemetry-cyan, #00e5ff);
}

.sdm-entrance-share {
  text-align: right;
  color: var(--color-text-primary, #eaeaea);
}

.sdm-entrance-cmp {
  color: var(--color-text-primary, #eaeaea);
}

.sdm-entrance-more {
  display: block;
}

/* ---------------------------------------------------------------- small screens */

@media (max-width: 759.98px) {
  /* Below the Laptop minimum the shell stacks and scrolls; keep that for the month split too. */
  .sd-root[data-granularity="month"] .sd-view[data-profile="room"] {
    grid-template-rows: none;
  }

  .sd-view[data-profile="room"] .sdm-graphs-lead {
    grid-template-columns: minmax(0, 1fr);
  }

  .sdm-kpi-value {
    font-size: var(--sd-kpi-size, 2rem);
  }

  .sdm-entrances {
    max-height: none;
  }
}
