/* fleetfax /stats family (digest, out-of-service, fleet-age).
 * Shared styling for the three static stats pages. Design tokens come from
 * main.css. House rules honored: near-black on white, sparing red accent,
 * NO colored left-border card accents, full-pill buttons, no gradients here.
 * Charts are built by web/js/stats.js as inline SVG. Light surface only, to
 * match the rest of the site (no dark mode on the marketing surface). */

.sx { max-width: 980px; margin: 0 auto; padding: var(--s-12) 0 var(--s-16); }

.sx-crumbs { font-size: var(--text-sm); color: var(--text-3); margin-bottom: var(--s-8); }
.sx-crumbs a { color: var(--text-3); text-decoration: none; }
.sx-crumbs a:hover { color: var(--brand); }

.sx-head h1 { font-family: var(--font-sans); font-size: var(--text-3xl); font-weight: 600; letter-spacing: -0.02em; margin-bottom: var(--s-3); text-wrap: balance; }
.sx-lede { font-size: var(--text-base); line-height: 1.6; color: var(--text-2); max-width: 64ch; margin-bottom: var(--s-4); }
.sx-asof { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--s-8); }
.sx-asof b { color: var(--text-2); font-weight: 600; }

/* Section scaffolding */
.sx-section { margin-top: var(--s-16); }
.sx-section > h2 { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.01em; margin-bottom: var(--s-2); }
.sx-section-sub { font-size: var(--text-sm); color: var(--text-2); margin-bottom: var(--s-6); max-width: 64ch; }
.sx-block-label { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin: 0 0 var(--s-3); }

/* Horizontal-scroll wrapper so the page body NEVER scrolls sideways */
.sx-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

/* --- Stat tiles (digest hero + OOS national + fleet-age median) --------- */
.sx-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: var(--s-4); }
.sx-tiles--five { grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); }
.sx-tiles--two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.sx-tile { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); padding: var(--s-5); }
.sx-tile-v { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sx-tile-v.sx-big { font-size: var(--text-3xl); }
.sx-tile-v.sx-nodata { font-size: var(--text-lg); color: var(--text-3); font-weight: 500; letter-spacing: 0; }
.sx-tile-sub { font-size: var(--text-xs); color: var(--text-3); margin-top: 4px; font-variant-numeric: tabular-nums; }
.sx-tile-l { font-size: var(--text-sm); font-weight: 600; color: var(--text); margin-top: var(--s-3); }
.sx-tile-note { font-size: var(--text-xs); color: var(--text-3); line-height: 1.5; margin-top: 4px; }

/* --- Per-metric sparkline rows (digest 90-day trend) -------------------- */
.sx-metric { border-top: 1px solid var(--border); padding: var(--s-5) 0; }
.sx-metric:first-child { border-top: none; }
.sx-metric-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-3); }
.sx-metric-name { font-size: var(--text-base); font-weight: 600; }
.sx-metric-latest { font-size: var(--text-sm); color: var(--text-3); font-variant-numeric: tabular-nums; }
.sx-metric-latest b { color: var(--text); font-weight: 600; }
.sx-spark { display: block; width: 100%; height: 46px; }
.sx-spark-axis { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text-3); margin-top: 6px; }

/* Legend for the digest sparkline shades (small, muted, like the status page) */
.sx-spark-legend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin: 0 0 var(--s-5); font-size: var(--text-xs); color: var(--text-3); }
.sx-spark-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.sx-spark-legend-sw { width: 11px; height: 11px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.sx-spark-legend-sw--gap { background: transparent; border: 1px dashed var(--border-strong); }

/* --- Line chart (OOS 24-month trend) ------------------------------------ */
.sx-legend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin: 0 0 var(--s-4); font-size: var(--text-sm); color: var(--text-2); }
.sx-legend-item { display: inline-flex; align-items: center; gap: 7px; }
.sx-legend-sw { width: 13px; height: 3px; border-radius: 2px; display: inline-block; }
.sx-linechart { display: block; width: 100%; height: 260px; }
.sx-line-axis { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text-3); margin-top: 6px; }

