/* ============================================================
   06 — Platforms: source → destination routing matrix

   Two breakpoints only:
     ≤ 38.75rem (620px)  phone  — per-source disclosure list
     ≥ 38.76rem          grid   — scrollable matrix + crosshair
   ============================================================ */
.platforms {
  /* Layout constants — declared once, composed from the space scale */
  --pin-w: 11rem;                 /* pinned source column */
  --mark-w: 1.25rem;              /* platform glyph box */
  --matrix-min: 68rem;            /* pin-w + 10 destination columns */
  --matrix-max-h: min(78vh, 46rem);
  --sticky-offset: 6rem;          /* mirrors html { scroll-padding-top } */
  /* "not applicable" texture — reused by the cell and its legend swatch */
  --hatch: repeating-linear-gradient(45deg,
            transparent 0 var(--s-1),
            var(--border-strong) var(--s-1),
            var(--border-strong) calc(var(--s-1) + 1px));
}

/* Off-screen symbol sprite */
.platforms__sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.platforms__mark {
  width: var(--mark-w);
  height: var(--mark-w);
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease-out);
}

/* ---------- Matrix card ---------- */
.platforms__matrix {
  position: relative;
  margin-top: clamp(var(--s-10), 4vw, var(--s-16));
  background: var(--surface);
  border-radius: var(--r-xl);
  overflow: clip; /* masks the scrollbar inside the card radius */
  box-shadow: inset 0 0 0 1px var(--border), var(--sh-md);
}

/* Card head — the axes and the honest count, in one strip */
.platforms__cardhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3) var(--s-6);
  padding: var(--s-5) var(--s-6);
  border-block-end: 1px solid var(--border);
}
.platforms__count {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-normal);
  color: var(--text);
}
.platforms__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-5);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.platforms__legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  white-space: nowrap;
}
.platforms__na-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: calc(var(--r-xs) / 2);
  background-color: var(--surface);
  background-image: var(--hatch);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* The fades live on this band, not on the card — they must never
   reach the card head or the card foot. */
.platforms__scrollwrap { position: relative; }

.platforms__scroll {
  overflow: auto;
  max-block-size: var(--matrix-max-h);
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-200) transparent;
}
/* The card clips its children, so the scroller's ring is drawn on the card itself */
.platforms__scroll:focus-visible { outline: none; }
.platforms__matrix:has(.platforms__scroll:focus-visible) {
  box-shadow: inset 0 0 0 1px var(--border), var(--sh-md), var(--focus-ring);
}
@media (forced-colors: active) {
  .platforms__matrix:has(.platforms__scroll:focus-visible) {
    outline: 3px solid Highlight;
    outline-offset: 2px;
  }
}

/* Edge fades — scoped to the scrolling band, starting after the pinned column */
.platforms__scrollwrap::before,
.platforms__scrollwrap::after {
  content: "";
  position: absolute;
  inset-block: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 7;
  transition: opacity var(--dur) var(--ease-out);
}
.platforms__scrollwrap::before {
  left: var(--pin-w);
  width: var(--s-6);
  background: linear-gradient(to right, var(--surface), transparent);
}
.platforms__scrollwrap::after {
  right: 0;
  width: var(--s-12);
  background: linear-gradient(to left, var(--surface), transparent);
}
.platforms__matrix.is-scrolled .platforms__scrollwrap::before { opacity: 1; }
.platforms__matrix.is-overflowing:not(.is-end) .platforms__scrollwrap::after { opacity: 1; }

/* Depth on the pinned column once it starts overlapping.
   Offset + spread must clear the opaque cell background or nothing paints. */
.platforms__matrix.is-scrolled .platforms__corner,
.platforms__matrix.is-scrolled .platforms__src {
  box-shadow: var(--s-2) 0 var(--s-2) calc(var(--s-1) * -1)
              color-mix(in srgb, var(--ink-900) 14%, transparent);
}

