/*
 * OxiONNX WebGPU Demo — stylesheet.
 *
 * Graphite surfaces and a rust accent, following the design tokens the
 * other COOLJAPAN sub-apps use (see public/geovault/geovault.css). There
 * are no inline styles anywhere in this app — the page runs under
 * `style-src 'self'`, so every visual state is a class or an attribute the
 * browser styles natively (that is why the download bar is a real
 * <progress> element rather than a div with a width).
 */

:root {
  --bg-0: #0c0f14;
  --bg-1: #12161d;
  --bg-2: #171d26;
  --bg-3: #1e2531;

  --border-0: #222a36;
  --border-1: #2e3948;

  --text-0: #dde4ec;
  --text-1: #9aa6b5;
  --text-2: #66717f;

  /* Rust — the runtime is a Rust project, and the accent says so. */
  --accent: #d08a5a;
  --accent-strong: #eaa87a;
  --accent-dim: #5c3a25;
  --accent-wash: rgba(208, 138, 90, 0.12);

  --ok: #4cae7e;
  --ok-wash: rgba(76, 174, 126, 0.12);
  --danger: #e0564f;
  --danger-wash: rgba(224, 86, 79, 0.12);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  --sp-xs: 0.25rem;
  --sp-sm: 0.5rem;
  --sp-md: 1rem;
  --sp-lg: 1.5rem;
  --sp-xl: 2.25rem;

  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --shadow-md: 0 4px 14px -4px rgba(0, 0, 0, 0.6);
  --transition-fast: 150ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-0);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-strong); }
a:hover { color: var(--accent); }

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.skip-link {
  position: absolute;
  left: -999px;
}
.skip-link:focus {
  left: var(--sp-md);
  top: var(--sp-md);
  z-index: 20;
  background: var(--bg-3);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
}

/* ── header ───────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: baseline;
  gap: var(--sp-md);
  flex-wrap: wrap;
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-0);
}

.brand { display: flex; align-items: baseline; gap: var(--sp-sm); }
.brand-name { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.01em; }
.brand-accent { color: var(--accent); }
.brand-sub {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-2);
}
.topbar-tag { color: var(--text-1); font-size: 0.9rem; }
.spacer { flex: 1 1 auto; }
.topbar-link {
  font-size: 0.85rem;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
}

/* ── privacy banner ───────────────────────────────────────────────── */

.privacy-banner {
  display: flex;
  align-items: baseline;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  padding: var(--sp-sm) var(--sp-lg);
  background: var(--ok-wash);
  border-bottom: 1px solid var(--border-0);
  font-size: 0.87rem;
}
.privacy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
  align-self: center;
}
.privacy-detail { color: var(--text-1); }

/* ── layout ───────────────────────────────────────────────────────── */

.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--sp-lg);
  display: grid;
  gap: var(--sp-lg);
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border-0);
  border-radius: var(--radius-md);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-md);
}
.card-h {
  font-size: 1.05rem;
  margin-bottom: var(--sp-sm);
  letter-spacing: 0.01em;
}
.card-note { color: var(--text-1); font-size: 0.88rem; margin-bottom: var(--sp-md); }
.intro p + p { margin-top: var(--sp-sm); }
.muted { color: var(--text-2); }

/* ── capability list ──────────────────────────────────────────────── */

.cap-list { list-style: none; display: grid; gap: var(--sp-sm); }
.cap-empty { color: var(--text-2); }
.cap {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-sm) var(--sp-sm) 0;
  border-bottom: 1px solid var(--border-0);
}
.cap:last-child { border-bottom: none; }
.cap-mark { font-weight: 700; text-align: center; }
.cap.ok .cap-mark { color: var(--ok); }
.cap.bad .cap-mark { color: var(--danger); }
.cap-label { font-weight: 600; }
.cap-detail { color: var(--text-1); margin-left: var(--sp-sm); font-size: 0.86rem; }
.cap-advice {
  color: var(--text-1);
  font-size: 0.84rem;
  margin-top: var(--sp-xs);
  padding-left: var(--sp-sm);
  border-left: 2px solid var(--accent-dim);
}
.engine-pick {
  margin-top: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--accent-wash);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

/* ── model table ──────────────────────────────────────────────────── */

.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-bottom: var(--sp-md);
}
.model-table th, .model-table td {
  text-align: left;
  padding: var(--sp-sm);
  border-bottom: 1px solid var(--border-0);
}
.model-table thead th { color: var(--text-2); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.model-table tfoot th, .model-table tfoot td { border-bottom: none; padding-top: var(--sp-md); }
.model-table tfoot td { color: var(--accent-strong); }

/* ── buttons ──────────────────────────────────────────────────────── */

.btn-row {
  display: flex;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  align-items: center;
}
.btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-1);
  background: var(--bg-3);
  color: var(--text-0);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent-dim); border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent); color: #1a1207; }
.btn-ghost { background: transparent; }
.linkish {
  font: inherit;
  font-size: inherit;
  background: none;
  border: none;
  color: var(--accent-strong);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  color: var(--text-1);
  font-size: 0.86rem;
  margin-left: auto;
}
.field-inline select {
  font: inherit;
  font-size: 0.86rem;
  background: var(--bg-3);
  color: var(--text-0);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
}
.field-inline select:disabled { opacity: 0.45; }

/* ── progress ─────────────────────────────────────────────────────── */

