/*
  Motion Primitives — shared shell
  Canvas, stroke recipes, snap-clip player, chrome.
  Each primitive HTML loads this + adds its own .primitive-* rules.
*/

/* ---------- Larken (real brand serif, used for italic emphasis) ----------
   Self-hosted from ./fonts/. Path is sibling-relative so it works whether
   _shell.css is loaded from /motion-primitives/ standalone or from
   /brand-hub/motion-primitives/. */
:root {
  --pepper: #211F20;
  --buttermilk: #FAFAF3;
  --emerald: #1E4C48;
  --honey: #FAC53A;
  --carnelian: #B74A00;
  --stroke: 3.5px;     /* default dark-mode stroke (was 5px) */
  --fit: 1;
}

/* Light ICC mode: no glow, hairline strokes */
body[data-bg="light"] {
  --stroke: 2.25px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ---------- Canvas vignettes ---------- */
body[data-bg="dark"] {
  background: radial-gradient(ellipse 80% 70% at 50% 55%, #0c2219 0%, #071511 60%, #030605 100%);
}
body[data-bg="light"] { background: var(--buttermilk); }

/* ---------- Stroke recipes ---------- */
/* Default "auto": white on dark, pepper on light */
body[data-bg="dark"][data-accent="auto"] {
  --stroke-color: #FAFAF3;
  --glow-1: rgba(250,250,243,0.32);
  --glow-2: rgba(250,250,243,0.18);
}
body[data-bg="light"][data-accent="auto"] {
  --stroke-color: #211F20;
  --glow-1: rgba(33,31,32,0.18);
  --glow-2: rgba(33,31,32,0.10);
}
body[data-accent="emerald"] {
  --stroke-color: #1E4C48;
  --glow-1: rgba(30,76,72,0.40);
  --glow-2: rgba(30,76,72,0.22);
}
body[data-accent="honey"] {
  --stroke-color: #FAC53A;
  --glow-1: rgba(250,197,58,0.50);
  --glow-2: rgba(250,197,58,0.28);
}
body[data-accent="carnelian"] {
  --stroke-color: #B74A00;
  --glow-1: rgba(183,74,0,0.48);
  --glow-2: rgba(183,74,0,0.26);
}

/* ---------- Clip stack ----------
   Clips are stacked in the SAME position and cross-faded in place — the reel
   plays as one continuous motion graphic. (Previously a horizontal filmstrip
   that slid sideways between clips.) */
.clip-track {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.clip {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity;
}
.clip.is-active {
  opacity: 1;
  pointer-events: auto;
}
/* Recording / reduced-motion: no cross-fade, hard switch. */
body.recording .clip { transition: none; }
@media (prefers-reduced-motion: reduce) { .clip { transition: none; } }

.stage {
  position: absolute;
  top: 50%; left: 50%;
  width: 3840px;
  height: 2160px;
  transform: translate(-50%, -50%) scale(var(--fit, 1));
  transform-origin: center center;
}

.stage svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ---------- Shared shape glow ---------- */
/* Apply this class to any group that should carry the brand glow.
   Light ICC mode never glows — clean Buttermilk + hairline only. */
.gx-glow {
  filter:
    drop-shadow(0 0 6px var(--glow-1))
    drop-shadow(0 0 14px var(--glow-2));
}
body[data-bg="light"] .gx-glow {
  filter: none;
}

/* ---------- Frame caption (shared across primitives) ----------
   Any primitive can opt into a top/bottom caption via URL params:
     ?caption=Plant_the_perimeter      (use _ for spaces)
     ?capPos=top|bottom                (default bottom)
     ?capStyle=eyebrow|headline        (default eyebrow)
     ?capEm=N                          (0-based word index for Larken italic emphasis)
   The shell renders a single fixed overlay so it floats over every clip
   like a subtitle — no per-primitive changes required. */
.frame-caption {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 50;
  display: block;
  pointer-events: none;
  padding: 0 6vw;
  text-align: center;
  font-family: 'Inter', system-ui, sans-serif;
  font-feature-settings: "ss01", "cv11";
  color: var(--cap-text-color);
  white-space: normal;
}
.frame-caption[data-cap-pos="top"]    { top: 8vh; }
.frame-caption[data-cap-pos="bottom"] { bottom: 10vh; }

.frame-caption[data-cap-style="eyebrow"] {
  font-weight: 550;
  font-size: 24px;
  letter-spacing: 0.02em;
  /* Tightened to match Larken italic's natural rhythm — was 0.18em (too loose). */
  /* No automatic uppercase — case is preserved as the editor types it. */
  opacity: 0.7;
}
.frame-caption[data-cap-style="headline"] {
  font-weight: 550;
  font-size: 56px;
  letter-spacing: -0.008em;
  line-height: 1.08;
  opacity: 0.92;
}

body[data-bg="dark"]  .frame-caption { --cap-text-color: #FAFAF3; }
body[data-bg="light"] .frame-caption { --cap-text-color: #211F20; }

.frame-caption .em-word {
  font-family: 'Larken', 'Fraunces', 'Georgia', serif;
  font-style: italic;
  /* Larken bold-italic is the brand signature — matches the Canva treatment. */
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--cap-em-color);
}
body[data-bg="dark"]  .frame-caption .em-word { --cap-em-color: #FAC53A; text-shadow: 0 0 22px rgba(250, 197, 58, 0.22); }
body[data-bg="light"] .frame-caption .em-word { --cap-em-color: #B74A00; text-shadow: none; }

/* Hide caption while recording-mode chrome is hidden? No — caption is part of
   the deliverable, so it stays. Recording mode hides only chrome. */
body.recording .frame-caption { /* keep visible */ }

/* ---------- Reveal states ---------- */
.gx-pre {
  opacity: 0;
  transform: scale(0.88);
  transform-box: fill-box;
  transform-origin: center center;
}
.gx-in {
  opacity: 1;
  transform: scale(1);
  transition:
    opacity 1100ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 1100ms cubic-bezier(0.22, 1, 0.36, 1);
}
.gx-persistent {
  opacity: 1;
  transform: scale(1);
  transform-box: fill-box;
  transform-origin: center center;
}
.gx-future {
  opacity: 0;
  transform: scale(0.88);
  transform-box: fill-box;
  transform-origin: center center;
}

@media (prefers-reduced-motion: reduce) {
  .gx-in { transition: none; }
  .clip-track { transition: none; }
}

/* ---------- Chrome (hidden in record mode) ---------- */
.chrome { transition: opacity 200ms ease; }
body.recording .chrome { opacity: 0; pointer-events: none; }

.topbar {
  position: fixed; top: 24px; left: 24px;
  display: flex; gap: 12px; align-items: center;
  padding: 10px 16px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  color: #FAFAF3;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  z-index: 100;
  backdrop-filter: blur(10px);
}
body[data-bg="light"] .topbar {
  background: rgba(33,31,32,0.85);
}
.topbar .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #FAC53A;
}

.nav-pill {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 8px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  z-index: 100;
  backdrop-filter: blur(10px);
}
body[data-bg="light"] .nav-pill {
  background: rgba(33,31,32,0.85);
}
.nav-pill button {
  appearance: none;
  background: transparent;
  border: none;
  color: #FAFAF3;
  font-size: 18px;
  width: 36px; height: 36px;
  border-radius: 999px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.nav-pill button:hover { background: rgba(255,255,255,0.08); }
.nav-pill button#playBtn[data-playing="true"] {
  background: rgba(255,205,80,0.18);
  color: #FAC53A;
}
.nav-pill button#playBtn[data-playing="true"]:hover {
  background: rgba(255,205,80,0.28);
}
.nav-pill button#playBtn svg { display: block; }
.nav-pill .counter {
  color: #FAFAF3;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 0 12px;
  letter-spacing: 0.04em;
}

.scene-meta {
  position: fixed;
  bottom: 28px; right: 28px;
  color: rgba(250,250,243,0.55);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  z-index: 100;
}
body[data-bg="light"] .scene-meta { color: rgba(33,31,32,0.55); }
