/* ==========================================================================
   Statistics deck: Day view (RFC #80 §4, issue #134)
   Rules specific to the Day view; the frame, rows and cells come from statistics-deck.css.
   Every box keeps min-height: 0 and clips, so nothing scrolls from 760 CSS px up.
   ========================================================================== */

/* The Room KPI row keeps room for a label, the figure and two comparison lines on short
   screens (RFC §3.5 lets a view adjust its split); the graph rows give way. */
.sd-root[data-granularity="day"] .sd-view[data-profile="room"] {
  grid-template-rows: minmax(96px, 12fr) minmax(0, 55fr) minmax(0, 33fr);
}

/* Room: the lead row gives visitors by hour more width than people inside. */
.sd-day-row[data-graphs="hourly inside"] {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

/* ---------------------------------------------------------------- KPI tiles */

.sd-root .sd-day-kpi {
  /* Safe centring: if a tile ever runs short it clips at the bottom, never over the label. */
  justify-content: safe center;
  align-items: stretch;
  gap: 0.3rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.sd-day-kpi-label {
  display: flex;
  gap: 0.6em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--color-text-muted, #7c8797);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sd-day-tag {
  color: var(--color-telemetry-cyan, #00e5ff);
}

.sd-day-kpi-value {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-primary, #eaeaea);
  /* The row height follows the viewport height, so the figure does too. */
  font-size: min(var(--sd-kpi-size, 2.5rem), 3.8vh);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.sd-view[data-profile="laptop"] .sd-day-kpi-value {
  font-size: min(var(--sd-kpi-size, 3rem), 7vh);
}

/* An entrance name is text, not a figure: smaller, so more of it shows. */
.sd-view .sd-day-kpi[data-kpi="topEntrance"] .sd-day-kpi-value {
  font-size: min(calc(var(--sd-kpi-size, 2.5rem) * 0.55), 2.4vh);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.sd-day-kpi-lines {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
  letter-spacing: 0.05em;
  line-height: 1.25;
  text-transform: uppercase;
}

.sd-day-kpi-lines li {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-muted, #7c8797);
}

.sd-day-kpi-lines b {
  color: var(--color-text-primary, #eaeaea);
  font-weight: 700;
}

/* Laptop tiles are tall enough for a missing reference's reason to wrap onto a second line
   instead of being cut short on a narrow screen. */
.sd-view[data-profile="laptop"] .sd-day-kpi-lines li.sd-day-missing {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
}

.sd-day-line-label {
  margin-right: 0.6em;
}

.sd-day-kpi-lines .sd-day-missing b,
.sd-day-kpi-lines li.sd-day-missing {
  color: var(--color-text-muted, #7c8797);
  font-weight: 400;
  text-transform: none;
}

/* ---------------------------------------------------------------- graph cells */

.sd-root .sd-day-graph {
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.35rem;
}

.sd-day-graph-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sd-day-graph-head h3 {
  flex: 0 0 auto;
  margin: 0;
  color: var(--color-text-primary, #eaeaea);
  font-size: 12px;
  font-weight: 700;
}

.sd-day-legend {
  display: flex;
  gap: 0.9rem;
  flex: 0 0 auto;
  color: var(--color-text-muted, #7c8797);
}

.sd-day-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.sd-day-swatch {
  display: inline-block;
  width: 14px;
  height: 8px;
}

.sd-day-swatch-bar {
  background: var(--color-telemetry-cyan, #00e5ff);
}

.sd-day-swatch-dash {
  height: 0;
  border-top: 2px dashed var(--color-text-primary, #eaeaea);
}

.sd-day-swatch-outline {
  border: 2px solid var(--color-text-primary, #eaeaea);
}

.sd-day-note {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-muted, #7c8797);
}

.sd-day-graph-body {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------------------------------------------------------------- entrance share */

.sd-day-entrances {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(var(--sd-day-rows, 1), minmax(0, 2.6rem));
  align-content: start;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  font-size: 12px;
}

.sd-day-entrance {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) 5.5em;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  white-space: nowrap;
}

.sd-day-with-yoy .sd-day-entrance {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) 5.5em minmax(0, 1.1fr);
}

.sd-day-entrance-name {
  display: flex;
  gap: 0.4em;
  min-width: 0;
  overflow: hidden;
  color: var(--color-text-primary, #eaeaea);
  text-transform: uppercase;
}

.sd-day-entrance-name > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sd-day-entrance-name small {
  color: var(--color-text-muted, #7c8797);
  font-size: 10px;
}

.sd-day-others .sd-day-entrance-name {
  color: var(--color-text-muted, #7c8797);
}

.sd-day-bar {
  display: block;
  height: 60%;
  max-height: 18px;
  min-height: 4px;
  background: var(--color-bg-elevated, #181c22);
}

.sd-day-bar-fill {
  display: block;
  height: 100%;
}

/* A greyed day's fill carries the shell's shared .sd-swatch-unreliable hatch instead. */
.sd-day-bar-fill:not(.sd-swatch-unreliable) {
  background: var(--color-telemetry-cyan, #00e5ff);
}

.sd-day-others .sd-day-bar-fill:not(.sd-swatch-unreliable) {
  background: var(--color-text-muted, #7c8797);
}

.sd-day-share {
  text-align: right;
  color: var(--color-text-primary, #eaeaea);
  font-variant-numeric: tabular-nums;
}

.sd-day-yoy {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-primary, #eaeaea);
  font-variant-numeric: tabular-nums;
}

.sd-day-yoy.sd-day-missing {
  color: var(--color-text-muted, #7c8797);
  font-size: 11px;
}

/* ---------------------------------------------------------------- Unreliable day */

/* An Unreliable day greys out all its graphs (RFC §4.1); canvases draw in muted grey with the
   shared hatching, and the entrance bars take the shared .sd-swatch-unreliable hatch. */
.sd-day-greyed .sd-day-graph-head h3,
.sd-day-greyed .sd-day-entrance-name,
.sd-day-greyed .sd-day-share,
.sd-day-greyed .sd-day-yoy {
  color: var(--color-text-muted, #7c8797);
}

.sd-day-greyed .sd-day-swatch-bar {
  background: var(--color-text-muted, #7c8797);
}

/* ---------------------------------------------------------------- small screens */

@media (max-width: 759.98px) {
  .sd-day-row[data-graphs="hourly inside"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .sd-day-kpi-value,
  .sd-view[data-profile="laptop"] .sd-day-kpi-value {
    font-size: 1.75rem;
  }

  .sd-day-entrances {
    min-height: 200px;
  }
}
