/* Model selection page — tier cards, filterable catalog, rate table. */

.lede {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--color-text);
}

/* ---------------------------------------------------------------- tiers */

/* Four cards. At prose width that's a 2x2 block — a 3+1 wrap leaves an
   awkward orphan and makes Specialized look like an afterthought. */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1rem;
  margin: 1.75rem 0;
}

.tier-card {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-bg-nav);
  padding: 1.125rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
}

.tier-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.tier-blurb {
  margin: 0 0 0.875rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.tier-use-label {
  margin: 0 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.docs-content ul.tier-use {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--color-text-secondary);
}

.docs-content ul.tier-use li + li {
  margin-top: 0.25rem;
}

.tier-count {
  margin: auto 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- pills & badges */

.tier-pill {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  border-radius: 0.3125rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tier-frontier {
  background: rgba(239, 191, 4, 0.16);
  color: #7a5f00;
  border-color: rgba(239, 191, 4, 0.5);
}
.tier-balanced {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.35);
}
.tier-fast {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.35);
}
.tier-specialized {
  background: rgba(100, 116, 139, 0.14);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.35);
}

:root[data-theme="dark"] .tier-frontier { color: #f5d76e; }
:root[data-theme="dark"] .tier-balanced { color: #93b4f4; }
:root[data-theme="dark"] .tier-fast { color: #6ee7b7; }
:root[data-theme="dark"] .tier-specialized { color: #cbd5e1; }

.consumption {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--color-text-secondary);
}

.consumption::before {
  content: "";
  width: 1.25rem;
  height: 0.375rem;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    currentColor var(--fill, 25%),
    var(--color-gray-6) var(--fill, 25%)
  );
  flex: none;
}

.consumption-low { --fill: 25%; color: #047857; }
.consumption-moderate { --fill: 50%; color: #1d4ed8; }
.consumption-high { --fill: 75%; color: #b45309; }
.consumption-very-high { --fill: 100%; color: #b91c1c; }

:root[data-theme="dark"] .consumption-low { color: #6ee7b7; }
:root[data-theme="dark"] .consumption-moderate { color: #93b4f4; }
:root[data-theme="dark"] .consumption-high { color: #fbbf24; }
:root[data-theme="dark"] .consumption-very-high { color: #fca5a5; }

/* --------------------------------------------------------------- catalog */

.catalog {
  margin: 1.5rem 0;
}

/* The catalog wants more room than the prose column. Once there's space,
   reclaim the .docs-content padding on both sides — no further, or it would
   run under the TOC column. */
@media (min-width: 1400px) {
  .catalog { margin-inline: -2.5rem; }
}

.catalog-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  background: var(--color-bg-nav);
}

.catalog-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 14rem;
}

.catalog-search svg {
  position: absolute;
  left: 0.625rem;
  color: var(--color-text-muted);
  pointer-events: none;
}

.catalog-search input {
  width: 100%;
  padding: 0.4375rem 0.625rem 0.4375rem 2rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.875rem;
}

.catalog-search input:focus-visible,
.catalog-controls select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.catalog-filter-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.catalog-filter-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.catalog-controls select {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.8125rem;
  max-width: 11rem;
}

.catalog-toggles {
  gap: 0.875rem;
}

.catalog-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.chip {
  padding: 0.1875rem 0.5625rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.chip:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.chip[aria-pressed="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

:root[data-theme="dark"] .chip[aria-pressed="true"] { color: #0f172a; }

.catalog-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-top: 0;
  background: var(--color-bg);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.catalog-reset {
  border: 0;
  background: none;
  padding: 0;
  color: var(--color-accent);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: underline;
}

/* A sticky <thead> anchors to its nearest scroll container, not the page — and
   `overflow-x: auto` already makes this one. So bound the height and let the
   table scroll inside it, which is better for 97 rows anyway: the filters stay
   on screen while you scroll the results. */
.catalog-scroll {
  overflow: auto;
  max-height: min(70vh, 40rem);
  overscroll-behavior: contain;
  border: 1px solid var(--color-border);
  border-top: 0;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.docs-content table.catalog-table {
  width: 100%;
  min-width: 30rem;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.docs-content .catalog-table th,
.docs-content .catalog-table td {
  border: 0;
  border-bottom: 1px solid var(--color-border);
  padding: 0.5rem 0.625rem;
  text-align: left;
  vertical-align: top;
}

.docs-content .catalog-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-bg-nav);
  /* The sort button supplies the padding. */
  padding: 0;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--color-border);
}

.sort-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}

/* `hidden` on a <tr> loses to the UA's display:table-row in some engines. */
.docs-content .catalog-table tr[hidden] {
  display: none;
}

.docs-content .catalog-table tbody tr:last-child td {
  border-bottom: 0;
}

.docs-content .catalog-table tbody tr:hover {
  background: var(--color-gray-6);
}

.sort-btn {
  border: 0;
  background: none;
  cursor: pointer;
}

.sort-btn:hover { color: var(--color-text); }

.sort-btn::after {
  content: "↕";
  opacity: 0.35;
  font-size: 0.75rem;
}

.sort-btn[data-dir="asc"],
.sort-btn[data-dir="desc"] { color: var(--color-accent); }
.sort-btn[data-dir="asc"]::after { content: "↑"; opacity: 1; }
.sort-btn[data-dir="desc"]::after { content: "↓"; opacity: 1; }

.cell-model { min-width: 12rem; }

.model-name {
  display: block;
  font-weight: 600;
  color: var(--color-text);
}

.docs-content code.model-id {
  display: block;
  margin-top: 0.125rem;
  padding: 0;
  background: none;
  border: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

.model-note {
  display: block;
  margin-top: 0.25rem;
  max-width: 22rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--color-text-secondary);
  font-style: italic;
}

.catalog-empty {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------ legend */

.catalog-legend {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-gray-6);
}

.legend-note {
  margin: 0 0 0.625rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------ rate table */

.docs-content table.rate-table {
  font-size: 0.875rem;
}

.docs-content .rate-table td:first-child { white-space: nowrap; }

/* --------------------------------------------------------------- narrow */

@media (max-width: 640px) {
  .catalog-controls {
    align-items: stretch;
    flex-direction: column;
    gap: 0.75rem;
  }
  .catalog-filter-group { flex-wrap: wrap; }
  .catalog-controls select { max-width: none; flex: 1; }
}

@media print {
  .catalog-controls,
  .catalog-status { display: none; }
  .catalog-scroll { overflow: visible; max-height: none; }
  .docs-content table.catalog-table { min-width: 0; font-size: 0.6875rem; }
  .docs-content .catalog-table thead th { position: static; }
}

/* --------------------------------------------------------- page footnote */

.fn-ref {
  font-size: 0.75em;
  line-height: 0;
  margin-left: 0.0625rem;
}

.page-footnote {
  margin: 2rem 0 0;
  padding-top: 0.875rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}
