/* 08-pages/_stats.css - stats page-specific layout for the fleet aggregate surface. */

.p-stats__eyebrow {
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.p-stats__availability {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.p-stats__status-title {
  color: var(--text-bright);
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}

.p-stats__section-head {
  display: flex;
  align-items: center;
  gap: 1.2ch;
  margin-block-end: var(--space-md);
}

/* Each section is its own subject, so its header gets air above it — but not the first
   one, which already sits below the page's own header. */
.p-article__section + .p-article__section > .p-stats__section-head {
  margin-block-start: var(--space-xl);
}

.p-stats__section-title {
  color: var(--text-bright);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.p-stats__section-rule {
  flex: 1;
  border-top: var(--bw) solid var(--line);
}

.p-stats__section-note {
  color: var(--text-dim);
  font-size: var(--text-xs);
}

.p-stats__stat-grid,
.p-stats__hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18ch), 1fr));
  gap: var(--space-md);
}

/* Every measured section from supporting roles down is one box per row, and they all
   share this measure so their edges line up as a single column down the page. The
   tables inside carry their own min-width and scroll within their frame, so the cap
   lifts on narrow viewports rather than squeezing them. */
.p-stats__stack {
  display: grid;
  gap: var(--space-md);
  max-width: 66%;
}

@media (max-width: 72rem) {
  .p-stats__stack { max-width: 100%; }
}

/* A callout in the stack is a one-line figure, not prose, so it takes the stack's
   measure rather than the narrower site-wide reading measure it defaults to. */
.p-stats__stack > .c-callout {
  max-width: none;
}

.p-stats__hero {
  border: 3px double var(--accent);
  padding: var(--space-lg) var(--gutter-page) var(--space-xl);
  min-width: 0;
}

.p-stats__hero-lead {
  max-width: 64ch;
  color: var(--text-bright);
  font-size: var(--text-xl);
  line-height: 1.35;
}

.p-stats__hero-lead + .p-stats__hero-lead {
  margin-top: var(--space-md);
}

.p-stats__hero-lead b,
.p-stats__accent { color: var(--accent); }

.p-stats__good { color: var(--good); }
.p-stats__muted { color: var(--text-muted); }

.p-stats__hero-sub {
  max-width: 70ch;
  margin-top: var(--space-xs);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.p-stats__hero-stats { margin-top: var(--space-lg); }

.p-stats__harnesses {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 28rem), 1fr));
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.p-stats__panel-caption {
  max-width: 56ch;
  margin-bottom: var(--space-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.p-stats__chart-frame {
  max-width: 100%;
  overflow-x: auto;
}

.p-stats__histogram {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.6ch;
  height: 210px;
  min-width: 28rem;
  padding-top: var(--space-sm);
  border-bottom: var(--bw) solid var(--line);
}

.p-stats__histogram-bar {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0.4ch;
}

.p-stats__histogram-column {
  width: 100%;
  min-height: 2px;
  background: var(--accent);
}

.p-stats__histogram-column.is-over { background: var(--warn); }

.p-stats__histogram-label {
  color: var(--text-dim);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.p-stats__histogram-marker {
  position: absolute;
  top: 0;
  bottom: 1.4rem;
  border-left: var(--bw) dashed var(--warn);
}

.p-stats__histogram-marker span {
  position: absolute;
  top: -0.1rem;
  left: 0.6ch;
  padding-inline: 0.4ch;
  background: var(--surface-raised);
  color: var(--warn);
  font-size: 0.7rem;
  font-weight: var(--fw-bold);
}

.p-stats__histogram-marker--secondary {
  border-left-color: var(--text-muted);
}

.p-stats__histogram-marker--secondary span {
  color: var(--text-muted);
}

.p-stats__harness-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1ch;
  margin-bottom: var(--space-sm);
}

.p-stats__harness-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text-bright);
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
}

.p-stats__harness-count {
  color: var(--text-dim);
  font-size: var(--text-xs);
}

.p-stats__harness-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-xs);
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: var(--bw) solid var(--line);
}

.p-stats__harness-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.p-stats__harness-value {
  color: var(--text-bright);
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.p-stats__harness-key {
  color: var(--text-dim);
  font-size: 0.68rem;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.p-stats__bars {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.p-stats__bar-row {
  display: grid;
  grid-template-columns: 13ch minmax(0, 1fr) 8ch;
  align-items: center;
  gap: 1ch;
}

.p-stats__bar-label {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.p-stats__bar-track {
  height: 0.7rem;
  min-width: 6rem;
  background: var(--surface-sunken);
  border: var(--bw) solid var(--line);
}

.p-stats__bar-track--stacked {
  display: flex;
  flex-direction: column;
  gap: 1px;
  height: auto;
  padding-block: 1px;
}

.p-stats__bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.p-stats__bar-fill--role {
  height: 0.5rem;
}

/* The flat bucket is a different population from the milestone-split ones, not a bin
   of the same series, so it does not carry the accent. */
.p-stats__bar-fill.is-muted { background: var(--text-muted); }

.p-stats__bar-value {
  color: var(--text-bright);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.p-stats__bar-value small {
  margin-left: 0.5ch;
  color: var(--text-dim);
}

.p-stats__table-frame {
  max-width: 100%;
  overflow-x: auto;
}

.p-stats__data-table {
  min-width: 34rem;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.p-stats__data-table th {
  text-align: right;
}

.p-stats__data-table th:first-child,
.p-stats__data-table td:first-child {
  text-align: left;
}

.p-stats__data-table td {
  text-align: right;
}

.p-stats__data-table td:first-child {
  color: var(--text-muted);
}

.p-stats__data-table .is-median {
  color: var(--text-bright);
  font-weight: var(--fw-bold);
}

.p-stats__data-table .is-highlight {
  color: var(--accent);
}

/* The role bars ride in the table's last column, one stacked track per row, so the
   numbers and their shape read as a single figure rather than two facing boxes. */
.p-stats__chart-column {
  width: 34%;
  padding-left: 2ch;
}

.p-stats__data-table td.p-stats__chart-column {
  text-align: left;
}

.p-stats__data-table .is-good,
.p-stats__harness-value.is-good { color: var(--good); }

.p-stats__data-table .is-warn,
.p-stats__harness-value.is-warn { color: var(--warn); }

@media (max-width: 56rem) {
  .p-stats__section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-2xs);
  }

  .p-stats__section-rule { display: none; }
  .p-stats__bar-row { grid-template-columns: 11ch minmax(0, 1fr) 7ch; }

  /* The five figures stay on one row at every width, so they read as one line of
     numbers rather than a grid with an orphan. They only get smaller. */
  .p-stats__harness-value { font-size: var(--text-sm); }
  .p-stats__harness-key { font-size: 0.6rem; letter-spacing: normal; }
}
