/* chip-detail.css — Chip-level overview page.
 *
 * Layout primitives (.hero, .section, .grid, .card, .data-table) come
 * from the global stylesheets; this file only adds the per-page bits:
 *   • chip-hero      : center-aligned hero matched to Home / Suites
 *   • chip-suite-grid: per-suite KPI cards with suite-color accent
 *   • chip-runs      : the all-submissions table styling
 */

/* ── Hero ──────────────────────────────────────────────────── */
.chip-hero {
  text-align: center;
  padding: 2.5rem 1rem 1.75rem;
}
.chip-hero .eyebrow { justify-content: center; }
/* Centered hero — drop the leading rule so the vendor label doesn't
   read like "— APPLE", matching the rk-hero / cmp-hero treatment. */
.chip-hero .eyebrow::before { display: none; }
.chip-hero-eyebrow .vendor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vendor-color, var(--fg-muted));
}

/* ── 01 · Best per suite ──────────────────────────────────── */
.chip-suite-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.chip-suite-card {
  --suite-color: var(--accent-2);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.05rem 1.05rem;
  border: 1px solid var(--border-soft);
  border-left: 3px solid color-mix(in srgb, var(--suite-color) 65%, transparent);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease,
              box-shadow 120ms ease, background 120ms ease;
}
.chip-suite-card[data-suite="A"] { --suite-color: var(--suite-A); }
.chip-suite-card[data-suite="B"] { --suite-color: var(--suite-B); }
.chip-suite-card[data-suite="C"] { --suite-color: var(--suite-C); }
.chip-suite-card[data-suite="D"] { --suite-color: var(--suite-D); }
.chip-suite-card[data-suite="E"] { --suite-color: var(--suite-E); }
.chip-suite-card[data-suite="F"] { --suite-color: var(--suite-F); }
.chip-suite-card[data-suite="G"] { --suite-color: var(--suite-G); }

a.chip-suite-card { cursor: pointer; }
a.chip-suite-card:hover {
  border-color: var(--suite-color);
  border-left-color: var(--suite-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 18px -10px color-mix(in srgb, var(--suite-color) 45%, transparent);
  background: color-mix(in srgb, var(--suite-color) 3%, var(--bg-elev));
  text-decoration: none;
}

.chip-suite-card--empty {
  opacity: 0.55;
  border-left-color: var(--border-soft);
}

.chip-suite-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.chip-suite-letter {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--suite-color) 18%, transparent);
  color: color-mix(in srgb, var(--suite-color) 75%, var(--fg-strong));
  flex: 0 0 auto;
}
.chip-suite-letter--inline {
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
}
.chip-suite-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--fg-strong);
  line-height: 1.2;
  min-width: 0;
  flex: 1 1 auto;
}

/* "Ranked #N of M" badge in the KPI card head.  Rank is computed
   across unique chips (not raw rows), so a chip with many vLLM
   versions doesn't double-count its own ranking slot.  Top-3 borrow
   the same medal palette as Home / Rankings; everyone else stays
   muted so the badge doesn't compete with the primary metric. */