/* --- Median-by-fleet-size horizontal bars (fleet-age) ------------------- */
.sx-hbars { display: flex; flex-direction: column; gap: var(--s-5); margin-top: var(--s-2); }
.sx-hbar-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-bottom: 6px; }
.sx-hbar-label { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.sx-hbar-sub { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.sx-hbar-track { display: flex; align-items: center; gap: var(--s-2); min-height: 16px; }
.sx-hbar-fill { height: 14px; background: #48515c; border-radius: 4px; min-width: 2px; flex: 0 0 auto; }
.sx-hbar-val { font-size: var(--text-sm); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sx-hbar-val.sx-nodata { color: var(--text-3); font-weight: 500; }
.sx-dist-basis { font-size: var(--text-xs); color: var(--text-3); line-height: 1.6; margin-top: var(--s-4); }

/* --- Sortable state table (OOS) ----------------------------------------- */
.sx-table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: var(--text-sm); }
.sx-table caption { text-align: left; font-size: var(--text-xs); color: var(--text-3); padding-bottom: var(--s-3); }
.sx-table th, .sx-table td { padding: var(--s-3) var(--s-4); text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.sx-table th:first-child, .sx-table td:first-child { text-align: left; }
.sx-table thead th { position: sticky; top: 0; background: var(--bg); font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border-strong); }
.sx-table td { font-variant-numeric: tabular-nums; }
.sx-table td.sx-nodata { color: var(--text-3); }
.sx-th-btn { display: inline-flex; align-items: center; gap: 5px; background: none; border: none; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; padding: 0; }
.sx-th-btn:hover { color: var(--brand); }
.sx-th-arrow { font-size: 10px; color: var(--text-3); }
.sx-table th[aria-sort="ascending"] .sx-th-btn,
.sx-table th[aria-sort="descending"] .sx-th-btn { color: var(--text); }
.sx-table th[aria-sort="ascending"] .sx-th-arrow,
.sx-table th[aria-sort="descending"] .sx-th-arrow { color: var(--brand); }

/* --- Cross-links + honest empty + footnote ------------------------------ */
.sx-crosslinks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4); margin-top: var(--s-6); }
/* Interactive-card affordance (founder 2026-07-15): the /research hub rp-card
   idiom — background tint on hover + title color shift + pointer (the anchor
   provides the pointer; the whole card IS the anchor). Border darken kept. */
.sx-xlink { display: block; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-5); text-decoration: none; background: var(--bg); transition: border-color .15s ease, background-color .15s ease; }
.sx-xlink:hover { border-color: var(--border-strong); background: var(--bg-alt); }
.sx-xlink-t { font-size: var(--text-base); font-weight: 600; color: var(--text); transition: color .15s ease; }
.sx-xlink:hover .sx-xlink-t { color: var(--text-2); }
.sx-xlink-d { font-size: var(--text-sm); color: var(--text-2); line-height: 1.5; margin-top: 4px; }

.sx-pro { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-alt); padding: var(--s-4) var(--s-5); font-size: var(--text-sm); line-height: 1.55; color: var(--text-2); margin-top: var(--s-8); }
.sx-pro a { color: var(--brand); font-weight: 600; text-decoration: none; }
.sx-pro a:hover { text-decoration: underline; }

.sx-empty { border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--bg-alt); padding: var(--s-8) var(--s-6); text-align: center; color: var(--text-2); font-size: var(--text-sm); line-height: 1.6; }
.sx-empty b { color: var(--text); font-weight: 600; }

.sx-unavail { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-alt); padding: var(--s-8) var(--s-6); text-align: center; color: var(--text-2); font-size: var(--text-base); }

.sx-footnote { font-size: var(--text-xs); color: var(--text-3); line-height: 1.7; margin-top: var(--s-12); padding-top: var(--s-5); border-top: 1px solid var(--border); }

/* Skeleton (truthful, no colored bars, no jokey copy) */
.sx-skel { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-6); }
.sx-skel-line { height: 12px; border-radius: 6px; background: var(--border); animation: sx-pulse 1.4s ease-in-out infinite; }
.sx-skel-line + .sx-skel-line { margin-top: var(--s-4); }
.sx-skel-line.w40 { width: 40%; } .sx-skel-line.w60 { width: 60%; } .sx-skel-line.w80 { width: 80%; }
@keyframes sx-pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .sx-skel-line { animation: none; } }

@media (max-width: 640px) {
  .sx { padding-top: var(--s-8); }
  .sx-head h1 { font-size: var(--text-2xl); }
  .sx-tile-v.sx-big { font-size: var(--text-2xl); }
  /* The OOS table is min-width 560px, so it always scrolls sideways on a phone —
     a right-edge fade hints the extra columns (mask pinned to the scroller's
     visible right edge, unaffected by scroll offset). Scoped to table scrollers
     so the (non-scrolling) trend-chart scroller keeps a crisp edge. */
  .sx-scroll:has(.sx-table) {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }
  /* Sort buttons are the primary control in each header cell — give them a >=40px
     tap target (they were the bare text height). Padding only; type unchanged. */
  .sx-th-btn { min-height: 40px; padding: 8px 0; }
}