/* ---------- Table ---------- */
.platforms__table {
  table-layout: fixed;
  width: 100%;
  min-width: var(--matrix-min);
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
.platforms__col-src { width: var(--pin-w); }

/* Both axes are peers — same size. The mono corner label carries the direction. */
.platforms__table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--cell-bg, var(--surface));
  padding: var(--s-5) var(--s-2) var(--s-4);
  text-align: center;
  vertical-align: bottom;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-normal);
  color: var(--text);
  border-block-end: 1px solid var(--border-strong);
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.platforms__dest-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  line-height: var(--lh-snug);
  white-space: nowrap;
}

.platforms__table thead th.platforms__corner {
  left: 0;
  z-index: 6;
  text-align: start;
  padding-inline: var(--s-6) var(--s-4);
  border-inline-end: 1px solid var(--border);
}
.platforms__corner-in {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-1);
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  line-height: var(--lh-snug);
  color: var(--text-muted);
}
/* --accent is the page's interactive colour; a static axis label isn't clickable.
   The destination axis steps up the ink ramp instead. */
.platforms__corner-b { color: var(--text); }
.platforms__corner-arrow {
  width: 1.75rem;
  height: 0.625rem;
  color: var(--text-subtle);
}

.platforms__src {
  position: sticky;
  left: 0;
  z-index: 4; /* above a focused cell, below the sticky header row */
  background: var(--cell-bg, var(--surface));
  text-align: start;
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-6);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-normal);
  color: var(--text);
  border-block-end: 1px solid var(--border);
  border-inline-end: 1px solid var(--border);
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.platforms__src-in {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  white-space: nowrap;
}