.chip-suite-rank {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  background: color-mix(in srgb, var(--fg-muted) 10%, transparent);
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip-suite-rank .chip-suite-rank-total {
  color: var(--fg-faint);
  font-weight: 500;
}
.chip-suite-rank.is-gold {
  color: #b8860b;
  background: color-mix(in srgb, #f1c40f 22%, transparent);
}
.chip-suite-rank.is-silver {
  color: #7d7d7d;
  background: color-mix(in srgb, #b0b0b0 25%, transparent);
}
.chip-suite-rank.is-bronze {
  color: #8b4513;
  background: color-mix(in srgb, #cd7f32 22%, transparent);
}

.chip-suite-metric {
  margin-top: 0.2rem;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.chip-suite-val {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--fg-strong);
  font-variant-numeric: tabular-nums;
}
.chip-suite-unit {
  font-size: 0.78rem;
  color: var(--fg-muted);
  letter-spacing: 0.01em;
}

/* "×N" badge that appears next to the metric on chips with multiple
 * fan-out variants (×1 / ×4 / ×8).  Tells users the headline number
 * came from a multi-card deployment so they don't read it as a
 * single-card score.  Suite-tinted to match the card accent. */
.chip-suite-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--suite-color) 15%, transparent);
  color: color-mix(in srgb, var(--suite-color) 70%, var(--fg-strong));
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip-suite-meta {
  font-size: 0.78rem;
  color: var(--fg-muted);
  line-height: 1.4;
}
.chip-suite-meta .fw-ver { color: var(--fg-faint); margin-left: 0.25rem; }
.chip-suite-empty {
  font-size: 0.85rem;
  color: var(--fg-faint);
  font-style: italic;
}

/* Affordance hint pinned to the bottom of every active KPI card.
 *   • Plain click   → primary action ("Open run") — emphasized.
 *   • Modifier click → secondary path ("⌘+click for all in suite") —
 *     muted and only fully revealed on hover so it doesn't compete
 *     with the metric.  The full sentence is also exposed via the
 *     card's `title` attribute for keyboard / screen-reader access. */
.chip-suite-hint {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.5rem;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--fg-faint);
  border-top: 1px dashed color-mix(in srgb, var(--border-soft) 80%, transparent);
}
.chip-suite-hint-primary {
  color: var(--fg-muted);
  font-weight: 600;
}
.chip-suite-hint-sep { opacity: 0.5; }
.chip-suite-hint-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  opacity: 0.55;
  transition: opacity 120ms ease;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-suite-hint kbd {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.02rem 0.28rem;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg-muted);
  line-height: 1.2;
}
a.chip-suite-card:hover .chip-suite-hint-secondary { opacity: 1; }
a.chip-suite-card:hover .chip-suite-hint {
  border-top-color: color-mix(in srgb, var(--suite-color) 30%, var(--border-soft));
}

/* ── 02 · Performance fingerprint (radar) ─────────────────── */
.chip-fp-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.9fr);
  gap: 1.4rem;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-card);
}
@media (max-width: 760px) {
  .chip-fp-wrap {
    grid-template-columns: 1fr;
    padding: 1rem 0.95rem;
  }
}
.chip-fp-canvas {
  position: relative;
  width: 100%;
  /* Square the canvas so the radar polygon stays visually balanced;
     Chart.js needs the parent to set the height (canvas is responsive). */
  aspect-ratio: 1 / 1;
  max-width: 420px;
  margin: 0 auto;
}
.chip-fp-canvas canvas { width: 100% !important; height: 100% !important; }

