/* ============================================================
   ALLOY CINEMATIC v2 — Act 3 SOP chapter embeds
   Owner: SA-5 (SOP Chapter Embeds)
   ------------------------------------------------------------
   Artisan glass cards on warm cream. Reuses the SOP page's
   visual language (sop.css) but scoped under .sop-embed so the
   classes never leak into / collide with the rest of the page.
   Tokens come from cinematic-v2.css :root (do NOT edit that file).
   Visibility rule (inherited): CSS defaults VISIBLE; motion only
   enhances. The mermaid SVGs are injected + animated by
   site/js/mermaid-draw.js.
   ============================================================ */

/* ---- Section copy card -------------------------------------- */
.sop-embed {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-glass);
  padding: clamp(1.4rem, 3.2vw, 2.4rem);
  box-shadow: 0 22px 60px color-mix(in srgb, var(--walnut) 10%, transparent);
  max-width: 60ch;
}

/* Fraunces narrator headline */
.sop-embed__narrator {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 3.2vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--fg);
  margin: 0.2rem 0 0.85rem;
  max-width: 20ch;
}
.sop-embed__narrator em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

/* Consulting-friendly lead paragraph */
.sop-embed__lead {
  font-size: clamp(1rem, 1.5vw, 1.12rem);
  line-height: 1.62;
  color: var(--muted);
  margin: 0 0 1.15rem;
  max-width: 52ch;
}

/* Abbreviated technical body */
.sop-embed__tech {
  font-size: 0.94rem;
  line-height: 1.66;
  color: var(--fg-alt);
  max-width: 58ch;
}
.sop-embed__tech p { margin: 0 0 0.75rem; }
.sop-embed__tech p:last-child { margin-bottom: 0; }
.sop-embed__tech strong { color: var(--walnut); font-weight: 600; }

/* Inline mono — mirrors sop.css .sop-mono, scoped */
.sop-embed .sop-mono,
.sop-embed code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: color-mix(in srgb, var(--walnut) 9%, transparent);
  padding: 0.1em 0.38em;
  border-radius: 4px;
  color: var(--walnut);
}

/* ---- Footer row: full-section link ------------------------- */
.sop-embed__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1.35rem;
}

.sop-embed__more {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding-bottom: 2px;
  transition: color 0.2s ease, gap 0.2s var(--spring), border-color 0.2s ease;
}
.sop-embed__more:hover {
  color: var(--accent-hover);
  gap: 0.65rem;
  border-color: var(--accent-hover);
}
.sop-embed__more .arrow { transition: transform 0.2s var(--spring); }
.sop-embed__more:hover .arrow { transform: translateX(3px); }

/* ---- Ground-truth investor expand (markup only here) -------
   Hidden by default via the [hidden] attribute. SA-7 wires the
   toggle/reveal behaviour. The [hidden] attribute selector beats
   the base rule on specificity, so display:none always wins
   while the attribute is present. */
.sop-embed__ground {
  display: grid;
  gap: 1rem;
  margin-top: 1.4rem;
  padding-top: 1.3rem;
  border-top: 1px dashed color-mix(in srgb, var(--walnut) 24%, transparent);
}
.sop-embed__ground[hidden] { display: none; }

.sop-embed__ground-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--walnut);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.sop-embed__ground-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-gold);
}

/* Tables inside ground-truth — mirrors sop.css .sop-table */
.sop-embed .sop-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 65%, white);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--walnut) 5%, transparent);
}
.sop-embed .sop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.sop-embed .sop-table th,
.sop-embed .sop-table td {
  padding: 0.62rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--fg-alt);
}
.sop-embed .sop-table th {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--walnut);
}
.sop-embed .sop-table tr:last-child td { border-bottom: none; }
.sop-embed .sop-table td .sop-mono { font-size: 0.8rem; }

/* Callout / ordered-layer block — mirrors sop.css .sop-callout */
.sop-embed .sop-callout {
  background: color-mix(in srgb, var(--bg) 60%, white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  font-size: 0.9rem;
  line-height: 1.56;
  color: var(--fg-soft, var(--fg-alt));
}
.sop-embed .sop-callout strong { color: var(--walnut); font-weight: 600; }
.sop-embed .sop-callout ol,
.sop-embed .sop-callout ul { margin: 0; padding-left: 1.2rem; }
.sop-embed .sop-callout li { margin-bottom: 0.35rem; }
.sop-embed .sop-callout li:last-child { margin-bottom: 0; }

/* ---- Mermaid diagram mount (SVG injected by mermaid-draw.js) */
.sop-embed__diagram {
  margin-top: 1.4rem;
  padding: clamp(1rem, 2.6vw, 1.5rem);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 44px color-mix(in srgb, var(--walnut) 7%, transparent);
  overflow-x: auto;
}
.sop-embed__diagram svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}
.sop-embed__diagram::before {
  content: attr(data-diagram-label);
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--walnut) 55%, transparent);
  margin-bottom: 0.9rem;
}

/* ---- Hand-authored mermaid SVG primitives ------------------ */
.md-shape {
  fill: color-mix(in srgb, var(--bg) 55%, white);
  stroke: color-mix(in srgb, var(--walnut) 42%, transparent);
  stroke-width: 1.4;
}
.md-shape--decision { fill: color-mix(in srgb, var(--accent) 14%, white); stroke: color-mix(in srgb, var(--accent) 55%, transparent); }
.md-shape--terminal { fill: color-mix(in srgb, var(--accent-gold) 12%, white); stroke: color-mix(in srgb, var(--accent-gold) 50%, transparent); }
.md-shape--muted   { fill: color-mix(in srgb, var(--surface) 70%, white); stroke: color-mix(in srgb, var(--walnut) 30%, transparent); }
.md-shape--actor   { fill: color-mix(in srgb, var(--walnut) 12%, white); stroke: color-mix(in srgb, var(--walnut) 45%, transparent); }

.md-node-text {
  font-family: var(--font-body);
  font-size: 13px;
  fill: var(--fg);
  text-anchor: middle;
  dominant-baseline: middle;
}
.md-node-text--sm { font-size: 11px; }

.md-edge {
  fill: none;
  stroke: color-mix(in srgb, var(--walnut) 48%, transparent);
  stroke-width: 1.6;
}
.md-edge--dashed { stroke-dasharray: 6 5; stroke: color-mix(in srgb, var(--walnut) 38%, transparent); }

.md-edge-label {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--walnut);
  text-anchor: middle;
  dominant-baseline: middle;
}
.md-edge-label-bg { fill: color-mix(in srgb, var(--bg) 88%, white); }

.md-lifeline {
  stroke: color-mix(in srgb, var(--walnut) 26%, transparent);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.md-loopbox {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 45%, transparent);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
}
.md-loop-label {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--accent);
}

/* Initial hidden state for animated bits is set inline by JS so a
   no-JS load simply shows nothing in the diagram mount (the rest of
   each section — narrator, lead, technical, link — stays fully
   visible). */

/* ---- Mobile ------------------------------------------------- */
@media (max-width: 768px) {
  .sop-embed { max-width: 100%; padding: 1.25rem 1.1rem; border-radius: var(--radius-md); }
  .sop-embed__lead,
  .sop-embed__tech { max-width: 100%; }
  .sop-embed__diagram { margin-left: -0.25rem; margin-right: -0.25rem; }
}

/* ---- Reduced motion: diagrams already render fully drawn via JS;
   nothing extra needed here, but guarantee no transitions linger. */
@media (prefers-reduced-motion: reduce) {
  .sop-embed__more,
  .sop-embed__more .arrow { transition: none; }
}
