/* Structural rules only.
   Anything driven by a module field lives in the scoped <style> in module.html.
   Colors arrive as custom properties set there: --sb-blue, --sb-amber,
   --sb-muted, --sb-divider and the per-stat --sb-accent. */

.stats-band {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- Spectrum ruler ---------- */

.stats-band__spectrum-caption {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.4;
}

/* Three stacked rows: zone label (0–16px), axis strip (20–34px),
   band labels (40–56px). */
.stats-band__ruler {
  position: relative;
  height: 56px;
}

.stats-band__axis,
.stats-band__ionizing,
.stats-band__window {
  position: absolute;
  top: 20px;
  height: 14px;
}

/* Fine ticks every 1%, with a baseline under them. */
.stats-band__axis {
  left: 0;
  right: 0;
  background:
    linear-gradient(var(--sb-divider), var(--sb-divider)) left bottom / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, var(--sb-divider) 0 1px, transparent 1px 1%) left bottom / 100% 6px no-repeat;
}

/* Ionizing range, from mid-UV upward. */
.stats-band__ionizing {
  left: 63%;
  right: 0;
  background: repeating-linear-gradient(135deg, var(--sb-amber) 0 1px, transparent 1px 6px);
  opacity: 0.55;
}

.stats-band__zone {
  position: absolute;
  top: 0;
  left: 63%;
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  color: var(--sb-amber);
  white-space: nowrap;
}

/* The T-ray window: a soft fill with viewfinder corners, same language as
   the Timeline module's image frames. */
.stats-band__window {
  left: 30%;
  width: 10%;
  top: 16px;
  height: 22px;
  --sb-corner: 7px;
  background:
    linear-gradient(var(--sb-blue), var(--sb-blue)) left top / var(--sb-corner) 2px no-repeat,
    linear-gradient(var(--sb-blue), var(--sb-blue)) left top / 2px var(--sb-corner) no-repeat,
    linear-gradient(var(--sb-blue), var(--sb-blue)) right top / var(--sb-corner) 2px no-repeat,
    linear-gradient(var(--sb-blue), var(--sb-blue)) right top / 2px var(--sb-corner) no-repeat,
    linear-gradient(var(--sb-blue), var(--sb-blue)) left bottom / var(--sb-corner) 2px no-repeat,
    linear-gradient(var(--sb-blue), var(--sb-blue)) left bottom / 2px var(--sb-corner) no-repeat,
    linear-gradient(var(--sb-blue), var(--sb-blue)) right bottom / var(--sb-corner) 2px no-repeat,
    linear-gradient(var(--sb-blue), var(--sb-blue)) right bottom / 2px var(--sb-corner) no-repeat;
}

.stats-band__window::before {
  content: "";
  position: absolute;
  inset: 4px 4px;
  background: var(--sb-blue);
  opacity: 0.28;
}

.stats-band__band {
  position: absolute;
  top: 40px;
  padding-left: 6px;
  border-left: 1px solid var(--sb-divider);
  font-size: 12px;
  line-height: 16px;
  color: var(--sb-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  box-sizing: border-box;
}

/* The two labels that matter may run past their band's edge on narrow screens. */
.stats-band__band--tray,
.stats-band__band--xray {
  overflow: visible;
}

.stats-band__band--tray {
  color: var(--sb-blue);
  font-weight: 700;
  border-left-color: var(--sb-blue);
}

.stats-band__band--xray {
  color: var(--sb-amber);
  font-weight: 600;
}

/* The probe: a vertical scan line resting on the centre of the T-ray window. */
.stats-band__probe {
  position: absolute;
  top: 12px;
  left: 35%;
  width: 2px;
  height: 30px;
  margin-left: -1px;
  background: var(--sb-blue);
  box-shadow: 0 0 10px 1px var(--sb-blue);
}

@media (max-width: 767px) {
  /* Too tight for every label on a phone: keep T-ray and X-ray. */
  .stats-band__band--minor { color: transparent; }
}

/* ---------- Figures ---------- */

.stats-band__list {
  list-style: none;
  margin: 0 0 0 -21px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  /* Every stat has a hairline on its left (below). The list hangs 21px
     (padding + line) out to the left and clips that strip, so the figure
     that starts each row has no line and sits flush with the band's edge,
     however many rows the grid wraps into. Only the left side is clipped. */
  clip-path: inset(-100px -100px -100px 21px);
}

/* Each figure reads like an instrument column: a hairline on its left. */
.stats-band__stat {
  margin: 0;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--sb-divider);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Share the figure row across every stat in a grid row, so when a phrase
   wraps to two lines the numbers next to it drop to the same baseline and
   all descriptions start at the same height. */
@supports (grid-template-rows: subgrid) {
  .stats-band__stat {
    display: grid;
    grid-row: span 2;
    grid-template-rows: subgrid;
    row-gap: 10px;
  }
}

.stats-band__figure {
  display: flex;
  align-items: flex-end;
}

.stats-band__value {
  margin: 0;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.stats-band__description {
  margin: 0;
  line-height: 1.55;
}

.stats-band__ref {
  font-size: 0.7em;
  font-weight: 700;
  line-height: 0;
  margin-left: 2px;
  color: inherit;
  text-decoration: none;
}

.stats-band__ref:hover,
.stats-band__ref:focus {
  text-decoration: underline;
}

/* ---------- Sources ---------- */

.stats-band__sources {
  border-top: 1px solid;
  font-size: 12px;
  line-height: 1.6;
}

.stats-band__sources > :first-child { margin-top: 0; }
.stats-band__sources > :last-child { margin-bottom: 0; }

/* The theme's global link style sets its own size and family; the sources
   line keeps the surrounding small type. */
.stats-band__sources a {
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  color: inherit;
  text-decoration: underline;
}

/* Screen-reader-only text: the real figure (the visible readout animates)
   and the spectrum description. */
.stats-band__sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Reveal (module.js adds .js-scan, then .is-scanned) ---------- */

.stats-band.js-scan .stats-band__probe {
  left: 0;
  opacity: 0;
  transition: left 1s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease;
}
.stats-band.js-scan.is-scanned .stats-band__probe {
  left: 35%;
  opacity: 1;
}

.stats-band.js-scan .stats-band__window {
  opacity: 0;
  transform: scale(1.35);
  transition: opacity 0.3s ease 0.9s, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) 0.9s;
}
.stats-band.js-scan.is-scanned .stats-band__window {
  opacity: 1;
  transform: none;
}

.stats-band.js-scan .stats-band__band--tray {
  color: var(--sb-muted);
  transition: color 0.3s ease 0.95s;
}
.stats-band.js-scan.is-scanned .stats-band__band--tray {
  color: var(--sb-blue);
}