.platforms__cell {
  position: relative;
  padding: var(--s-3) var(--s-2);
  text-align: center;
  white-space: nowrap;
  background: var(--cell-bg, transparent);
  border-block-end: 1px solid var(--border);
  scroll-margin-block-start: var(--sticky-offset);
  scroll-margin-inline-start: var(--pin-w);
  transition: background-color var(--dur-fast) var(--ease-out);
}
.platforms__table tbody tr:last-child > * { border-block-end: 0; }
.platforms__cell:focus-visible {
  z-index: 3;
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
@media (forced-colors: active) {
  .platforms__cell:focus-visible { outline: 2px solid Highlight; outline-offset: -3px; }
  .platforms__table .is-lit-col,
  .platforms__table .is-lit-row { outline: 1px solid Highlight; outline-offset: -1px; }
}

/* ---------- State marks: quiet ground, loud exceptions ---------- */
.platforms__dot,
.platforms__dash {
  display: inline-block;
  vertical-align: middle;
  border-radius: var(--r-pill);
}
.platforms__dot {
  width: 0.4375rem;
  height: 0.4375rem;
  background: var(--violet-500);
}
.platforms__dash {
  width: 0.75rem;
  height: 0.1875rem;
  background: var(--text-subtle);
}

.platforms__beta {
  display: inline-flex;
  align-items: center;
  padding-inline: var(--s-2);
  border-radius: var(--r-pill);
  background: var(--amber-100);
  color: color-mix(in srgb, var(--amber-500) 55%, var(--ink-900));
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  line-height: var(--lh-relaxed);
}

/* ---------- Crosshair (custom-property cascade — order decides, not specificity) ----------
   "Same platform" is texture, not tint, so it can never be confused with a highlight
   and stays legible when the crosshair passes over it. */
.platforms__cell.is-na {
  --cell-bg: var(--surface);
  background-image: var(--hatch);
}

.platforms__table .is-lit-row,
.platforms__table .is-lit-col { --cell-bg: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.platforms__table .is-lit-col.platforms__dest,
.platforms__table .is-lit-row.platforms__src { color: var(--accent); }
.platforms__table .is-lit-col.platforms__dest .platforms__mark,
.platforms__table .is-lit-row.platforms__src .platforms__mark { color: var(--accent); }

.platforms__table .is-lit { --cell-bg: color-mix(in srgb, var(--accent) 20%, var(--surface)); }

/* ---------- Card foot ---------- */
.platforms__foot {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end; /* keys stay put when the hint fades */
  gap: var(--s-2) var(--s-4);
  padding: var(--s-3) var(--s-6);
  border-block-start: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.platforms__matrix.is-overflowing .platforms__foot { display: flex; }
.platforms__hint {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-inline-end: auto;
  /* Inherits --text-muted from the foot — weight and the arrow carry it. */
  font-weight: var(--fw-semibold);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.platforms__hint-arrow { width: var(--mark-w); height: 0.625rem; }
.platforms__matrix.is-scrolled .platforms__hint {
  opacity: 0;
  transform: translateX(calc(var(--s-2) * -1));
}
.platforms__keys { font-variant-numeric: tabular-nums; }

/* ---------- Closing notes — hairline row, small glyph, no icon/title/paragraph triad ---------- */
.platforms__notes {
  display: grid;
  /* Fixed count of three — auto-fit fits exactly 2 tracks across a wide band
     and orphans the third on its own hairline row. 1-up, then 3-up. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-6) var(--s-10);
  margin-top: clamp(var(--s-12), 5vw, var(--s-20));
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  color: var(--text-muted);
}
.platforms__notes li {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border-strong);
  max-width: var(--maxw-prose);
}
.platforms__note-glyph {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  padding: var(--s-1);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
}
.platforms__notes strong {
  color: var(--text);
  font-weight: var(--fw-semibold);
}

@media (min-width: 60rem) {
  .platforms__notes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Just above the phone breakpoint the pinned column eats the visible band.
   Narrowing it buys back a destination column; the edge fade and
   scroll-margin both key off --pin-w, so they follow. */
@media (max-width: 48rem) {
  .platforms { --pin-w: 8.5rem; }
  .platforms__src { padding-inline-start: var(--s-4); }
  .platforms__table thead th.platforms__corner { padding-inline: var(--s-4) var(--s-3); }
}

/* ---------- Phone view (built by JS from the table) ---------- */
.platforms__disc { display: none; }

@media (max-width: 38.75rem) {
  /* Only trade the table away once the disclosure list actually exists */
  .platforms__matrix:has(.platforms__disc) .platforms__scrollwrap,
  .platforms__matrix:has(.platforms__disc) .platforms__foot { display: none; }
  .platforms__matrix:has(.platforms__disc) .platforms__disc { display: block; }

  .platforms__cardhead { padding: var(--s-5); }

  .platforms__disc-item { border-block-end: 1px solid var(--border); }
  .platforms__disc-item:last-child { border-block-end: 0; }

  /* Name + chevron on line one, counts on line two — nothing competes for width */
  .platforms__disc-sum {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-3);
    min-height: 2.75rem;
    padding: var(--s-4) var(--s-5);
    cursor: pointer;
    list-style: none;
  }
  .platforms__disc-sum::-webkit-details-marker { display: none; }
  .platforms__disc-sum:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
  .platforms__disc-name {
    flex: 1;
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-normal);
  }
  .platforms__disc-meta {
    flex: 1 0 100%;
    margin-block-start: calc(var(--s-2) * -1);
    padding-inline-start: calc(var(--mark-w) + var(--s-3));
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
  }
  .platforms__disc-chev {
    flex: none;
    width: 1.125rem;
    height: 1.125rem;
    color: var(--text-subtle);
    transition: transform var(--dur) var(--ease-out);
  }
  .platforms__disc-item[open] .platforms__disc-chev { transform: rotate(180deg); }
  .platforms__disc-item[open] .platforms__disc-sum .platforms__mark { color: var(--accent); }

  .platforms__disc-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    padding: 0 var(--s-5) var(--s-5);
  }
  .platforms__pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    white-space: nowrap;
  }
  .platforms__pill .platforms__mark { width: 1rem; height: 1rem; color: inherit; }
  .platforms__pill.is-beta {
    background: var(--amber-100);
    color: color-mix(in srgb, var(--amber-500) 55%, var(--ink-900));
  }
  .platforms__pill.is-beta .platforms__beta {
    padding: 0;
    background: none;
    color: inherit;
  }
  .platforms__pill.is-no {
    color: var(--text-muted);
    box-shadow: inset 0 0 0 1px var(--border-strong);
    background: transparent;
  }
}
