/* Models grid — cards, bench cells, GPU compat, unsloth, ollama, badges,
   pricing-by-provider, lifecycle states, contradiction tooltip. */

.models-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

/* Card grid: composite score sits ONLY beside the head row, not down the
 * full height. Main + actions span the full card width below the head, so
 * bench-grid / ollama / sources can use 100% of the card instead of being
 * squeezed into the left column. Score keeps its sidebar look at the top
 * (and align-self: start so a tall head doesn't stretch the score box).
 * Mobile collapses to a single column (responsive.css). */
.model-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "head    score"
    "main    main"
    "actions actions";
  column-gap: var(--space-3);
  row-gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow);
}
.model-card-head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-width: 0;
}
.model-card-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.model-name-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
}
.model-rank {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.85rem;
}
.model-provider {
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
/* Provider info inline in cardHead — small secondary text after name+tier
 * badge, separated by a leading dot. Wraps below on narrow widths. */
.model-provider-inline {
  color: var(--muted);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.model-provider-inline::before {
  content: "·";
  margin-right: 6px;
  color: var(--border-strong, var(--muted));
}
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tier-badge.frontier { color: var(--accent-2); border-color: var(--accent-2-soft); }
.tier-badge.open-flagship,
.tier-badge.coder-specialized,
.tier-badge.gemma,
.tier-badge.ollama-local { color: var(--accent); border-color: var(--accent-soft); }

.composite-score {
  grid-area: score;
  align-self: start;
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 88px;
  padding: var(--space-2) var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.composite-score .label {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.composite-score .value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.05;
}
.composite-score .coverage {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  cursor: help;
}
.composite-score .coverage.cov-full { color: var(--ok); border-color: var(--accent-soft); }
.composite-score .coverage.cov-partial { color: var(--warn); border-color: var(--warn-soft); }
.composite-score .coverage.cov-low { color: var(--warn-2, #e07320); border-color: var(--warn-2-soft, #e0732040); }
/* B1: low-confidence composite — italic value + inline note */
.composite-score .value.value-low-confidence { font-style: italic; opacity: 0.82; }
.composite-score .low-confidence-note {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--warn-2-soft, #e0732040);
  background: var(--surface-2);
  color: var(--warn-2, #e07320);
}
.composite-score .disputed {
  display: inline-block;
  margin-top: 2px;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--warn-soft);
  background: var(--surface-2);
  color: var(--warn);
  cursor: help;
}

table#comparison-table .coverage-mini {
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 0.7em;
  font-weight: 600;
  border: 1px solid var(--border);
  cursor: help;
}
table#comparison-table .coverage-mini.cov-full { color: var(--ok); border-color: var(--accent-soft); }
table#comparison-table .coverage-mini.cov-partial { color: var(--warn); border-color: var(--warn-soft); }
table#comparison-table .coverage-mini.cov-low { color: var(--warn-2, #e07320); border-color: var(--warn-2-soft, #e0732040); }

.model-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px var(--space-2);
  font-size: 0.82rem;
}
.meta-cell { display: flex; flex-direction: column; gap: 1px; }
.meta-cell .label { color: var(--muted); font-size: 0.68rem; font-weight: 600; line-height: 1.2; }
.meta-cell .value { color: var(--text); font-family: var(--font-mono); line-height: 1.25; }

.bench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(98px, 1fr));
  gap: 6px;
}
.bench-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 22px 5px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
  cursor: default;
  min-width: 0;
}
.bench-cell .name {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.2;
}
.bench-cell .value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.15;
}
.bench-cell.empty .value { color: var(--muted); opacity: 0.6; }
.bench-cell .flag {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.8rem;
  line-height: 1;
  cursor: help;
  background: var(--surface);
  border-radius: 4px;
  padding: 1px 3px;
}
.bench-cell.flag-warn { border-color: var(--warn-soft); }
.bench-cell.flag-danger { border-color: var(--danger-soft); }

/* Excluded by active preset (weight === 0) — dim + grayscale. Cell stays
 * visible because the underlying data is real; the dim signals the preset
 * isn't ranking on it. Weight overlay sits next to the bench label. */
