/* Space-themed distribution panels on the index page (see
   static/js/pages/overview-distribution.js). Deliberately shares the banner's
   palette and typography so the page reads as one field from top to bottom. */

/* ---------- platform filter, in the banner's idiom ---------- */
/* Scoped to this section so the buttons elsewhere keep layout.css's styling. */

.glass-card .platform-filter-group {
  /* The heading sits directly above with no margin of its own, so the pills
     were touching it. */
  margin-top: 1.4rem;
  gap: 0;
  padding: 0.28rem;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  border-radius: 999px;
  background: rgba(10, 15, 38, 0.55);
  border: 1px solid rgba(150, 180, 255, 0.22);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.glass-card .platform-filter-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.42rem 1.15rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(198, 214, 255, 0.78);
  transition: color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.glass-card .platform-filter-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.glass-card .platform-filter-btn.active {
  color: #fff;
  background: linear-gradient(180deg, rgba(120, 150, 255, 0.55), rgba(72, 96, 210, 0.55));
  border-color: rgba(170, 195, 255, 0.55);
  /* The lit pill glows the way the galaxy cores do. */
  box-shadow:
    0 0 0 1px rgba(150, 180, 255, 0.25),
    0 0 22px -4px rgba(126, 160, 255, 0.9);
}

#overview-distribution {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.6rem 2.4rem;
}

.dist-panel {
  position: relative;
  --name-col: 8.5rem;            /* kept in step with .dist-row's first column */
  min-width: 0;                  /* grid children default to min-content */
  padding: 1.1rem 1.2rem 1.2rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(150, 180, 255, 0.16);
  /* A faint core glow behind each panel, like a distant nebula, so the four
     read as objects in the field rather than as four lists on a flat card. */
  background:
    radial-gradient(75% 60% at 12% 0%, rgba(96, 126, 255, 0.13) 0%, rgba(9, 12, 32, 0) 70%),
    rgba(8, 12, 30, 0.42);
  overflow: hidden;
}

/* The spectrograph slit: every beam starts on this line, which is what makes
   the panel readable as a spectrum rather than as a bar chart. Anchored to the
   row list so it stops with the rows, not at the panel's edge. */
.dist-rows,
.dist-rest {
  position: relative;
}

.dist-rows::before,
.dist-rest::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--name-col) + 0.7rem);
  width: 1px;
  background: linear-gradient(180deg,
    rgba(150, 180, 255, 0) 0%,
    rgba(150, 180, 255, 0.45) 14%,
    rgba(150, 180, 255, 0.45) 86%,
    rgba(150, 180, 255, 0) 100%);
  pointer-events: none;
}

.dist-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(236, 241, 255, 0.94);
}

.dist-meta {
  margin: 0.2rem 0 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg,
    rgba(150, 180, 255, 0.55), rgba(150, 180, 255, 0)) 1;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: rgba(158, 184, 255, 0.82);
}

.dist-empty {
  color: rgba(200, 214, 255, 0.6);
  font-size: 0.82rem;
}

/* Name | beam | count. The name column is fixed so the beams all start on the
   same line and can be compared down the panel. */
.dist-row {
  display: grid;
  grid-template-columns: var(--name-col) minmax(0, 1fr) 3.6rem;
  align-items: center;
  gap: 0.7rem;
  padding: 0.16rem 0;
  cursor: default;
}

.dist-name {
  font-size: 0.8rem;
  color: rgba(226, 234, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dist-count {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: rgba(180, 200, 255, 0.85);
}

/* The track is the dark sky the emission line sits on. */
.dist-track {
  position: relative;
  height: 0.7rem;
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0));
  background-size: 100% 1px;
  background-position: 0 50%;
  background-repeat: no-repeat;
  overflow: visible;
}

.dist-beam {
  position: absolute;
  top: 50%;
  left: 0;
  height: 0.28rem;
  width: var(--len);
  transform: translateY(-50%) scaleX(0);
  transform-origin: left center;
  border-radius: 999px;
  /* Dim at the origin, full strength at the head: the line reads as light
     travelling outward rather than as a filled bar. */
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--beam) 22%, transparent) 0%,
    color-mix(in srgb, var(--beam) 70%, transparent) 55%,
    var(--beam) 100%);
  box-shadow: 0 0 12px -2px color-mix(in srgb, var(--beam) 65%, transparent);
  overflow: hidden;              /* clips the hover sweep to the beam */
  transition: filter 180ms ease;
}

/* The star at the head of the beam. */
.dist-star {
  position: absolute;
  top: 50%;
  left: var(--len);
  width: 0.5rem;
  height: 0.5rem;
  margin: -0.25rem 0 0 -0.25rem;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--beam) 70%, transparent),
    0 0 10px 1px color-mix(in srgb, var(--beam) 85%, transparent),
    0 0 22px 3px color-mix(in srgb, var(--beam) 45%, transparent);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 260ms ease, transform 260ms ease;
}

/* Reveal: staggered per row, so a panel lights up line by line like the
   galaxies assembling in the banner. */
.dist-row.is-in .dist-beam {
  transform: translateY(-50%) scaleX(1);
  transition: transform 760ms cubic-bezier(0.16, 0.9, 0.3, 1);
  transition-delay: calc(var(--i) * 55ms);
}

.dist-row.is-in .dist-star {
  opacity: 1;
  transform: scale(1);
  transition-delay: calc(var(--i) * 55ms + 420ms);
}

.dist-row.is-in .dist-star {
  animation: dist-twinkle 4.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 370ms);
}

@keyframes dist-twinkle {
  0%, 100% { filter: brightness(1); }
  45%      { filter: brightness(1.5); }
}

/* A slow pulse of light running out along the beam, like the trail behind the
   rocket. Only on hover: forty of these animating at once would be noise. */
.dist-row:hover .dist-beam {
  filter: brightness(1.5);
}

.dist-row:hover .dist-beam::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.75) 50%,
    rgba(255, 255, 255, 0) 100%);
  animation: dist-sweep 1.1s ease-out infinite;
}

@keyframes dist-sweep {
  from { transform: translateX(-100%); opacity: 0; }
  35%  { opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

.dist-row:hover .dist-star {
  transform: scale(1.35);
  transition-delay: 0s;
}

.dist-row:hover .dist-name,
.dist-row:hover .dist-count {
  color: #fff;
}

.dist-more {
  margin-top: 0.5rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(150, 180, 255, 0.28);
  color: rgba(214, 228, 255, 0.9);
  font-size: 0.74rem;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.dist-more:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(180, 205, 255, 0.6);
}

/* color-mix is recent; without it the beams would come out transparent. */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .dist-beam { background: var(--beam); }
  .dist-star { box-shadow: 0 0 10px 1px var(--beam); }
}

@media (max-width: 900px) {
  #overview-distribution { grid-template-columns: minmax(0, 1fr); }
  .dist-panel { --name-col: 7rem; }
  .dist-row { grid-template-columns: var(--name-col) minmax(0, 1fr) 3.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .dist-beam,
  .dist-star { transition: none; }
  .dist-row.is-in .dist-star,
  .dist-row:hover .dist-beam::after { animation: none; }
  .dist-row .dist-beam { transform: translateY(-50%) scaleX(1); }
  .dist-row .dist-star { opacity: 1; transform: scale(1); }
}
