/* ======================================================
   Embedl Deploy — model cards
   The shared model card (modelcard.js, vendored from
   embedl/deploy-bench webapp/web): sample inputs | benchmark. Rules mirror the card sections of the
   reference style.css and resolve through the brand tokens
   (brand/scale.css + tokens.css, dark theme). Loaded after
   style.css; the legacy --text-3 / --stroke / --font-* names
   come from there.
   ====================================================== */

/* ── GALLERY: one wide card per result — samples | model graph | benchmark ── */
.model-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 1180px;
    gap: 16px;
}
@media (max-width: 900px) { .model-gallery { grid-template-columns: 1fr; } }

/* Architecture graph pane (this site is dark-themed). */
.model-graph-surface {
    position: relative;
    width: 100%;
    height: 220px;
    padding: 10px;
    border-radius: var(--radius-lg);
    background-color: #0f0f0f;
    background-image: radial-gradient(circle, rgba(71, 165, 184, 0.14) 0.7px, transparent 1px);
    background-size: 16px 16px;
    background-position: center;
}
.model-graph {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.model-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0;
    display: flex;
    flex-direction: column;
    text-align: left;
    font-family: var(--font-body);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    position: relative;
}

.model-card:hover { border-color: var(--border-strong); }
.model-card--link { display: flex; flex-direction: column; color: inherit; }
.model-card--link:hover { color: inherit; }

.model-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;                 /* two-up cards: buttons wrap under the name */
    gap: 8px;
    padding: 16px 20px 0;
}
.model-card-header .hw-select { margin-left: 0; }

.model-name { font-family: var(--font-head); font-size: 1rem; font-weight: 700; color: var(--text); }
.model-meta { font-size: 0.74rem; color: var(--text-3); letter-spacing: 0.01em; }
.model-meta code { color: var(--text-2); font-size: 0.8rem; }

.model-card-run { display: inline-flex; align-items: center; gap: 7px; background: var(--bg-card); border: 1px solid var(--border-default); color: var(--text-primary); border-radius: var(--radius-md); padding: 6px 14px; font-family: var(--font-sans); font-size: 0.78rem; font-weight: 500; white-space: nowrap; transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease); }
.model-card-run:hover { background: var(--bg-secondary); border-color: var(--border-strong); color: var(--text-primary); }

.model-card-cols {
    display: grid;
    grid-template-columns: minmax(200px, 1.1fr) minmax(240px, 1.2fr);
}

/* Gallery cards: model graph | benchmark only (samples live on the model page). */
.model-card-cols--gallery { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 18px;
    padding: 12px 20px 16px;
    align-items: start;
}

.model-col-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

/* sample inputs */
.samples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sample { margin: 0; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sample img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--stroke);
    background: var(--bg-card);
    display: block;
}
.sample.is-miss img { border-color: var(--warning); }
.sample.is-ok img { border-color: var(--stroke); }
.sample figcaption { font-size: 0.66rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.samples-note { grid-column: 1 / -1; font-size: 0.64rem; color: var(--text-3); opacity: 0.8; }
.samples-pending { grid-column: 1 / -1; font-size: 0.7rem; color: var(--text-3); min-height: 60px; }

/* benchmark column */
.model-col--bench .bench { margin-top: 0; }
.bench-env { margin-left: auto; font-size: 0.7rem; color: var(--text-3); }
.bench-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 0.78rem; color: var(--text-2); flex-wrap: wrap; }
.bench-speedup-pill { padding: 2px 10px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); font-weight: 500; letter-spacing: 0; }
.bench-speedup-pill--even { background: var(--bg-secondary); color: var(--text-secondary); }
.bench-speedup-pill--batch { background: color-mix(in srgb, var(--accent-primary) 10%, transparent); color: var(--accent-primary); }
.bench-acc-drop { color: var(--text-3); }
.bench-latency { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; color: var(--text); margin-top: 6px; font-variant-numeric: tabular-nums; }
.bench-latency span { font-family: var(--font-body); font-size: 0.72rem; font-weight: 400; color: var(--text-3); }
.bench-kv { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: 0.72rem; }
.bench-kv-row { display: flex; justify-content: space-between; gap: 10px; }
.bench-kv-key { color: var(--text-3); }
.bench-kv-val { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.bench-kv-base { color: var(--text-3); }

.gallery-empty { text-align: center; color: var(--text-3); padding: 40px 0; }

/* Gallery hardware filter */
.gallery-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 0 0 22px; }
.gallery-filter .deploy-chip { border-radius: var(--radius-sm); font-family: var(--font-body); font-weight: 500; letter-spacing: 0; }
.deploy-chip.is-active { color: var(--on-accent); background: var(--accent-primary); border-color: var(--accent-primary); }

