/* Interactive demo */
#demo .hidden { display: none !important; }

:root {
  --demo-ink: #182235;
  --demo-muted: #667085;
  --demo-line: #e6ebf3;
  --demo-accent: #2878ed;
  --demo-accent-dark: #175dc2;
  --demo-gt: #34d399;
  --demo-gt-ink: #087a54;
  --demo-pred: #60a5fa;
  --demo-pred-ink: #1565c0;
  --demo-bad-ink: #c0392f;
}

.demo-section-lede {
  max-width: 660px;
  margin: -0.7rem auto 1.6rem;
  color: #657084;
  text-align: center;
  font-size: 1rem;
  line-height: 1.6;
}

.demo-section-howto {
  max-width: 700px;
  margin: -1.1rem auto 1.5rem;
  color: #7b869a;
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.65;
}

.demo-swatch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.demo-swatch::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.demo-swatch.pred { color: var(--demo-pred-ink); }
.demo-swatch.gt { color: var(--demo-gt-ink); }
.demo-swatch.pred::before { background: var(--demo-pred); }
.demo-swatch.gt::before { background: var(--demo-gt); }

.demo-card {
  margin-bottom: 2rem;
  border: 1px solid #e5eaf2;
  border-radius: 18px;
  background: #f7f9fc;
  box-shadow: 0 18px 50px rgba(31, 45, 72, 0.08);
}

.demo-eyebrow {
  display: block;
  color: var(--demo-muted);
  font-family: 'Google Sans', 'Noto Sans', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

/* ── stage: viewport + one panel, equal height ── */
.demo-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: stretch;
  padding: 16px;
}

/* ── viewport ── */
.demo-viewport {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 38%, #1d2740 0%, #0e131f 100%);
}

.demo-viewport > canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.demo-viewport > canvas:focus-visible {
  outline: 2px solid var(--demo-pred);
  outline-offset: -2px;
}

.demo-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 14px;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(11, 16, 27, 0.6);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.demo-key {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e8edf7;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.demo-key::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.demo-key.gt::before { background: var(--demo-gt); }
.demo-key.pred::before { background: var(--demo-pred); }

.demo-zoom-hint {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(11, 16, 27, 0.6);
  backdrop-filter: blur(6px);
  color: #c9d3e4;
  font-size: 0.7rem;
  pointer-events: none;
}


/* Video-first: the method is video-only, so each scene opens on its raw input. */
.demo-viewport.video-mode > canvas,
.demo-viewport.video-mode .demo-legend,
.demo-viewport.video-mode .demo-zoom-hint { display: none; }

.demo-viewport.video-mode .demo-video-inset {
  inset: 0;
  width: auto;
  min-width: 0;
  max-width: none;
  border: 0;
  border-radius: 0;
  background: #05070c;
  box-shadow: none;
}

.demo-viewport.video-mode .demo-video-inset video {
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
}

.demo-video-inset video { cursor: pointer; }

.demo-viewport.video-mode .demo-inset-label {
  bottom: 12px;
  left: 12px;
  padding: 5px 10px;
  font-size: 0.72rem;
}

.demo-video-inset {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 30%;
  min-width: 150px;
  max-width: 260px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  background: #05070c;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}

.demo-video-inset video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.demo-inset-label {
  position: absolute;
  bottom: 6px;
  left: 7px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(5, 7, 12, 0.72);
  color: #d5deee;
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.demo-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0 0 0 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(11, 16, 27, 0.75);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}

.demo-viewport:not(.video-mode) .demo-play-btn {
  width: 34px;
  height: 34px;
  font-size: 0.7rem;
}

.demo-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(10, 14, 24, 0.55);
  color: #cdd7e8;
  font-size: 0.85rem;
  text-align: center;
  backdrop-filter: blur(2px);
}

.demo-spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--demo-pred);
  border-radius: 50%;
  animation: demo-spin 0.85s linear infinite;
}

.demo-loading.demo-error { color: #d7deea; }
.demo-loading.demo-error .demo-spinner { display: none; }

@keyframes demo-spin { to { transform: rotate(360deg); } }

/* ── panel ── */
.demo-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--demo-line);
  border-radius: 14px;
  background: #fff;
}

.demo-scene-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--demo-line);
}

.demo-scene-row .demo-eyebrow { flex: none; }

.demo-select-wrap {
  position: relative;
  flex: 1;
}

.demo-select-wrap::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 12px;
  width: 7px;
  height: 7px;
  border-right: 1.8px solid var(--demo-muted);
  border-bottom: 1.8px solid var(--demo-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.demo-select {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--demo-line);
  border-radius: 9px;
  background: #fbfcfe;
  color: var(--demo-ink);
  font-family: 'Google Sans', 'Noto Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
}

.demo-select:hover { border-color: #c3d6f4; }

.demo-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--demo-accent), var(--demo-accent-dark));
  color: #fff;
  font-family: 'Google Sans', 'Noto Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(40, 120, 237, 0.28);
  transition: filter 0.15s ease, transform 0.15s ease;
}

.demo-cta:hover { filter: brightness(1.07); transform: translateY(-1px); }
.demo-cta:active { transform: none; }

.demo-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