.chip-fp-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.chip-fp-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.32rem 0.55rem;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  font-size: 0.82rem;
}
.chip-fp-row[data-suite="A"] { --suite-color: var(--suite-A); }
.chip-fp-row[data-suite="B"] { --suite-color: var(--suite-B); }
.chip-fp-row[data-suite="C"] { --suite-color: var(--suite-C); }
.chip-fp-row[data-suite="D"] { --suite-color: var(--suite-D); }
.chip-fp-row[data-suite="E"] { --suite-color: var(--suite-E); }
.chip-fp-row[data-suite="F"] { --suite-color: var(--suite-F); }
.chip-fp-row[data-suite="G"] { --suite-color: var(--suite-G); }
.chip-fp-letter {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--on-accent, #fff);
  background: var(--suite-color, var(--accent-2));
}
.chip-fp-name {
  color: var(--fg);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-fp-value {
  color: var(--fg-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.chip-fp-pct {
  color: var(--fg-strong);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3.2rem;
  text-align: right;
}
.chip-fp-pct.is-missing {
  color: var(--fg-faint);
  font-weight: 400;
}

/* ── 03 · Scaling across chip-counts (grouped bar) ────────── */
.chip-scl-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem 1.4rem;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 1.2rem 1.3rem 0.6rem;
  box-shadow: var(--shadow-card);
}
@media (max-width: 760px) {
  .chip-scl-wrap {
    grid-template-columns: 1fr;
    padding: 1rem 0.95rem 0.4rem;
  }
}
.chip-scl-canvas {
  position: relative;
  width: 100%;
  /* Aspect ratio that gives 6–7 suite clusters of bars adequate width
     without stretching tall on mobile.  Chart.js owns the height. */
  aspect-ratio: 16 / 7;
  min-height: 220px;
  max-height: 320px;
}
.chip-scl-canvas canvas { width: 100% !important; height: 100% !important; }

.chip-scl-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-self: start;
  padding-top: 0.5rem;
}
.chip-scl-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--fg);
}
.chip-scl-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border-soft);
  background: var(--accent-2);
}
.chip-scl-legend-label {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.chip-scl-breakdown {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.4rem;
}
.chip-scl-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1.2fr) minmax(0, 2fr);
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  font-size: 0.8rem;
}
.chip-scl-row[data-suite="A"] { --suite-color: var(--suite-A); }
.chip-scl-row[data-suite="B"] { --suite-color: var(--suite-B); }
.chip-scl-row[data-suite="C"] { --suite-color: var(--suite-C); }
.chip-scl-row[data-suite="D"] { --suite-color: var(--suite-D); }
.chip-scl-row[data-suite="E"] { --suite-color: var(--suite-E); }
.chip-scl-row[data-suite="F"] { --suite-color: var(--suite-F); }
.chip-scl-row[data-suite="G"] { --suite-color: var(--suite-G); }
.chip-scl-row-letter {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.74rem;
  color: var(--on-accent, #fff);
  background: var(--suite-color, var(--accent-2));
}
.chip-scl-row-title {
  color: var(--fg);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-scl-row-cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.4rem;
  align-items: center;
}
.chip-scl-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.05rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.chip-scl-cell-pct {
  color: var(--fg-strong);
  font-weight: 600;
  font-size: 0.78rem;
}
.chip-scl-cell-val {
  color: var(--fg-muted);
  font-size: 0.7rem;
}
.chip-scl-cell-empty {
  color: var(--fg-faint);
  font-weight: 400;
  text-align: right;
  display: inline-block;
}

/* ── 04 · Every submission ────────────────────────────────── */
.chip-runs-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.chip-runs {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.chip-runs thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 0.7rem 0.85rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.chip-runs tbody td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border-soft);
  color: var(--fg);
  vertical-align: middle;
}
.chip-runs tbody tr:last-child td { border-bottom: 0; }
.chip-runs tbody tr {
  cursor: pointer;
  transition: background 80ms ease;
}
.chip-runs tbody tr:hover td {
  background: color-mix(in srgb, var(--suite-color, var(--fg-muted)) 7%, transparent);
}

.chip-runs tbody tr[data-suite="A"] { --suite-color: var(--suite-A); }
.chip-runs tbody tr[data-suite="B"] { --suite-color: var(--suite-B); }
.chip-runs tbody tr[data-suite="C"] { --suite-color: var(--suite-C); }
.chip-runs tbody tr[data-suite="D"] { --suite-color: var(--suite-D); }
.chip-runs tbody tr[data-suite="E"] { --suite-color: var(--suite-E); }
.chip-runs tbody tr[data-suite="F"] { --suite-color: var(--suite-F); }
.chip-runs tbody tr[data-suite="G"] { --suite-color: var(--suite-G); }

.chip-runs-suite {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.chip-runs-suite-title {
  font-weight: 600;
  color: var(--fg-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-runs-metric {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
}
.chip-runs .fw-ver { color: var(--fg-faint); margin-left: 0.25rem; }
.chip-runs .col-tier .badge { text-transform: capitalize; }
.chip-runs .col-chips { width: 1%; white-space: nowrap; }
.chip-runs-count {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg-strong);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg-muted) 10%, transparent);
}

