/* ==========================================================================
   Leo Console — additive layer.
   Tokens only (Vapor Cathedral rule 1). No raw values, no new colours.
   The base sheet ships .sidebar/.topbar at opacity:0 because the source page
   fades them in with GSAP; this layer does the same reveal in CSS.
   ========================================================================== */

.sidebar, .topbar { animation: leoIn var(--dur-slow) var(--ease-out) forwards; }
.sr { opacity: 0; animation: leoUp var(--dur-slow) var(--ease-out) forwards; }
.sr-group > * { opacity: 0; animation: leoUp var(--dur-slow) var(--ease-out) forwards; }
.sr-group > *:nth-child(2) { animation-delay: .05s }
.sr-group > *:nth-child(3) { animation-delay: .1s }
.sr-group > *:nth-child(4) { animation-delay: .15s }
.sr-group > *:nth-child(5) { animation-delay: .2s }
.sr-group > *:nth-child(6) { animation-delay: .25s }

@keyframes leoIn { to { opacity: 1 } }
@keyframes leoUp { from { opacity: 0; transform: translateY(var(--sp-5)) } to { opacity: 1; transform: none } }

/* section rhythm */
.leo-sec { scroll-margin-top: var(--sp-6); margin-bottom: var(--sp-16); }
.leo-sec:last-child { margin-bottom: var(--sp-10); }

/* the reel library: poster card built from .card + tokens */
.leo-reel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.leo-poster {
  position: relative; aspect-ratio: 9 / 16; background: var(--surface-3);
  border-bottom: 1px solid var(--line); overflow: hidden; cursor: pointer;
}
.leo-poster img { width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform var(--dur-slow) var(--ease-out); }
.leo-poster:hover img { transform: scale(1.04); }
.leo-poster .leo-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, transparent 45%, var(--scrim));
  opacity: 0; transition: opacity var(--dur-base) ease;
}
.leo-poster:hover .leo-play, .leo-poster:focus-visible .leo-play { opacity: 1; }
.leo-play span {
  width: 52px; height: 52px; border-radius: var(--r-full); background: var(--volt);
  color: var(--ink); display: grid; place-items: center; font-size: var(--fs-md);
  transition: transform var(--dur-base) var(--ease-spring);
}
.leo-poster:hover .leo-play span { transform: scale(1.08); }
.leo-poster:active .leo-play span { transform: scale(.96); }
.leo-stamp {
  position: absolute; left: var(--sp-2); top: var(--sp-2); z-index: 2;
  font-family: 'Source Code Pro', ui-monospace, monospace; font-size: var(--fs-xs);
  background: var(--scrim); color: var(--ink); padding: 2px var(--sp-2);
  border-radius: var(--r-full);
}
[data-theme="light"] .leo-stamp { color: var(--surface-1); }
.leo-reel-body { padding: var(--sp-4); display: grid; gap: var(--sp-2); }
.leo-reel-body h4 { font-size: var(--fs-sm); }
.leo-reel-meta {
  font-family: 'Source Code Pro', ui-monospace, monospace; font-size: var(--fs-xs);
  color: var(--text-3); display: flex; gap: var(--sp-2); flex-wrap: wrap;
}

/* live log */
.leo-log {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); max-height: 260px; overflow: auto;
  font-family: 'Source Code Pro', ui-monospace, monospace; font-size: var(--fs-xs);
  line-height: 1.8; color: var(--text-2); white-space: pre-wrap; word-break: break-word;
}
.leo-log b { color: var(--volt); font-weight: 600; }
[data-theme="light"] .leo-log b { color: var(--outline-color); }

/* player dialog is wider than the stock .dialog */
.leo-player { max-width: 940px; width: min(94vw, 940px); }
.leo-player video {
  width: 100%; max-height: 62vh; border-radius: var(--r-md);
  background: var(--surface-3); border: 1px solid var(--line); display: block;
}
.leo-player-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: var(--sp-5); align-items: start; }
@media (max-width: 720px) { .leo-player-grid { grid-template-columns: 1fr; } }

/* shot strip */
.leo-shots { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.leo-shot {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-sm);
  font-family: 'Source Code Pro', ui-monospace, monospace; font-size: var(--fs-xs);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2);
}
.leo-shot.ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--text); }
.leo-shot.warn { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--text); }
.leo-shot.bad { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--text); }

