/* ─── LLM explainer: code-driven animation player ─────────────────
   Usage: <figure data-llm-explainer></figure> + js/llm-explainer.js
   All colours come from the site tokens in docs.css.                 */

.llmx {
  --llmx-p: 0;
  margin: var(--space-8, 32px) 0;
  background: var(--surface, #fffdf8);
  border: 1px solid var(--border, #ded3c5);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  color: var(--fg, #1f1a16);
}

.llmx-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bg, #fbf7f0);
  cursor: pointer;
}

.llmx-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.llmx-bigplay {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: var(--radius-pill, 9999px);
  background: var(--accent, #9a5a2f);
  color: var(--accent-on, #fff);
  box-shadow: var(--elev-raised, 0 20px 50px rgba(31, 26, 22, 0.12));
  display: grid;
  place-items: center;
  transition: transform var(--motion-fast, 180ms) var(--ease-standard, ease),
              background var(--motion-fast, 180ms) var(--ease-standard, ease);
}
.llmx-bigplay svg { width: 30px; height: 30px; }
.llmx-bigplay:hover { background: var(--accent-hover, #8c5129); transform: scale(1.05); }
.llmx-bigplay[hidden] { display: none; }

.llmx-caption {
  margin: 0;
  min-height: calc(3 * 1.55em + 28px);
  padding: 14px 20px;
  font-family: var(--font-body, Georgia, serif);
  font-size: 17px;
  line-height: 1.55;
  color: var(--fg-2, #4b4038);
  border-top: 1px solid var(--border-soft, #eee5da);
}

.llmx-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-soft, #eee5da);
  background: var(--surface, #fffdf8);
}

.llmx-btn {
  flex: none;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border, #ded3c5);
  border-radius: var(--radius-md, 8px);
  background: var(--surface, #fffdf8);
  color: var(--fg, #1f1a16);
  display: grid;
  place-items: center;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  transition: background var(--motion-fast, 180ms) var(--ease-standard, ease);
}
.llmx-btn:hover { background: var(--border-soft, #eee5da); }
.llmx-btn:focus-visible,
.llmx-track:focus-visible,
.llmx-chapters:focus-visible,
.llmx-bigplay:focus-visible { outline: none; box-shadow: var(--focus-ring, 0 0 0 4px rgba(154, 90, 47, 0.24)); }

.llmx-track {
  position: relative;
  flex: 1;
  min-width: 80px;
  height: 32px;
  cursor: pointer;
  touch-action: none;
  border-radius: var(--radius-sm, 4px);
}
.llmx-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: var(--border, #ded3c5);
  overflow: hidden;
}
.llmx-fill {
  height: 100%;
  width: calc(var(--llmx-p) * 100%);
  background: var(--accent, #9a5a2f);
}
.llmx-tick {
  position: absolute;
  top: 50%;
  left: calc(var(--at) * 100%);
  width: 2px;
  height: 10px;
  margin: -5px 0 0 -1px;
  background: var(--muted, #7d7168);
  opacity: 0.45;
  pointer-events: none;
}
.llmx-thumb {
  position: absolute;
  top: 50%;
  left: calc(var(--llmx-p) * 100%);
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent, #9a5a2f);
  box-shadow: 0 0 0 3px var(--surface, #fffdf8);
  pointer-events: none;
}

.llmx-time {
  flex: none;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  color: var(--muted, #7d7168);
  font-variant-numeric: tabular-nums;
}

.llmx-chapters {
  flex: none;
  max-width: 210px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border, #ded3c5);
  border-radius: var(--radius-md, 8px);
  background: var(--surface, #fffdf8);
  color: var(--fg, #1f1a16);
  font-family: var(--font-mono, monospace);
  font-size: 13px;
}

/* full screen: stage fills, canvas letterboxes itself */
.llmx:fullscreen {
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: var(--bg, #fbf7f0);
}
.llmx:fullscreen .llmx-stage { flex: 1; aspect-ratio: auto; min-height: 0; }
.llmx:fullscreen .llmx-caption { min-height: 0; text-align: center; font-size: 20px; }

@media (max-width: 720px) {
  .llmx-chapters { display: none; }
  .llmx-caption { font-size: 15px; padding: 12px 16px; }
  .llmx-controls { gap: 6px; padding: 8px 10px; }
  .llmx-time { font-size: 12px; }
}
@media (max-width: 420px) {
  .llmx-restart, .llmx-time { display: none; }
}
