/* Token Factory cards. See static/components/cards.js.
   Gallery uses static/notebook_index.css instead. */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--space-5);
}

/* ---- tag pill ----------------------------------------------------------- */
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  list-style: none;
}
.tag-pill.is-strong { border-color: var(--border-emphasis); color: var(--text); }

/* ---- token factory model card ------------------------------------------- */
.model-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  min-height: 208px;
  padding: var(--space-5);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.model-card:hover { border-color: var(--border-emphasis); transform: translateY(-2px); }
.model-card.is-muted { border-style: dashed; }
.model-card.is-muted .model-name { color: var(--text-muted); }

.model-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.model-pub {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-control);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  flex: 0 0 auto;
}

/* Every tone the admin form can set has a style here. The previous build
   offered six tones and defined two, so four silently fell through. */
.model-badge {
  padding: 2px var(--space-2);
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  flex: 0 0 auto;
}
.model-badge.is-free    { color: var(--success);     border-color: var(--success); }
.model-badge.is-limited { color: var(--attention);   border-color: var(--attention); }
.model-badge.is-soon    { color: var(--text-subtle); border-color: var(--border-emphasis); }
.model-badge.is-offline { color: var(--text-subtle); border-color: var(--border); }
.model-badge.is-deploy  { color: var(--graph);       border-color: var(--graph-line); }

.model-name {
  font-size: var(--text-md);
  font-weight: 700;
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
}

.model-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-normal);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: auto;
  padding-top: var(--space-2);
}

/* Live capacity bar. Its own row rather than inside .model-foot: that row wraps
   pills, and a full-width bar would push them onto a second line. */
.model-load {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary, #475467);
}

.model-load-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--surface-sunken, #eef1f6);
  overflow: hidden;
}

.model-load-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
  background: #12b76a;
}

/* Tabular figures stop the percentage from jittering as digits change. */
.model-load-pct {
  flex: none;
  min-width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.model-load.is-busy .model-load-fill {
  background: #f79009;
}

.model-load.is-full .model-load-fill {
  background: #d92d20;
}

.model-load.is-full {
  color: #b42318;
}

.model-card.is-state {
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  cursor: default;
  border-style: dashed;
}
.model-card.is-state:hover { transform: none; border-color: var(--border); }
.model-state-text { font-size: var(--text-sm); color: var(--text-muted); }

/* ---- filters ------------------------------------------------------------ */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.filter-pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.filter-pill {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.filter-pill:hover { border-color: var(--border-emphasis); color: var(--text); }
.filter-pill[aria-pressed="true"] {
  border-color: var(--graph);
  background: var(--graph-soft);
  color: var(--text);
  font-weight: 600;
}

.result-count {
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.empty-state {
  padding: var(--space-8) var(--space-5);
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  text-align: center;
  color: var(--text-muted);
}
.empty-state p { margin: 0 0 var(--space-4); }
.empty-state p:last-child { margin-bottom: 0; }

/* ---- two-column browse (token factory) ---------------------------------- */
.browse {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
.browse > * { min-width: 0; }

.facets {
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  max-height: calc(100dvh - var(--header-height) - var(--space-7));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: auto;
}

.facet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 700;
}

.facet-group { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.facet-group:last-child { border-bottom: 0; }

.facet-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-muted);
}

.facet {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-height-sm, 32px);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
  cursor: pointer;
}
.facet-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.facet-count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }

@media (max-width: 900px) {
  .browse { grid-template-columns: 1fr; }
  .facets { position: static; max-height: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facet-head { grid-column: 1 / -1; }
  .facet-group { min-width: 0; border-bottom: 0; }
  .facet-group + .facet-group { border-left: 1px solid var(--border); }
}

@media (max-width: 640px) {
  .card-grid { gap: var(--space-4); }
  .model-card { padding: var(--space-4); }
  .facets { grid-template-columns: 1fr; }
  .facet-group { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
  .facet-group + .facet-group { border-left: 0; border-top: 1px solid var(--border); }
  .facet { gap: var(--space-2); max-width: 100%; }
  .filter-bar { gap: var(--space-3); }
  .filter-bar > .ant-input-affix-wrapper { max-width: none !important; }
}

/* ---- pricing grid (model detail) ---------------------------------------- */
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.price-cell { display: flex; flex-direction: column; gap: 2px; }
.price-label { font-size: var(--text-xs); color: var(--text-muted); }
.price-value { font-size: var(--text-base); font-weight: 600; }
