/* web-ai-showcase — shared design system.
   Warm editorial palette carried over from image-embedding-lab / the AI-focus demos:
   off-white paper, indigo accent, Georgia display + humanist sans body. Light + dark. */

:root {
  color-scheme: light dark;
  --color: #000;
  --background: #fdfcf8;
  --bg-secondary: #f0eee6;
  --bg-raised: #fffefb;
  --border: #e0ddd4;
  --border-strong: #000;
  --muted: #666;
  --accent: #4b3aff;
  --accent-ink: #fff;
  --good: #1a8a3a;
  --bad: #c0392b;
  --warn: #b8860b;
  --space: 1rem;
  --radius: 10px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color: #e8e4dc;
    --background: #1c1a17;
    --bg-secondary: #2a2723;
    --bg-raised: #24211d;
    --border: #3a3530;
    --border-strong: #6a6258;
    --muted: #9a9088;
    --accent: #8ab4f8;
    --accent-ink: #0c1524;
    --good: #57c97a;
    --bad: #e06c75;
    --warn: #d9a441;
  }
}

/* Cross-document view transitions between catalogue and model pages. */
@view-transition {
  navigation: auto;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  line-height: 1.7;
  color: var(--color);
  background: var(--background);
  padding: 1.5rem;
  max-width: 1080px;
  margin: 0 auto;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: normal;
  line-height: 1.25;
}
h1 {
  font-size: 2rem;
  margin: 0 0 0.3rem;
}
h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}
h3 {
  font-size: 1.05rem;
  margin: 1.4rem 0 0.4rem;
}
a {
  color: var(--accent);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lede {
  font-size: 1.12rem;
  color: var(--color);
}
.crumbs {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.muted {
  color: var(--muted);
}

/* Catalogue grid — content-visibility keeps offscreen cards cheap to render. */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.model-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.model-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.model-card h3 {
  margin: 0;
}

/* Tags: task / modality / backend / size */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}
.tag-run {
  border-color: var(--good);
  color: var(--good);
}
.tag-webgpu {
  border-color: var(--accent);
  color: var(--accent);
}
.tag-flag {
  border-color: var(--warn);
  color: var(--warn);
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Panels for the interactive control surface + the "see inside" viz. */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  padding: 1rem;
  margin: 1rem 0;
}
.panel > h3:first-child {
  margin-top: 0;
}

button,
.button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button.secondary {
  background: var(--bg-raised);
  color: var(--color);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}

input,
textarea,
select {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  color: var(--color);
}

pre,
code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  overflow-x: auto;
}

/* Model-load progress + status — errors go on the page, never only the console. */
.status {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.status.err {
  color: var(--bad);
}
.status.ok {
  color: var(--good);
}
progress {
  width: 100%;
  height: 0.6rem;
}

/* Shared model-loader (lib/model-loader.js): auto-init status + contextual action. */
.model-loader {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.model-loader .loader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.model-loader .loader-detail {
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.model-loader[data-state="ready"] {
  border-color: var(--good);
}
.model-loader[data-state="unsupported"],
.model-loader[data-state="error"] {
  border-color: var(--bad);
}
.model-loader[data-state="update"],
.model-loader[data-state="partial"] {
  border-color: var(--warn);
}
/* A subtle "working" cue on the status while checking/initialising/downloading. */
.model-loader[data-state="checking"] .status::after,
.model-loader[data-state="initialising"] .status::after,
.model-loader[data-state="downloading"] .status::after {
  content: " ⏳";
}

.byline {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  .model-card {
    transition: none;
  }
}
