/* ═══════════════════════════════════════════════════════════════════════════
   Use-case animations — stage furniture.

   This file styles everything AROUND the app: the plinth a figure sits on, the
   pointer, the captions, the transport in the video stage. The application UI
   itself is styled entirely by triplo-ui.css, which is generated from src/.

   Nothing here may restyle a `.tri-stage` component. If the replica looks
   wrong, the fix is in the app's own CSS, then a re-run of
   tools/build-anim-css.py — never a rule added below.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── The stage box ───────────────────────────────────────────────────────── */

/* Horizontal padding is 20px, not the 26px .doc-shot uses, on purpose: the
   docs column is 728px wide and the window is 680px, so anything wider forces
   a fractional scale and the whole replica renders soft. 20px leaves 688px and
   the window draws at 1:1. */
.tri-figure {
  margin: 26px 0;
  background: linear-gradient(160deg, hsl(136, 18%, 95%) 0%, var(--slate-100, #f1f5f9) 100%);
  border: 1px solid var(--slate-200, #e2e8f0);
  border-radius: 14px;
  padding: 26px 20px;
}

/* The viewport reserves the tallest frame of the scene (engine.js measures it),
   so the window never needs clipping — and clipping would slice a hard edge
   through its drop shadow. */
.tri-viewport {
  position: relative;
  width: 100%;
}

/* The app window is 680px wide (--app-width in SpotlightBar.css). Rather than
   restyle it for narrow screens — which would be a different product — the
   whole window is scaled down as one piece, the way a screenshot would be. */
/* At 1:1 the transform is dropped entirely rather than set to scale(1) — a
   transformed element gets its own compositing layer and rasterises text
   slightly softer even at identity. */
.tri-stage[data-crisp="1"] { transform: none; }

.tri-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 680px;
  transform-origin: top left;
  transform: scale(var(--tri-scale, 1));
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  box-sizing: border-box;
  /* The OS paints the desktop behind a transparent window; a page has to
     paint its own, or --bg-primary's 2% transparency shows the plinth. */
  border-radius: var(--radius-lg, 14px);
}

.tri-stage .spotlight-inner {
  background: #1e1e20;
  box-shadow: 0 18px 46px rgba(13, 20, 17, 0.28), 0 3px 8px rgba(13, 20, 17, 0.16);
}

.tri-figure figcaption {
  font-size: 12.5px;
  color: var(--slate-500, #64748b);
  margin-top: 18px;
  line-height: 1.55;
  text-align: center;
}

/* ── Stage caption: the line that says which half of the story is on screen.
      Deliberately outside the window — it is narration, not product UI. ──── */

.tri-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 22px;
  margin-top: 18px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--slate-500, #64748b);
  text-align: center;
  transition: opacity 0.35s ease;
}

.tri-legend[data-state="out"] { opacity: 0; }

.tri-legend b {
  font-weight: 650;
  color: var(--brand-dark, #24753a);
}

.tri-legend-rule {
  flex: 0 0 22px;
  height: 1px;
  background: var(--slate-300, #cbd5e1);
}

/* ── Pointer ─────────────────────────────────────────────────────────────── */

.tri-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  margin: -2px 0 0 -2px;
  pointer-events: none;
  z-index: 900;
  opacity: 0;
  transform: translate(var(--x, 0px), var(--y, 0px));
  transition: transform 0.62s cubic-bezier(0.32, 0.72, 0.24, 1), opacity 0.25s ease;
  will-change: transform;
}

.tri-cursor[data-on="1"] { opacity: 1; }
.tri-cursor svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55)); }

.tri-ripple {
  position: absolute;
  top: 0;
  left: 0;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 1.5px solid rgba(52, 199, 89, 0.85);
  pointer-events: none;
  z-index: 899;
  opacity: 0;
  transform: translate(var(--x, 0px), var(--y, 0px)) scale(0.35);
}

.tri-ripple[data-fire="1"] { animation: tri-ripple 0.5s ease-out; }

@keyframes tri-ripple {
  0%   { opacity: 0.9; transform: translate(var(--x), var(--y)) scale(0.35); }
  100% { opacity: 0;   transform: translate(var(--x), var(--y)) scale(1.15); }
}