/* ── Empty / not-found state ──────────────────────────────────
 * Visually rhymes with .rk-empty / .cmp-empty so a stale
 * `#/chip/<slug>` link reads as the same "no data here" surface
 * as an over-filtered rankings view, not a hard 404. */
.chip-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--fg-muted);
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
}
.chip-empty .state-icon {
  display: block;
  font-size: 2rem;
  color: var(--fg-faint);
  margin-bottom: 0.6rem;
}
.chip-empty p { margin: 0.3rem 0; }
.chip-empty .chip-empty-sub {
  font-size: 0.85rem;
  color: var(--fg-faint);
}
.chip-empty code {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  color: var(--fg-strong);
}

/* ── 03 · Compare with similar chips ─────────────────────────
 * Horizontal-flowing grid of peer tiles.  Each tile links to that
 * chip's own detail page so the section is a pure navigation
 * surface; we deliberately do NOT mutate the compare basket from
 * here (that would be a hidden side effect on a click that visually
 * reads as "open this chip"). */
.chip-peer-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.chip-peer-card {
  --vendor-color: var(--fg-faint);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 1rem 0.95rem;
  border: 1px solid var(--border-soft);
  border-left: 3px solid color-mix(in srgb, var(--vendor-color) 60%, transparent);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease,
              box-shadow 120ms ease, background 120ms ease;
}
/* `--vendor-color` set globally by data.js via `[data-vendor="<name>"]`. */

.chip-peer-card:hover {
  border-color: var(--vendor-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 18px -10px color-mix(in srgb, var(--vendor-color) 45%, transparent);
  background: color-mix(in srgb, var(--vendor-color) 3%, var(--bg-elev));
  text-decoration: none;
}
.chip-peer-vendor {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  text-transform: uppercase;
}
.chip-peer-name {
  font-weight: 600;
  color: var(--fg-strong);
  font-size: 0.95rem;
  line-height: 1.25;
}
.chip-peer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--fg-muted);
}
.chip-peer-suites { display: inline-flex; gap: 0.25rem; flex-wrap: wrap; }
.chip-peer-suite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--suite-color, var(--fg-muted)) 18%, transparent);
  color: color-mix(in srgb, var(--suite-color, var(--fg-muted)) 75%, var(--fg-strong));
}
.chip-peer-suite[data-suite="A"] { --suite-color: var(--suite-A); }
.chip-peer-suite[data-suite="B"] { --suite-color: var(--suite-B); }
.chip-peer-suite[data-suite="C"] { --suite-color: var(--suite-C); }
.chip-peer-suite[data-suite="D"] { --suite-color: var(--suite-D); }
.chip-peer-suite[data-suite="E"] { --suite-color: var(--suite-E); }
.chip-peer-suite[data-suite="F"] { --suite-color: var(--suite-F); }
.chip-peer-suite[data-suite="G"] { --suite-color: var(--suite-G); }
.chip-peer-runs { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 880px) {
  .chip-hero { padding: 1.75rem 0.5rem 1.4rem; }
  .chip-suite-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .chip-suite-val { font-size: 1.5rem; }
  .chip-runs { font-size: 0.8rem; }
  .chip-runs thead th,
  .chip-runs tbody td { padding: 0.55rem 0.6rem; }
  /* Submitter column carries the least info on mobile — hide it first. */
  .chip-runs .col-submitter { display: none; }
  .chip-peer-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 640px) {
  .chip-runs .col-precision { display: none; }
  .chip-suite-grid { grid-template-columns: 1fr; }
  .chip-peer-grid { grid-template-columns: 1fr; }
  /* Modifier-click is moot on touch — keep the primary hint, drop
     the secondary one (the title attribute still carries the full
     sentence for assistive tech). */
  .chip-suite-hint-sep,
  .chip-suite-hint-secondary { display: none; }
}
