/* ═══════════════════════════════════════════════════════════════════
   EMMA Briefing Slide Design System (bf-*)
   Single source for portal player, studio preview iframe, and app.
   Self-contained: defines its own variables (iframes don't inherit
   globals.css), values mirror the EMMA brand palette.
   ═══════════════════════════════════════════════════════════════════ */

.bf-scope {
  --bf-bg: oklch(0.995 0.002 60);
  --bf-fg: oklch(0.175 0.015 30);
  --bf-muted-fg: oklch(0.48 0.01 50);
  --bf-panel: oklch(0.945 0.008 60);
  --bf-border: oklch(0.905 0.008 55);
  --bf-primary: oklch(0.635 0.175 35);
  --bf-primary-fg: oklch(0.995 0.002 60);
  --bf-success: oklch(0.62 0.17 155);
  --bf-destructive: oklch(0.577 0.245 27.325);
  --bf-dark: oklch(0.16 0.05 12);
  --bf-dark-soft: oklch(0.22 0.06 14);
  --bf-dark-fg: oklch(0.93 0.01 55);
  --bf-font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --bf-font-serif: "Instrument Serif", Georgia, serif;
  --bf-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --bf-radius: 1rem;
  --bf-radius-sm: 0.625rem;
  --bf-gap: 1.15rem;
}

.bf-scope *,
.bf-scope *::before,
.bf-scope *::after {
  box-sizing: border-box;
}

/* ── Slide root ── */

.bf-slide {
  display: flex;
  flex-direction: column;
  gap: var(--bf-gap);
  width: 100%;
  min-height: 100%;
  padding: clamp(1.5rem, 5vw, 3.25rem);
  background: var(--bf-bg);
  color: var(--bf-fg);
  font-family: var(--bf-font-sans);
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.bf-slide h1,
.bf-slide h2,
.bf-slide h3,
.bf-slide h4,
.bf-slide p,
.bf-slide ul,
.bf-slide ol,
.bf-slide figure,
.bf-slide blockquote,
.bf-slide hr {
  margin: 0;
}

.bf-slide ul,
.bf-slide ol {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bf-slide img,
.bf-slide video {
  max-width: 100%;
  display: block;
}

.bf-slide hr {
  border: 0;
  border-top: 1px solid var(--bf-border);
  width: 100%;
}

.bf-theme-dark {
  --bf-bg: var(--bf-dark);
  --bf-fg: var(--bf-dark-fg);
  --bf-muted-fg: oklch(0.72 0.02 45);
  --bf-panel: var(--bf-dark-soft);
  --bf-border: oklch(0.3 0.05 16);
  --bf-primary: oklch(0.685 0.18 38);
}

/* ── Typography ── */

.bf-eyebrow {
  font-family: var(--bf-font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--bf-primary);
}

.bf-display-xl {
  font-family: var(--bf-font-serif);
  font-weight: 400;
  font-size: clamp(2.35rem, 8vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
}

.bf-display-lg {
  font-family: var(--bf-font-serif);
  font-weight: 400;
  font-size: clamp(1.85rem, 6vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.bf-display-md {
  font-family: var(--bf-font-serif);
  font-weight: 400;
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  line-height: 1.15;
}

.bf-lead {
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  line-height: 1.6;
  color: var(--bf-muted-fg);
}

.bf-body {
  font-size: 1rem;
  line-height: 1.7;
}

.bf-caption {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--bf-muted-fg);
}

.bf-muted {
  color: var(--bf-muted-fg);
}

.bf-mono {
  font-family: var(--bf-font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.bf-accent {
  color: var(--bf-primary);
}

.bf-quote {
  font-family: var(--bf-font-serif);
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  line-height: 1.35;
  padding-left: 1.25rem;
  border-left: 3px solid var(--bf-primary);
}

.bf-stat-number {
  font-family: var(--bf-font-serif);
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  line-height: 1;
  color: var(--bf-primary);
}

.bf-stat-label {
  font-family: var(--bf-font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bf-muted-fg);
}

.bf-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--bf-border);
  border-radius: 999px;
  font-family: var(--bf-font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bf-muted-fg);
  background: var(--bf-bg);
  width: fit-content;
}

/* ── Lists ── */

.bf-list {
  list-style: none;
  padding-left: 0;
}

.bf-list > li {
  position: relative;
  padding-left: 1.3rem;
}

.bf-list > li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--bf-primary);
}

.bf-numbered-list {
  list-style: none;
  padding-left: 0;
  counter-reset: bf-counter;
}

.bf-numbered-list > li {
  position: relative;
  padding-left: 2.2rem;
  counter-increment: bf-counter;
}

.bf-numbered-list > li::before {
  content: "0" counter(bf-counter);
  position: absolute;
  left: 0;
  top: 0.3em;
  font-family: var(--bf-font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--bf-primary);
}

.bf-check-list,
.bf-x-list {
  list-style: none;
  padding-left: 0;
}

.bf-check-list > li,
.bf-x-list > li {
  position: relative;
  padding-left: 1.6rem;
}

.bf-check-list > li::before {
  content: "✓";
  position: absolute;
  left: 0;
  font-weight: 600;
  color: var(--bf-success);
}

.bf-x-list > li::before {
  content: "✕";
  position: absolute;
  left: 0;
  font-weight: 600;
  color: var(--bf-destructive);
}

/* ── Layout ── */

.bf-stack {
  display: flex;
  flex-direction: column;
  gap: var(--bf-gap);
}

.bf-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.bf-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.bf-center {
  align-items: center;
  text-align: center;
  justify-content: center;
}

.bf-grid-2,
.bf-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--bf-gap);
}