.bench-cell.excluded {
  opacity: 0.45;
  filter: grayscale(0.55);
}
.bench-cell.excluded .name { font-style: italic; }
.bench-cell .bench-weight {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  vertical-align: 1px;
}
.bench-cell.opt-out {
  opacity: 0.55;
}
.bench-cell.opt-out .value {
  color: var(--muted, #8a8d92);
  font-size: 0.95em;
  cursor: help;
  border-bottom: 1px dotted var(--border, rgba(255, 255, 255, 0.15));
}
.bench-cell.opt-out-vendor-opt-out .value { color: var(--warn, #f0b04a); }
.bench-cell.opt-out-not-applicable .value { color: var(--muted, #8a8d92); }
.bench-cell.opt-out-out-of-scope .value { color: var(--muted, #6a6e74); }

/* Provenance tier badges on bench cells */
.bench-cell.tier-c .value {
  color: var(--muted, #8a8d92);
  font-style: italic;
}
.bench-cell.tier-c::after {
  content: 'C';
  font-size: 0.6rem;
  vertical-align: super;
  color: var(--muted, #8a8d92);
  margin-left: 2px;
}
.bench-cell.tier-unknown .value {
  color: var(--warn, #f0b04a);
}
.bench-cell.tier-unknown::before {
  content: '?';
  font-size: 0.7rem;
  color: var(--warn, #f0b04a);
  margin-right: 2px;
}
.bench-cell.gap-pending {
  opacity: 0.45;
}
.bench-cell.gap-pending .value {
  color: var(--muted, #8a8d92);
  font-size: 0.85em;
}

/* Freshness indicator — cells >14 days old */
.bench-cell.stale::after {
  content: '↻';
  font-size: 0.65rem;
  vertical-align: super;
  color: var(--muted, #8a8d92);
  margin-left: 2px;
  cursor: help;
}
.bench-cell.tier-c.stale::after {
  content: 'C↻';
}

/* B4: Very stale cells (>60 days) — stronger visual signal */
.bench-cell.cell-very-stale::after {
  content: '60d+';
  font-size: 0.6rem;
  vertical-align: super;
  color: var(--warn-2, #e07320);
  margin-left: 2px;
  cursor: help;
}
.bench-cell.cell-very-stale {
  border-color: var(--warn-2-soft, #e0732040);
}

/* Category header rows in bench grid */
.bench-cat-header {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #8a8d92);
  padding: 6px 4px 2px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  margin-top: 4px;
}

.compat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
}
.compat-badge.fits { color: var(--ok); border-color: var(--accent-soft); }
.compat-badge.offload { color: var(--warn); border-color: var(--warn-soft); }
.compat-badge.too-large { color: var(--danger); border-color: var(--danger-soft); }

.unsloth-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-2);
}
.unsloth-list li {
  padding: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.unsloth-list li.recommended {
  border-color: var(--accent-soft);
  color: var(--text);
}

.ollama-block {
  margin-top: 2px;
  padding: 6px var(--space-2);
  background: var(--surface, rgba(255, 255, 255, 0.03));
  border-left: 3px solid var(--accent-soft, var(--accent, #67e8a4));
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ollama-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}
.ollama-icon { font-size: 0.9rem; line-height: 1; }
.ollama-title-text { color: var(--text); }
.ollama-cmd-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg, rgba(0, 0, 0, 0.3));
  padding: 5px 8px;
  border-radius: 3px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.pull-cmd {
  flex: 1;
  font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, monospace);
  font-size: 0.78rem;
  color: var(--text);
  word-break: break-all;
  background: transparent;
}
.copy-btn {
  background: transparent;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  color: var(--muted);
  border-radius: 3px;
  padding: 2px 7px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--surface, rgba(255, 255, 255, 0.05)); color: var(--text); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ollama-meta {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.ollama-link {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  align-self: flex-start;
}
.ollama-link:hover { text-decoration: underline; }

.open-badge, .closed-badge {
  display: inline-block;
  margin-left: var(--space-2, 8px);
  padding: 1px 7px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 3px;
  vertical-align: middle;
}
.open-badge {
  background: var(--ok, #67e8a4);
  color: var(--bg, #0b0d10);
}
.closed-badge {
  background: var(--surface, rgba(255, 255, 255, 0.06));
  color: var(--muted, #8a8d92);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}

.notes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  font-size: 0.85rem;
  line-height: 1.4;
}
.notes .strengths::before { content: "✓ "; color: var(--ok); }
.notes .weaknesses::before { content: "△ "; color: var(--warn); }

.model-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 2px;
}

.sources-footer {
  margin-top: 2px;
  padding: 6px var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sources-footer .sources-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
}
.sources-footer .sources-label {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
  font-size: 0.7rem;
}
.sources-footer .sources-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}
.sources-footer .sources-row {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr;
  gap: var(--space-2);
  align-items: baseline;
  line-height: 1.45;
}
.sources-footer .sources-tier {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.sources-footer .sources-row.tier-I .sources-tier { color: var(--ok); }
.sources-footer .sources-row.tier-S .sources-tier { color: var(--warn); }
.sources-footer .sources-row.tier-C .sources-tier { color: var(--accent-2); }
.sources-footer .sources-list a {
  color: var(--accent-2);
  text-decoration: none;
}
.sources-footer .sources-list a:hover { text-decoration: underline; }

/* Contradiction tooltip (JS-positioned) */
.tooltip {
  position: fixed;
  z-index: 100;
  max-width: 320px;
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  color: var(--text);
  pointer-events: none;
}
.tooltip[hidden] { display: none; }
.tooltip h4 { margin: 0 0 var(--space-2); font-size: 0.9rem; }
.tooltip dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px var(--space-2); }
.tooltip dt { color: var(--muted); font-family: var(--font-mono); }
.tooltip dd { margin: 0; }

/* Lifecycle states */
.model-card.is-deprecated {
  opacity: 0.62;
  filter: grayscale(0.45);
}
.model-card.is-deprecated:hover { opacity: 0.85; }
.model-card.is-archived { display: none; }

.deprecated-badge,
.archived-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: var(--space-2);
}
.deprecated-badge {
  background: rgba(255, 175, 80, 0.15);
  color: #ffaf50;
  border: 1px solid rgba(255, 175, 80, 0.45);
}
.archived-badge {
  background: rgba(180, 180, 180, 0.18);
  color: var(--muted);
  border: 1px solid rgba(180, 180, 180, 0.4);
}

/* Multi-provider pricing breakdown */
.pricing-providers {
  margin: 0;
  padding: 6px var(--space-2);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.pricing-providers > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.pricing-providers > summary::-webkit-details-marker { display: none; }
.pricing-providers > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s ease;
}
.pricing-providers[open] > summary::before {
  transform: rotate(90deg);
}
.pricing-providers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: var(--space-2);
}
.pricing-provider-row {
  display: grid;
  grid-template-columns: minmax(80px, 0.4fr) 1fr auto;
  gap: var(--space-2);
  align-items: baseline;
  padding: 2px 0;
}
.prov-name {
  font-weight: 600;
  color: var(--accent);
  text-transform: lowercase;
}
.prov-price {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.prov-link {
  color: var(--accent-2);
  text-decoration: none;
  opacity: 0.7;
  font-size: 0.9em;
}
.prov-link:hover { opacity: 1; }