/* ── MODEL PAGE: summary strip (the same card, static) + hand-over toolbar ── */
.model-summary { margin: 0 0 18px; }
.model-summary .model-card--static { cursor: default; }
.model-summary-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; font-size: 0.78rem; color: var(--text-3); }
.model-summary-toolbar .run-btn { white-space: nowrap; }

/* Buttons: .run-btn is the one primary (solid teal); .run-btn--ghost is the quiet variant. */
.run-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--accent-primary); border: 1px solid var(--accent-primary); color: var(--on-accent); border-radius: var(--radius-md); padding: 7px 14px; font-family: var(--font-sans); font-weight: 500; font-size: 0.85rem; cursor: pointer; text-decoration: none; transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease); }
.run-btn:hover { background: var(--teal-10); border-color: var(--teal-10); color: var(--on-accent); }
.run-btn--ghost { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-default); }
.run-btn--ghost:hover { background: var(--bg-secondary); border-color: var(--border-strong); color: var(--text-primary); }
.run-btn[disabled] { opacity: 0.5; cursor: default; }

/* output column */
.model-col--samples { position: relative; }
.run-outputs { min-height: 64px; margin-bottom: 10px; }
.run-hint { font-size: 0.74rem; color: var(--text-3); }
.out-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.out-item { margin: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.out-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--stroke); display: block; }
.out-item.is-miss img { border-color: var(--warning); }
.out-item figcaption { display: flex; flex-direction: column; font-size: 0.64rem; line-height: 1.25; }
.out-pred { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.out-gt { color: var(--warning); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.run-metric { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.run-metric-key { font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.run-metric-val { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.run-metric-sub { font-size: 0.66rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.run-actions .run-btn { font-size: 0.74rem; padding: 6px 10px; }
.upload-panel { display: none; }

/* generic sample renderers */
.sample--text blockquote, .out-item--text blockquote { margin: 0; font-size: 0.7rem; color: var(--text); border-left: 2px solid var(--stroke); padding-left: 6px; max-height: 64px; overflow: hidden; }
.sample audio { width: 100%; height: 28px; }
.det-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.det-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--stroke); display: block; }
.det-box { position: absolute; border: 1.5px solid var(--accent-primary); border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.out-item--chart svg { width: 100%; height: auto; }
.fc-ctx { fill: none; stroke: var(--text-3); stroke-width: 1.2; }
.fc-truth { fill: none; stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 2; }
.fc-pred { fill: none; stroke: var(--accent-primary); stroke-width: 1.5; }

@media (max-width: 820px) {
    .model-card-cols { grid-template-columns: 1fr; }
    .samples { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* The shared hardware dropdown (lib/hwselect.js) in card headers. */
.model-card-header .hw-select { margin-left: auto; }
.model-card-header .hw-button { min-width: 0; padding: 4px 10px; height: auto; }


/* ---- Grouped cards: the other devices' results under the benchmark ---- */
.bench-others { margin-top: 10px; border-top: 1px solid var(--stroke); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.bench-others-title { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.bench-other { display: flex; justify-content: space-between; gap: 10px; font-size: 0.78rem; color: var(--text-2); cursor: pointer; border-radius: 6px; padding: 2px 4px; }
.bench-other:hover { background: var(--cyan-dim); color: var(--cyan-light); }
.bench-other-num { font-variant-numeric: tabular-nums; color: var(--text); }

/* Public cards are not links. */
a.model-card:not([href]) { cursor: default; }
a.model-card:not([href]):hover { border-color: var(--border-subtle); }
.bench-other { cursor: default; }
.bench-other:hover { background: none; color: var(--text-2); }