@media (min-width: 600px) {
  .bf-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bf-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.bf-gap-1 { gap: 0.5rem; }
.bf-gap-2 { gap: 1rem; }
.bf-gap-3 { gap: 1.6rem; }
.bf-gap-4 { gap: 2.4rem; }

.bf-pad-1 { padding: 0.6rem; }
.bf-pad-2 { padding: 1rem; }
.bf-pad-3 { padding: 1.5rem; }
.bf-pad-4 { padding: 2.25rem; }

.bf-card {
  background: var(--bf-bg);
  border: 1px solid var(--bf-border);
  border-radius: var(--bf-radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bf-panel {
  background: var(--bf-panel);
  border-radius: var(--bf-radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bf-full {
  width: 100%;
}

/* ── Media ── */

.bf-figure {
  position: relative;
  overflow: hidden;
  border-radius: var(--bf-radius);
  border: 1px solid var(--bf-border);
  background: var(--bf-panel);
  display: flex;
  flex-direction: column;
}

.bf-aspect-916 {
  aspect-ratio: 9 / 16;
  max-height: min(60dvh, 540px);
  width: auto;
  align-self: center;
}

.bf-aspect-169 {
  aspect-ratio: 16 / 9;
  width: 100%;
}

.bf-aspect-11 {
  aspect-ratio: 1 / 1;
  width: 100%;
}

.bf-img,
.bf-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bf-figcaption {
  position: absolute;
  inset-inline: 0.6rem;
  bottom: 0.6rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--bf-radius-sm);
  background: color-mix(in oklab, var(--bf-bg) 88%, transparent);
  backdrop-filter: blur(6px);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--bf-fg);
}

.bf-media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.bf-media-grid .bf-aspect-916 {
  max-height: none;
  width: 100%;
  align-self: stretch;
}

/* ── CTA ── */

.bf-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.7rem;
  border: 0;
  border-radius: 999px;
  background: var(--bf-primary);
  color: var(--bf-primary-fg);
  font-family: var(--bf-font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: fit-content;
  transition: filter 160ms ease;
}

.bf-cta:hover {
  filter: brightness(1.06);
}

/* ── Studio preview: resolved {{variable}} markers ──
   Display-only spans injected by the studio; the portal never renders
   these. Subtle dotted underline signals "personalized value". ── */

.bf-scope [data-bf-token] {
  border-bottom: 1px dotted color-mix(in oklab, var(--bf-primary) 65%, transparent);
  cursor: default;
}

/* ── Studio streaming preview: new elements ease in ──
   The streaming host applies updates via DOM diffing, so only freshly
   created nodes run this entry animation — existing content stays put. ── */

@keyframes bf-stream-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bf-stream-host :where(h1, h2, h3, h4, p, span, li, blockquote, figure, figcaption, img, video, button, div, ol, ul, hr) {
  animation: bf-stream-in 280ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

@media (prefers-reduced-motion: reduce) {
  .bf-stream-host :where(h1, h2, h3, h4, p, span, li, blockquote, figure, figcaption, img, video, button, div, ol, ul, hr) {
    animation: none;
  }
}

/* ── Build-up animations (interpreted by the portal player) ──
   Hidden initial state only inside .bf-player so the studio
   preview shows everything without player logic. ── */

.bf-player [data-animate] {
  opacity: 0;
  transition:
    opacity 520ms ease,
    transform 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.bf-player [data-animate="fade-up"] {
  transform: translateY(18px);
}

.bf-player [data-animate="scale-in"] {
  transform: scale(0.95);
}

.bf-player [data-animate].bf-in {
  opacity: 1;
  transform: none;
}

.bf-player [data-animate-delay="1"] { transition-delay: 80ms; }
.bf-player [data-animate-delay="2"] { transition-delay: 160ms; }
.bf-player [data-animate-delay="3"] { transition-delay: 240ms; }
.bf-player [data-animate-delay="4"] { transition-delay: 320ms; }
.bf-player [data-animate-delay="5"] { transition-delay: 400ms; }
.bf-player [data-animate-delay="6"] { transition-delay: 480ms; }

@media (prefers-reduced-motion: reduce) {
  .bf-player [data-animate] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
