/* motion.css — styles for motion canvas (Phase B) */

:root {
  --motion-bg: #1a1816;
}

body.motion-body {
  margin: 0;
  background: var(--motion-bg);
  font-family: 'Courier Prime', monospace;
  color: #FAF7F1;
  min-height: 100vh;
}

/* Top bar */
.motion-topbar {
  padding: 28px 40px 18px;
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.25);
}
.motion-topbar h1 {
  font-family: 'Courier Prime', monospace;
  font-size: 22px; font-weight: 700;
  letter-spacing: 0.04em; margin: 0;
  color: #FAF7F1;
}
.motion-topbar h1 span { color: #D46B3E; }
.motion-topbar .sub {
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}

/* Grid layout — 2x2 */
.motion-grid {
  padding: 32px 40px 80px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px 36px;
  max-width: 2000px;
  margin: 0 auto;
}

.motion-card {
  background: #0e0c0a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.motion-card .mc-header {
  padding: 14px 18px;
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.motion-card .mc-header .act {
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}
.motion-card .mc-header .title {
  font-size: 15px; color: #FAF7F1; letter-spacing: 0.03em;
}
.motion-card .mc-header .title b { color: #D46B3E; font-weight: 700; }
.motion-card .mc-header .runtime {
  font-size: 11px; color: rgba(255,255,255,0.4); letter-spacing: 0.14em;
}

/* Scene viewport: scaled 1920x1080.
   The engine renders a .motion-scene > .motion-stage tree, where
   .motion-stage is the fixed-size 1920x1080 surface that ScaledScene
   transforms via CSS. Both must NOT use absolute positioning here —
   ScaledScene wraps them in its own positioned container. */
.motion-scene {
  position: relative;
  width: 1920px;
  height: 1080px;
  background: #000;
  display: block;
}
.motion-stage {
  position: absolute;
  inset: 0;
}

/* Controls */
.motion-controls {
  padding: 10px 14px;
  display: flex; gap: 12px; align-items: center;
  background: #15120f;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-family: 'Courier Prime', monospace;
}
.mc-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: #FAF7F1;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit; font-size: 14px;
  min-width: 40px;
}
.mc-btn:hover { background: rgba(255,255,255,0.06); }
.mc-loop[data-on="true"] { border-color: #D46B3E; color: #D46B3E; }
.mc-scrub {
  flex: 1;
  accent-color: #D46B3E;
}
.mc-time { color: #D46B3E; font-size: 12px; min-width: 50px; text-align: right; letter-spacing: 0.06em; }
.mc-dur  { color: rgba(255,255,255,0.4); font-size: 12px; letter-spacing: 0.06em; }

/* ─── Caption pill on the stage ───────────────────────── */
.mt-caption {
  position: absolute;
  left: 50%; bottom: 140px;
  transform: translateX(-50%);
  background: rgba(20, 18, 15, 0.96);
  color: #FAF7F1;
  font-family: 'Courier Prime', monospace;
  font-size: 44px;
  letter-spacing: 0.01em;
  padding: 24px 44px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 10;
  text-align: left;
  box-shadow: 0 24px 80px -10px rgba(0,0,0,0.55);
}
.mt-caption--terminal {
  background: rgba(0,0,0,0.92);
  color: #00FF00;
  border: 1px solid rgba(0,255,0,0.4);
}

.tw-caret {
  background: currentColor;
}
.tw-caret--blink {
  animation: tw-blink 0.95s steps(2,end) infinite;
}
@keyframes tw-blink { 50% { opacity: 0; } }

/* Caption scene: dim everything inside .scene-bg while caption active */
.caption-scene {
  position: absolute; inset: 0;
}
.caption-scene .scene-bg {
  transition: opacity 360ms ease, filter 360ms ease;
  position: absolute; inset: 0;
}
.caption-scene.is-caption-active .scene-bg {
  opacity: 0.42;
}

/* Scene-content backgrounds (cream / terminal) */
.scene-cream-bg {
  background: #FEFCF8;
  position: absolute; inset: 0;
}
.scene-cream-bg::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(1400px 900px at 30% 20%, #FFFEFB 0%, transparent 60%),
    radial-gradient(1200px 800px at 80% 90%, #F5F0E8 0%, transparent 65%);
  pointer-events: none;
}
.scene-terminal-bg {
  background: #0A0A0A;
  position: absolute; inset: 0;
}
.scene-terminal-bg::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,0.18) 3px, rgba(0,0,0,0.18) 3px);
  pointer-events: none;
}
.scene-terminal-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(80% 100% at 50% 50%, transparent 60%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}


/* ════════════════════════════════════════════════════════════
 * Master timeline (stitched cut)
 * ════════════════════════════════════════════════════════════ */
body.master-body {
  margin: 0;
  background: #0E0D0C;
  color: #FAF7F1;
  font-family: 'Courier Prime', monospace;
  min-height: 100vh;
  overflow: hidden;
}
.mt-shell {
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
}
.mt-stage {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
}
.mt-stage-inner {
  position: absolute; inset: 0;
}

.mt-controls {
  background: linear-gradient(180deg, #1a1816 0%, #0E0D0C 100%);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 14px 28px 16px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-rows: auto auto;
  gap: 8px 18px;
  align-items: center;
}
.mt-pp {
  grid-row: 1; grid-column: 1;
  width: 44px; height: 44px;
  border-radius: 999px;
  background: var(--orange, #D46B3E);
  color: #FFF;
  border: none;
  font-size: 16px;
  font-family: 'Courier Prime', monospace;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.05em;
  transition: transform 0.1s ease;
}
.mt-pp:hover { transform: scale(1.05); }
.mt-pp:active { transform: scale(0.95); }

.mt-time {
  grid-row: 1; grid-column: 2;
  font-family: 'Courier Prime', monospace;
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.06em;
  font-weight: 700;
  white-space: nowrap;
  min-width: 90px;
}
.mt-time span { color: rgba(255,255,255,0.4); margin: 0 4px; }

.mt-audio {
  font-size: 16px;
  opacity: 0.55;
}
.mt-audio:hover { opacity: 1; }
.mt-audio.on { opacity: 1; color: var(--orange, #D46B3E); }
.mt-vo {
  font-size: 14px;
  opacity: 0.55;
}
.mt-vo:hover { opacity: 1; }
.mt-vo.on { opacity: 1; color: var(--orange, #D46B3E); }

.mt-track-wrap {
  grid-row: 1; grid-column: 3;
  position: relative;
  height: 44px;
}
.mt-tick-row {
  position: absolute; top: 0; left: 0; right: 0; height: 10px;
  pointer-events: none;
}
.mt-tick {
  position: absolute; top: 0;
  width: 1px; height: 8px;
  background: rgba(255,255,255,0.35);
}
.mt-tick-label {
  position: absolute; top: -2px;
  transform: translateX(-50%);
  font-family: 'Courier Prime', monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}
.mt-chapter-track {
  position: absolute; top: 22px; left: 0; right: 0; height: 8px;
  display: flex; gap: 2px;
  cursor: pointer;
}
.mt-seg {
  height: 100%;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  transition: background 0.15s ease;
}
.mt-seg:hover { background: rgba(255,255,255,0.16); }
.mt-seg.active { background: rgba(212,107,62,0.18); }
.mt-seg-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--orange, #D46B3E);
  transition: width 0.05s linear;
}
.mt-range {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.mt-chapters {
  grid-row: 2; grid-column: 1 / -1;
  display: flex; gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.mt-chapter {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.55);
  padding: 6px 12px;
  font-family: 'Courier Prime', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 3px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.mt-chapter:hover {
  border-color: rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.85);
}
.mt-chapter.active {
  border-color: var(--orange, #D46B3E);
  color: var(--orange, #D46B3E);
  background: rgba(212,107,62,0.08);
}
.mt-chapter-num {
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  font-size: 10px;
}
.mt-chapter.active .mt-chapter-num {
  color: var(--orange, #D46B3E);
}

/* Top bar over master */
.mt-topbar {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 50;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 100%);
  pointer-events: none;
  font-family: 'Courier Prime', monospace;
}
.mt-topbar .title {
  font-size: 14px; color: rgba(255,255,255,0.9);
  font-weight: 700; letter-spacing: 0.06em;
  pointer-events: auto;
}
.mt-topbar .title span { color: var(--orange, #D46B3E); }
.mt-topbar .nav {
  display: flex; gap: 8px;
  pointer-events: auto;
}
.mt-topbar .nav a {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 3px;
  transition: all 0.12s ease;
}
.mt-topbar .nav a:hover {
  color: rgba(255,255,255,0.95);
  border-color: rgba(255,255,255,0.35);
}
.mt-topbar .nav a.current {
  color: var(--orange, #D46B3E);
  border-color: var(--orange, #D46B3E);
  background: rgba(212,107,62,0.08);
}