/* ── Host-page guard ─────────────────────────────────────────────────────────
   The replica sits inside a `.doc-section` on a documentation page, and that
   page styles bare elements: `.doc-section p` paints prose slate grey, and the
   global `code` rule paints inline code brand green with a light background and
   `white-space: nowrap`. Both land on the replica's own <p> and <code>, because
   the app styles those by inheritance from `.chat-markdown` and never targets
   the tags directly — so the host page wins on specificity and the answer
   renders grey text with green code inside a dark bubble.

   This hands every such element back to inheritance. Specificity is (0,2,1),
   above `.doc-section p` (0,1,1) and below every generated component rule
   (0,3,1), so the app's own CSS still decides how anything actually looks.

   It must stay ahead of triplo-ui.css in the cascade — build.py emits the two
   links in that order.
   ────────────────────────────────────────────────────────────────────────── */

.tri-stage .spotlight-container :is(p, ul, ol, li, h1, h2, h3, h4, h5, h6,
  strong, b, em, i, a, hr, blockquote, table, thead, tbody, tr, th, td) {
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  text-decoration: none;
  text-transform: none;
  vertical-align: baseline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  width: auto;
  height: auto;
}

/* The thinking and tool blocks style their text by class, not inheritance —
   but their <p>/<pre> are bare tags the guard above would hand back to the
   page ink (their generated rules carry (0,2,0), the guard (0,2,1)). This
   deviation restores the app's own decision, out-specifying the guard. */
.tri-stage .thinking-block .thinking-text {
  color: var(--text-secondary);
}
.tri-stage .thinking-block .thinking-text--code {
  color: var(--text-secondary);
}

.tri-stage .spotlight-container li::marker { color: inherit; }

/* Preformatted text keeps the browser's monospace default and, in <pre>, its
   own whitespace handling — only the host page's colour, sizing and boxes go. */