/* ── situation pills: the count has to be obvious, not discovered ── */
.demo-sit-count {
  color: var(--demo-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

/* One segmented bar rather than a ragged row: scenes hold three to five situations,
   and equal segments keep the control the same size and shape in every scene. */
.demo-sit-pills {
  display: flex;
  margin-bottom: 11px;
  border: 1px solid var(--demo-line);
  border-radius: 9px;
  background: #fbfcfe;
  overflow: hidden;
}

.demo-sit-pill {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-left: 1px solid var(--demo-line);
  background: transparent;
  color: var(--demo-muted);
  font-family: 'Google Sans', 'Noto Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.demo-sit-pill:first-child { border-left: 0; }

.demo-sit-pill:hover { background: #f4f8ff; color: var(--demo-ink); }

.demo-sit-pill.active {
  background: var(--demo-accent);
  color: #fff;
}

/* the bar clips its children, so the focus ring is drawn inside the segment */
.demo-sit-pill:focus-visible { outline-offset: -2px; }

.demo-sit-text {
  min-height: 3.4em;
  margin: 0;
  color: var(--demo-ink);
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.demo-sit-text::before,
.demo-sit-text::after { content: '\201C'; color: #b7c2d4; }
.demo-sit-text::after { content: '\201D'; }

/* ── questions ── */
.demo-located {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 11px 13px;
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: 10px;
  background: linear-gradient(180deg, #f2fbf7, #ecf9f3);
}

.demo-located-title {
  color: var(--demo-gt-ink);
  font-family: 'Google Sans', 'Noto Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
}

.demo-located-title::before {
  content: '\2713';
  margin-right: 6px;
  font-weight: 700;
}

.demo-located-keys {
  display: flex;
  gap: 12px;
  font-size: 0.72rem;
}

.demo-q-block {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  padding-top: 14px;
  border-top: 1px solid var(--demo-line);
}

.demo-q-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.demo-q {
  border: 1px solid var(--demo-line);
  border-radius: 10px;
  background: #fbfcfe;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.demo-q:hover { border-color: #c3d6f4; background: #f7faff; }

.demo-q.open {
  border-color: rgba(40, 120, 237, 0.45);
  background: #f5f9ff;
}

.demo-q-btn {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: var(--demo-ink);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.demo-q-chev {
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: 0.42em;
  border-right: 1.8px solid #98a5ba;
  border-bottom: 1.8px solid #98a5ba;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}

.demo-q.open .demo-q-chev {
  margin-top: 0.3em;
  border-color: var(--demo-accent);
  transform: rotate(45deg);
}

.demo-q-body {
  padding: 0 12px 11px 28px;
}

.demo-answer {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--demo-line);
}

/* dot · label · value · tick — the dot repeats the marker colour in the viewport */
.demo-a-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  background: #fff;
}

.demo-a-row::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.demo-a-row.pred::before { background: var(--demo-pred); }
.demo-a-row.gt::before { background: var(--demo-gt); }

.demo-a-label {
  color: var(--demo-muted);
  font-size: 0.71rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.demo-a-word {
  justify-self: end;
  min-width: 0.6em;
  color: var(--demo-ink);
  font-size: 0.98rem;
  font-weight: 700;
  text-align: right;
}

/* On a match both answers turn green so the agreement reads at a glance; only the
   model's answer can carry the red verdict. */
.demo-a-word.ok { color: var(--demo-gt-ink); }
.demo-a-row.pred .demo-a-word.bad { color: var(--demo-bad-ink); }

.demo-a-tick {
  justify-self: end;
  width: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  text-align: right;
}

.demo-a-tick.ok { color: var(--demo-gt-ink); }
.demo-a-tick.bad { color: var(--demo-bad-ink); }

.demo-a-alt {
  margin: 6px 0 0;
  color: var(--demo-muted);
  font-size: 0.75rem;
}

.demo-a-alt:empty { display: none; }

.demo-status {
  margin: 0;
  color: var(--demo-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.demo-note {
  margin: auto 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--demo-line);
  color: #5b6577;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
}

.demo-q-btn:focus-visible,
.demo-sit-pill:focus-visible,
.demo-select:focus-visible,
.demo-play-btn:focus-visible {
  outline: 2px solid var(--demo-accent);
  outline-offset: 2px;
}

.demo-typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin-left: 2px;
  background: var(--demo-accent);
  vertical-align: text-bottom;
  animation: demo-caret 0.9s steps(1) infinite;
}

@keyframes demo-caret { 50% { opacity: 0; } }

.demo-pop { animation: demo-pop 0.28s cubic-bezier(0.2, 1.35, 0.4, 1) both; }

@keyframes demo-pop {
  from { opacity: 0; transform: translateY(4px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

/* ── responsive ── */
@media (max-width: 960px) {
  .demo-stage { grid-template-columns: 1fr; }

  .demo-viewport {
    min-height: 0;
    aspect-ratio: 4 / 3;
  }

  .demo-panel { overflow: visible; }
}

@media (max-width: 700px) {
  .demo-section-lede { padding: 0 12px; font-size: 0.9rem; }
  .demo-section-howto { padding: 0 12px; font-size: 0.82rem; }
  .demo-stage { gap: 12px; padding: 12px; }
  .demo-viewport { aspect-ratio: 1 / 1; }
  .demo-video-inset { width: 38%; min-width: 0; }
  .demo-zoom-hint { display: none; }
  .demo-panel { padding: 14px; }
  .demo-sit-text { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .demo-spinner,
  .demo-pop,
  .demo-typing::after { animation: none !important; }

  .demo-q,
  .demo-q-chev,
  .demo-sit-pill { transition: none !important; }
}