.progress-block { margin-top: var(--sp-md); }
.progress-label { font-size: 0.88rem; font-weight: 600; }
.progress {
  width: 100%;
  height: 8px;
  margin: var(--sp-xs) 0;
  border: none;
  border-radius: 4px;
  background: var(--bg-3);
  accent-color: var(--accent);
}
.progress::-webkit-progress-bar { background: var(--bg-3); border-radius: 4px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
.progress-detail { font-size: 0.82rem; color: var(--text-1); font-family: var(--font-mono); }

.err {
  margin-top: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--danger-wash);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

/* ── photo IO ─────────────────────────────────────────────────────── */

.io-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}
.io-slot { display: flex; flex-direction: column; gap: var(--sp-sm); }
.io-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2); }
.io-file { font: inherit; font-size: 0.82rem; color: var(--text-1); }
.io-file:disabled { opacity: 0.45; cursor: not-allowed; }
.canvas-frame {
  background: var(--bg-0);
  border: 1px dashed var(--border-1);
  border-radius: var(--radius-sm);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.canvas-frame.result { border-style: solid; border-color: var(--accent-dim); }
.canvas-frame canvas { max-width: 100%; max-height: 340px; display: block; }
.io-meta { font-size: 0.8rem; color: var(--text-2); font-family: var(--font-mono); }
.synthetic-note {
  margin-top: var(--sp-md);
  font-size: 0.84rem;
  color: var(--text-1);
  border-left: 2px solid var(--accent-dim);
  padding-left: var(--sp-sm);
}

/* ── stats ────────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-sm);
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--border-0);
  border-radius: var(--radius-sm);
  padding: var(--sp-sm) var(--sp-md);
}
.stat dt { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-2); }
.stat dd { font-family: var(--font-mono); font-size: 0.9rem; margin-top: var(--sp-xs); word-break: break-word; }

/* ── video placeholder ────────────────────────────────────────────── */

#video-tab[data-stage="placeholder"] {
  border-style: dashed;
  background: var(--bg-0);
}

/* ── footer ───────────────────────────────────────────────────────── */

.foot {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--sp-lg);
  color: var(--text-2);
  font-size: 0.84rem;
  border-top: 1px solid var(--border-0);
}

/* ── consent dialog ───────────────────────────────────────────────── */

.consent {
  max-width: 44rem;
  width: calc(100vw - 2rem);
  background: var(--bg-1);
  color: var(--text-0);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: var(--sp-xl);
  box-shadow: var(--shadow-md);
}
.consent::backdrop { background: rgba(4, 6, 9, 0.82); }
.consent-h { font-size: 1.2rem; margin-bottom: var(--sp-sm); }
.consent-lede { color: var(--text-1); margin-bottom: var(--sp-md); }
.consent-list { margin: 0 0 var(--sp-md) 1.1rem; display: grid; gap: var(--sp-sm); font-size: 0.92rem; }
.consent-privacy {
  font-size: 0.86rem;
  color: var(--text-1);
  background: var(--ok-wash);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-sm);
  padding: var(--sp-sm) var(--sp-md);
  margin-bottom: var(--sp-lg);
}
.consent-actions { justify-content: flex-end; }

/* ── video tab ────────────────────────────────────────────────────── */

/* The two <video> elements sit in the same dashed frames the photo
   canvases use, so the tab reads as one surface rather than a bolt-on. */
.canvas-frame video { max-width: 100%; max-height: 340px; display: block; }

/* A two-column key/value table; the shared .model-table rules give it its
   borders and spacing, this only fixes the label column's width. */
.video-probe { margin-bottom: var(--sp-md); }
.video-probe th { width: 9.5rem; color: var(--text-2); font-weight: 600; }
.video-probe td { color: var(--text-1); font-size: 0.88rem; }

.video-cap {
  margin: var(--sp-sm) 0 var(--sp-md);
  font-size: 0.86rem;
  color: var(--text-1);
  background: var(--accent-wash);
  border-left: 3px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: var(--sp-sm) var(--sp-md);
}
.video-cap label { display: flex; gap: var(--sp-sm); align-items: baseline; cursor: pointer; }
.video-cap input { accent-color: var(--accent); }

/* The estimate gate. Loud on purpose — it is the one moment the page asks
   the visitor to commit minutes of their machine to a render. */
.video-confirm {
  margin: var(--sp-md) 0;
  background: var(--bg-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: var(--sp-md);
  font-size: 0.9rem;
  color: var(--text-1);
}
.video-confirm .btn-row { margin-top: var(--sp-md); margin-bottom: 0; }

/* Horizontal strip of finished frames. `overflow-x` rather than a wrap:
   the point is the sequence, and it must not push the page around while a
   render is adding to it. */
.filmstrip {
  display: flex;
  gap: var(--sp-sm);
  overflow-x: auto;
  padding: var(--sp-sm) 0;
  margin-bottom: var(--sp-sm);
  scrollbar-width: thin;
}
.film-cell { flex: 0 0 auto; text-align: center; }
.film-cell canvas {
  display: block;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  background: var(--bg-0);
}
.film-cell figcaption {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
  margin-top: var(--sp-xs);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .layout, .foot { padding: var(--sp-md); }
  .card { padding: var(--sp-md); }
  .field-inline { margin-left: 0; }
  .video-probe th { width: auto; }
}