.leo-kv { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm); }
.leo-kv dt { color: var(--text-3); font-family: 'Source Code Pro', ui-monospace, monospace;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; }
.leo-kv dd { color: var(--text); }

.leo-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.leo-mono { font-family: 'Source Code Pro', ui-monospace, monospace; }
.leo-scroll { max-height: 300px; overflow: auto; }

/* two-column blocks that may hold a wide table — both tracks must be allowed
   to shrink, or the table pushes its panel past the edge and gets clipped */
.leo-cols { display: grid; gap: var(--sp-5);
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); align-items: start; }
.leo-cols > * { min-width: 0; }

/* idea cards: the whole card is the hit target */
.leo-idea { cursor: pointer; display: flex; flex-direction: column; padding: 0; overflow: hidden;
  transition: border-color var(--dur-base) ease, transform var(--dur-base) var(--ease-spring); }
.leo-idea:hover { border-color: var(--volt); }
.leo-idea:active { transform: scale(.99); }
.leo-idea:focus-visible { outline: 2px solid var(--volt); outline-offset: 2px; }
.leo-idea-poster { position: relative; aspect-ratio: 16 / 10; background: var(--surface-3);
  border-bottom: 1px solid var(--line); overflow: hidden; }
.leo-idea-poster img { width: 100%; height: 100%; object-fit: cover; object-position: center 28%;
  display: block; transition: transform var(--dur-slow) var(--ease-out); }
.leo-idea:hover .leo-idea-poster img { transform: scale(1.05); }
.leo-idea-body { padding: var(--sp-4); display: grid; gap: var(--sp-2); }
.leo-idea-body p { font-size: var(--fs-sm); color: var(--text-2); }
.leo-idea-foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  margin-top: var(--sp-1); }

/* the now-rendering panel is one big button */
.leo-clickable { cursor: pointer; transition: border-color var(--dur-base) ease; }
.leo-clickable:hover { border-color: var(--volt); }
.leo-clickable:focus-visible { outline: 2px solid var(--volt); outline-offset: 2px; }
.leo-hint { font-size: var(--fs-xs); color: var(--text-3);
  font-family: 'Source Code Pro', ui-monospace, monospace; }

/* script view */
.leo-shot-row { border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--sp-4); background: var(--surface-1); margin-bottom: var(--sp-3); }
.leo-shot-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-3); }
.leo-shot-n { width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: var(--r-sm); background: var(--volt); color: var(--ink); font-weight: 700;
  font-family: 'Source Code Pro', ui-monospace, monospace; font-size: var(--fs-xs); }
.leo-line { font-size: var(--fs-md); color: var(--text); margin: var(--sp-2) 0;
  padding-left: var(--sp-4); border-left: 2px solid var(--volt); }
.leo-dim { font-size: var(--fs-xs); color: var(--text-3); }
.leo-prose { font-size: var(--fs-sm); color: var(--text-2); }

/* ---------- generation indicators ---------- */
/* an element that is actively being produced: a slow accent breathe on its edge */
.leo-working { border-color: var(--line-strong); animation: leoWork 2.4s var(--ease-out) infinite; }
@keyframes leoWork {
  0%, 100% { border-color: var(--line); }
  50%      { border-color: var(--volt); }
}
.leo-shot.working { background: var(--volt-dim); border-color: var(--volt); }
.leo-shot.working .spinner-ring { width: 14px; height: 14px; border-width: 2px; }

/* the live progress bar keeps its shimmer even at 0% width */
.leo-progress-live { position: relative; }
.leo-progress-live::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, var(--volt-dim) 50%, transparent 70%);
  animation: leoSweep 1.9s var(--ease-out) infinite;
}
@keyframes leoSweep { from { transform: translateX(-100%) } to { transform: translateX(100%) } }

.leo-poster-live { display: grid; place-items: center;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3)); cursor: pointer; }
.leo-live-center { display: grid; place-items: center; text-align: center; }

/* reduced motion: keep the meaning, drop the movement */
@media (prefers-reduced-motion: reduce) {
  .leo-working { animation: none; border-color: var(--volt); }
  .leo-progress-live::after { animation: none; opacity: 0; }
}