.tri-stage .spotlight-container :is(code, kbd, samp) {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  white-space: normal;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.tri-stage .spotlight-container pre {
  color: inherit;
  font-size: inherit;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.tri-stage .spotlight-container pre code { white-space: inherit; }

/* ── Deviations from the app, and why ────────────────────────────────────────
   Five, all forced by putting a window-sized UI inside a page. Every one is
   listed here so the difference between product and replica is one short list.

   Each selector repeats `.tri-stage` deliberately. A deviation has to beat the
   generated rule it overrides, and `.tri-stage .selector-overlay` in anim.css
   ties `.tri-stage .selector-overlay` in triplo-ui.css on specificity — so the
   later file silently won and `position: fixed` survived. Doubling the class
   raises specificity without changing what it matches, and makes the outcome
   independent of which stylesheet loads first.
   ────────────────────────────────────────────────────────────────────────── */

/* 1 · The app portals its popups to document.body and pins them to the OS
      window with position:fixed. In a page that is catastrophic: with no
      transform on the stage there is no containing block, so `inset: 0`
      resolves against the browser viewport and an invisible overlay covers
      the whole document. Absolute, against the stage, has the same geometry
      inside the window and none of that reach. */
.tri-stage.tri-stage .selector-overlay,
.tri-stage.tri-stage .prompt-editor-overlay,
.tri-stage.tri-stage .confirm-auto-overlay {
  position: absolute;
  /* Nothing in a scene is clickable; the transport lives outside the stage. */
  pointer-events: none;
}

/* 2 · The window is a fixed pixel width set from Electron; the stage supplies
      it on .tri-stage and scales the whole thing. */
.tri-stage.tri-stage .spotlight-container { width: 100%; }

/* 3 · Popup entrances are framer-motion springs (stiffness 400, damping 30).
      No framer-motion here, so they are CSS approximations of the same
      motion: a 150ms backdrop fade and a short overshooting rise. */
.tri-stage.tri-stage .selector-overlay,
.tri-stage.tri-stage .prompt-editor-overlay,
.tri-stage.tri-stage .confirm-auto-overlay {
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tri-stage.tri-stage .selector-overlay[data-open="1"],
.tri-stage.tri-stage .prompt-editor-overlay[data-open="1"],
.tri-stage.tri-stage .confirm-auto-overlay[data-open="1"] { opacity: 1; }

.tri-stage.tri-stage .selector-panel,
.tri-stage.tri-stage .prompt-editor-panel,
.tri-stage.tri-stage .confirm-auto-panel {
  opacity: 0;
  transform: translateY(16px);
  transition: transform 0.42s cubic-bezier(0.22, 1.12, 0.36, 1), opacity 0.2s ease;
}
.tri-stage.tri-stage .selector-overlay[data-open="1"] .selector-panel,
.tri-stage.tri-stage .prompt-editor-overlay[data-open="1"] .prompt-editor-panel,
.tri-stage.tri-stage .confirm-auto-overlay[data-open="1"] .confirm-auto-panel {
  opacity: 1;
  transform: translateY(0);
}

/* 4 · .prompt-input is a contenteditable with a real caret in the app. Nothing
      is focused here, so the caret is drawn, in caret-color's colour. */
.tri-caret {
  display: inline-block;
  width: 1.5px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--accent-green);
  animation: tri-blink 1.06s steps(1) infinite;
}

@keyframes tri-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

/* Chat rows reveal their action buttons on hover; with no pointer they would
   never appear. The scene shows them when it hovers a row (.is-hover is
   generated from the app's own :hover rules — see build-anim-css.py). */

/* ── Focus rig ───────────────────────────────────────────────────────────────
   A scene that just plays leaves the viewer hunting for what changed. The rig
   dims the window, rings one element and names it, and — the part that does
   the work — animates between targets, so the eye is led rather than told.

   The dim is a 9999px spread on the ring's own box-shadow, clipped by a layer
   inset to the window. The label sits outside that clip so it can overhang the
   window edge without being cut.
   ────────────────────────────────────────────────────────────────────────── */

.tri-focus-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--radius-lg, 14px);
  pointer-events: none;
  z-index: 800;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.tri-focus-layer[data-on="1"] { opacity: 1; }

.tri-focus {
  position: absolute;
  left: var(--fx, 0);
  top: var(--fy, 0);
  width: var(--fw, 0);
  height: var(--fh, 0);
  border-radius: var(--fr, 8px);
  border: 1.5px solid rgba(52, 199, 89, 0.85);
  box-shadow:
    0 0 0 9999px rgba(6, 10, 8, 0.68),
    0 0 20px rgba(52, 199, 89, 0.25),
    inset 0 0 14px rgba(52, 199, 89, 0.1);
}

/* Only animate a ring that is moving from one target to the next. The first
   one appears in place; sliding it in from 0,0 reads as a glitch. */
.tri-focus[data-move="1"] {
  transition:
    left 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    top 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.tri-focus-label {
  position: absolute;
  left: var(--lx, 0);
  top: var(--ly, 0);
  z-index: 850;
  pointer-events: none;
  max-width: 92%;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(9, 14, 11, 0.97);
  border: 1px solid rgba(52, 199, 89, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  color: #7ee49b;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.005em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.32s ease;
}

.tri-focus-label[data-on="1"] { opacity: 1; }
.tri-focus-label[data-place="below"] { transform: translate(-50%, 0); }
.tri-focus-label[data-place="above"] { transform: translate(-50%, -100%); }

.tri-focus-label[data-move="1"] {
  transition:
    opacity 0.32s ease,
    left 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    top 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Video stage ─────────────────────────────────────────────────────────── */

.tri-film {
  margin: 0;
  min-height: 100vh;
  background: #0d1411;
  color: rgba(255, 255, 255, 0.9);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px;
  box-sizing: border-box;
}

/* Exactly 1920x1080. Record this element, nothing around it. */
.tri-frame {
  position: relative;
  width: 1920px;
  height: 1080px;
  flex: none;
  overflow: hidden;
  background:
    radial-gradient(1100px 620px at 50% 8%, rgba(52, 199, 89, 0.13), transparent 62%),
    radial-gradient(900px 700px at 88% 96%, rgba(52, 199, 89, 0.07), transparent 60%),
    #0b0f0d;
  transform-origin: top left;
  transform: scale(var(--fit, 1));
}

/* Window geometry at 1080p.
   1.65x puts the app's 13px body text at ~21px, which survives YouTube's
   compression and a phone screen. The viewport reserves the tallest frame
   (see engine.js), so nothing below it moves while the answer streams. */
.tri-frame .tri-viewport {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 205px;
  width: 1122px;   /* 680 * 1.65 */
  height: 690px;
  margin-left: -561px;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* When the Instruction card is up, the window steps aside for it. */
.tri-frame[data-card="1"] .tri-viewport { transform: translateX(-310px); }

.tri-frame .tri-stage .spotlight-inner {
  box-shadow: 0 60px 130px rgba(0, 0, 0, 0.6), 0 8px 22px rgba(0, 0, 0, 0.45);
}

/* Title card — a full frame, so it never fights the window for space. */
.tri-slug {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 200px;
  text-align: center;
  background: #0b0f0d;
  transition: opacity 0.55s ease;
}

.tri-slug[data-state="out"] { opacity: 0; pointer-events: none; }

.tri-slug-eyebrow {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #34c759;
  margin-bottom: 18px;
}

.tri-slug-title {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: #fff;
  margin: 0;
}

.tri-slug-sub {
  margin: 24px auto 0;
  max-width: 1080px;
  font-size: 26px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.6);
}

/* The Instruction's own text, shown beside the window. Presentation furniture —
   it is never dressed up as part of the app. */
.tri-card {
  position: absolute;
  z-index: 12;
  right: 85px;
  top: 268px;
  width: 520px;
  padding: 30px 32px 32px;
  border-radius: 18px;
  background: rgba(18, 24, 20, 0.94);
  border: 1px solid rgba(52, 199, 89, 0.28);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateX(34px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.tri-card[data-state="in"] { opacity: 1; transform: translateX(0); }

.tri-card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #34c759;
  margin-bottom: 20px;
}

.tri-card dt {
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.tri-card dd {
  margin: 0 0 20px;
  font-size: 18px;
  line-height: 1.62;
  color: rgba(255, 255, 255, 0.68);
}

.tri-card dd:last-child { margin-bottom: 0; }

.tri-lower {
  position: absolute;
  z-index: 12;
  left: 0;
  right: 0;
  bottom: 76px;
  padding: 0 160px;
  text-align: center;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.82);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.tri-lower[data-state="out"] { opacity: 0; transform: translateY(10px); }
.tri-lower b { color: #34c759; font-weight: 650; }

.tri-endcard {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: #0b0f0d;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.tri-endcard[data-state="in"] { opacity: 1; }
.tri-endcard img { width: 340px; height: auto; }
.tri-endcard p { margin: 0; font-size: 30px; color: rgba(255, 255, 255, 0.62); }
.tri-endcard .tri-endcard-url { font-size: 26px; color: #34c759; letter-spacing: 0.04em; }

/* ── Transport ───────────────────────────────────────────────────────────── */

.tri-transport {
  width: min(1400px, 100%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.tri-transport button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.tri-transport button:hover { background: rgba(52, 199, 89, 0.18); border-color: rgba(52, 199, 89, 0.5); }

.tri-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  min-width: 108px;
}

.tri-scrub { flex: 1; accent-color: #34c759; }

.tri-marks {
  width: min(1400px, 100%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tri-mark {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.tri-mark[data-on="1"] { border-color: #34c759; color: #34c759; background: rgba(52, 199, 89, 0.12); }

/* ── Docs: a small play/replay control under the figure ──────────────────── */

.tri-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.tri-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--slate-200, #e2e8f0);
  background: #fff;
  color: var(--slate-600, #475569);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tri-btn:hover {
  color: var(--brand-dark, #24753a);
  border-color: var(--brand-mid, hsl(136, 35%, 84%));
  background: var(--brand-light, hsl(136, 55%, 96%));
}

.tri-btn svg { display: block; }

/* ── Reduced motion ──────────────────────────────────────────────────────
   The scene stops on the frame that carries the point — the answer the
   Instruction produced — and the controls still allow a manual replay. */

@media (prefers-reduced-motion: reduce) {
  .tri-cursor,
  .tri-ripple { display: none; }
  .tri-caret { animation: none; }
  .tri-focus,
  .tri-focus-layer,
  .tri-focus-label,
  .tri-stage .selector-panel,
  .tri-stage .prompt-editor-panel,
  .tri-stage .confirm-auto-panel,
  .tri-stage .selector-overlay,
  .tri-stage .prompt-editor-overlay,
  .tri-stage .confirm-auto-overlay,
  .tri-slug,
  .tri-card,
  .tri-lower,
  .tri-legend { transition: none; }
}

@media (max-width: 768px) {
  .tri-figure { padding: 14px 10px; border-radius: 10px; }
}
