/* Engram Hero Flow Animation
 * ============================
 * Isolated hero visualization — cognitive-substrate flow.
 * All selectors scoped under .hero-flow to prevent leaks into landing CSS.
 * Uses landing-page design tokens from :root in engram-landing.css:
 * --teal-bright, --ink, --ink-1, --ink-2, --line, --line-strong,
 * --text, --text-dim, --text-faint, --font-display, --font-mono, --radius.
 * Adds tokens local to hero-flow only where missing.
 */

.hero-flow {
  --hf-teal: #04918E;
  --hf-teal-bright: #0BB4B0;
  --hf-teal-glow: rgba(11, 180, 176, 0.55);
  --hf-teal-soft: rgba(11, 180, 176, 0.12);
  --hf-navy: #1F3864;
  --hf-orange: #E87D00;
  --hf-orange-glow: rgba(232, 125, 0, 0.55);
  --hf-ink: #05070C;
  --hf-ink-1: #0A0E1A;
  --hf-ink-2: #11162A;
  --hf-line: rgba(255,255,255,0.06);
  --hf-line-strong: rgba(255,255,255,0.14);
  --hf-text: #EDEFF5;
  --hf-text-dim: #8A92A6;
  --hf-text-faint: #5A6278;

  margin: 88px auto 0;
  max-width: 1200px;
  width: 100%;
  position: relative;
  container-type: inline-size;
}

/* ==========================================================
   STAGE
   ========================================================== */
.hero-flow .hf-stage {
  position: relative;
  height: 620px;
  /* Transparent stage — landing hero-bg gradient shows through; no double-gradient noise */
  background: transparent;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.04);
  overflow: hidden;
}
.hero-flow .hf-canvas, .hero-flow .hf-tree-svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.hero-flow .hf-canvas { z-index: 3; pointer-events: none; }
.hero-flow .hf-tree-svg { z-index: 1; pointer-events: none; }

/* ==========================================================
   TOP ROW — PROMPT ↔ RESULT
   ========================================================== */
.hero-flow .hf-top-row {
  position: absolute;
  left: 20px; right: 20px;
  top: 18px;
  height: 72px;
  display: grid;
  grid-template-columns: 1.55fr 40px 1fr;
  z-index: 5;
}
.hero-flow .hf-bar {
  height: 100%;
  /* Match landing card aesthetic — near-transparent, subtle border */
  background: rgba(10, 14, 26, 0.35);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  display: flex;
  align-items: center;
  padding: 8px 14px;
  gap: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
  transition: box-shadow .35s ease, border-color .35s ease, background .35s ease;
  min-width: 0;
}
.hero-flow .hf-bar.armed   {
  border-color: rgba(11,180,176,0.45);
  box-shadow: 0 2px 20px rgba(11,180,176,0.18);
  background: rgba(11,180,176,0.05);
}
.hero-flow .hf-bar.blocked {
  border-color: rgba(232,125,0,0.45);
  box-shadow: 0 2px 20px rgba(232,125,0,0.18);
  background: rgba(232,125,0,0.05);
}

.hero-flow .hf-prompt-user {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
  padding: 5px 12px 5px 5px;
  background: rgba(11,180,176,0.10);
  border: 1px solid rgba(11,180,176,0.30);
  border-radius: 999px;
  max-width: 300px;
}
.hero-flow .hf-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #0BB4B0, #04918E);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 10px; font-weight: 700;
  color: #05070C; letter-spacing: 0.03em;
  flex-shrink: 0;
}
.hero-flow .hf-prompt-user-meta { display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; }
.hero-flow .hf-prompt-user-name { font-size: 12px; font-weight: 700; color: var(--hf-text); letter-spacing: -0.005em; white-space: nowrap; }
.hero-flow .hf-prompt-user-path { font-family: var(--font-mono, "SF Mono", monospace); font-size: 9px; color: var(--hf-text-faint); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-flow .hf-prompt-user-path .l { color: var(--hf-teal-bright); font-weight: 700; }

.hero-flow .hf-prompt-input {
  flex: 1;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 13px; color: var(--hf-text);
  letter-spacing: 0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.hero-flow .hf-caret {
  display: inline-block; width: 2px; height: 14px;
  background: var(--hf-teal-bright); vertical-align: -2px; margin-left: 1px;
  animation: hf-caret 1s steps(2) infinite;
}
@keyframes hf-caret { 50% { opacity: 0; } }

.hero-flow .hf-flow-indicator {
  display: flex; align-items: center; justify-content: center;
  color: var(--hf-text-faint);
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 22px; font-weight: 300;
  transition: color .35s ease;
}
.hero-flow .hf-flow-indicator.active  { color: var(--hf-teal-bright); text-shadow: 0 0 8px var(--hf-teal-glow); }
.hero-flow .hf-flow-indicator.blocked { color: var(--hf-orange);      text-shadow: 0 0 8px var(--hf-orange-glow); }

.hero-flow .hf-result-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(11,180,176,0.12);
  border: 1px solid rgba(11,180,176,0.30);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; position: relative;
  transition: all .35s ease; overflow: visible;
}
.hero-flow .hf-result-icon svg.hf-mini-substrate { width: 32px; height: 32px; overflow: visible; }
.hero-flow .hf-mini-outer, .hero-flow .hf-mini-mid, .hero-flow .hf-mini-inner {
  transform-origin: center; transform-box: fill-box;
}
.hero-flow .hf-mini-outer { animation: hf-spin 10s linear infinite; }
.hero-flow .hf-mini-mid   { animation: hf-spin 6s  linear infinite reverse; }
.hero-flow .hf-mini-inner { animation: hf-spin 4s  linear infinite; }
.hero-flow .hf-result-icon.processing .hf-mini-outer { animation-duration: 4s; }
.hero-flow .hf-result-icon.processing .hf-mini-mid   { animation-duration: 2.5s; }
.hero-flow .hf-result-icon.processing .hf-mini-inner { animation-duration: 1.6s; }
@keyframes hf-spin { to { transform: rotate(360deg); } }
.hero-flow .hf-mini-essence {
  fill: var(--hf-teal-bright);
  filter: drop-shadow(0 0 3px var(--hf-teal-glow));
  animation: hf-essence 2s ease-in-out infinite;
  transform-origin: center; transform-box: fill-box;
}
.hero-flow .hf-result-icon.processing .hf-mini-essence { animation-duration: 1s; }
@keyframes hf-essence {
  0%, 100% { r: 2;   opacity: 0.85; }
  50%      { r: 2.6; opacity: 1; }
}
.hero-flow .hf-bar.blocked .hf-result-icon { background: rgba(232,125,0,0.14); border-color: rgba(232,125,0,0.30); }
.hero-flow .hf-bar.blocked .hf-result-icon .hf-mini-outer circle,
.hero-flow .hf-bar.blocked .hf-result-icon .hf-mini-mid circle,
.hero-flow .hf-bar.blocked .hf-result-icon .hf-mini-inner circle { stroke: rgba(232,125,0,0.7); }
.hero-flow .hf-bar.blocked .hf-result-icon .hf-mini-essence { fill: var(--hf-orange); filter: drop-shadow(0 0 3px var(--hf-orange-glow)); }

.hero-flow .hf-result-body {
  flex: 1; position: relative;
  display: grid; grid-template-areas: "stack";
  align-items: center; overflow: hidden;
  min-height: 44px;
}
.hero-flow .hf-result-empty {
  grid-area: stack;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 12px; color: var(--hf-text-faint);
  letter-spacing: 0.02em; font-style: italic;
  transition: opacity .3s ease;
  align-self: center;
}
.hero-flow .hf-result-empty.hidden { opacity: 0; }
.hero-flow .hf-result-populated {
  grid-area: stack;
  display: flex; flex-direction: column; gap: 3px;
  opacity: 0; transform: translateY(4px);
  transition: opacity .5s ease, transform .5s ease;
  align-self: center; justify-self: start;
  width: 100%;
}
.hero-flow .hf-result-populated.active { opacity: 1; transform: translateY(0); }
.hero-flow .hf-result-topline { display: flex; align-items: center; gap: 8px; }
.hero-flow .hf-result-tag {
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 10px; padding: 2px 7px;
  background: rgba(11,180,176,0.16); color: var(--hf-teal-bright);
  border-radius: 4px; font-weight: 700; letter-spacing: 0.08em;
  flex-shrink: 0;
}
.hero-flow .hf-bar.blocked .hf-result-tag { color: var(--hf-orange); background: rgba(232,125,0,0.16); }
.hero-flow .hf-result-title  { font-size: 13px; font-weight: 700; color: var(--hf-text); letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-flow .hf-result-scope  { font-family: var(--font-mono, "SF Mono", monospace); font-size: 10px; color: var(--hf-text-faint); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hero-flow .hf-thinking-dot {
  display: inline-block; width: 4px; height: 4px;
  border-radius: 50%; background: var(--hf-text-faint);
  margin: 0 2px;
  animation: hf-think 1.4s ease-in-out infinite;
}
.hero-flow .hf-thinking-dot:nth-child(2) { animation-delay: .2s; }
.hero-flow .hf-thinking-dot:nth-child(3) { animation-delay: .4s; }
@keyframes hf-think {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.4); background: var(--hf-teal-bright); }
}

/* ==========================================================
   SOURCES COLUMN
   ========================================================== */
.hero-flow .hf-sources-wrap {
  position: absolute; left: 24px; top: 128px;
  width: 190px; height: 440px;
  z-index: 3; pointer-events: none;
}
.hero-flow .hf-sources-label {
  position: absolute; top: 0; left: 0;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--hf-text-faint); font-weight: 600;
}
.hero-flow .hf-src-node {
  position: absolute; left: 0;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 9px;
  background: rgba(17,22,42,0.80);
  border: 1px solid var(--hf-line-strong);
  border-radius: 6px;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 10.5px; color: var(--hf-text-dim);
  backdrop-filter: blur(4px);
  transition: all .35s ease;
  white-space: nowrap; opacity: 0.30;
  max-width: 200px;
}
.hero-flow .hf-src-node.active {
  color: var(--hf-text);
  border-color: var(--hf-teal-bright);
  background: rgba(11,180,176,0.14);
  box-shadow: 0 0 10px rgba(11,180,176,0.20);
  opacity: 1;
}
.hero-flow .hf-src-node.blocked {
  color: var(--hf-orange);
  border-color: var(--hf-orange);
  background: rgba(232,125,0,0.14);
  box-shadow: 0 0 10px rgba(232,125,0,0.24);
  opacity: 1;
}
.hero-flow .hf-src-node .hf-src-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 3px currentColor; }
.hero-flow .hf-src-node .hf-src-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.hero-flow .hf-src-node .hf-src-perm {
  font-size: 8.5px; padding: 1px 4px;
  background: rgba(11,180,176,0.20); color: var(--hf-teal-bright);
  border-radius: 3px; letter-spacing: 0.06em; font-weight: 700;
}
.hero-flow .hf-src-node.blocked .hf-src-perm { background: rgba(232,125,0,0.22); color: var(--hf-orange); }

/* ==========================================================
   GATES
   ========================================================== */
.hero-flow .hf-gate { position: absolute; width: 44px; height: 44px; z-index: 4; pointer-events: none; }
.hero-flow .hf-gate-icon {
  position: absolute; inset: 0;
  border: 1.5px solid var(--hf-line-strong);
  border-radius: 10px;
  background: rgba(10,14,26,0.90);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.10em; color: var(--hf-text-faint);
  text-transform: uppercase;
  transition: all .3s ease;
  backdrop-filter: blur(4px);
}
.hero-flow .hf-gate-icon.pass  { border-color: var(--hf-teal-bright); color: var(--hf-teal-bright); box-shadow: 0 0 12px var(--hf-teal-glow); background: rgba(11,180,176,0.18); }
.hero-flow .hf-gate-icon.block { border-color: var(--hf-orange);      color: var(--hf-orange);      box-shadow: 0 0 12px var(--hf-orange-glow); background: rgba(232,125,0,0.18); }
.hero-flow .hf-gate-caption {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 4px);
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 8.5px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--hf-text-faint); white-space: nowrap;
}
.hero-flow .hf-gate-access { left: 254px; top: 328px; }
.hero-flow .hf-gate-router { left: 554px; top: 328px; }

/* ==========================================================
   ENGRAM BRAIN
   ========================================================== */
.hero-flow .hf-brain {
  position: absolute;
  left: 332px; top: 254px;
  width: 172px; height: 172px;
  z-index: 2; pointer-events: none;
}
.hero-flow .hf-brain svg { width: 100%; height: 100%; overflow: visible; }
.hero-flow .hf-brain-glow {
  position: absolute; inset: -26px;
  background: radial-gradient(circle, rgba(11,180,176,0.35) 0%, rgba(11,180,176,0.10) 35%, transparent 65%);
  border-radius: 50%;
  animation: hf-breathe 4s ease-in-out infinite;
  z-index: 1;
}
@keyframes hf-breathe { 0%,100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.08); opacity: 1; } }
.hero-flow .hf-ring-outer, .hero-flow .hf-ring-mid, .hero-flow .hf-ring-inner {
  transform-origin: center; transform-box: fill-box;
}
.hero-flow .hf-ring-outer { animation: hf-spin 42s linear infinite; }
.hero-flow .hf-ring-mid   { animation: hf-spin 26s linear infinite reverse; }
.hero-flow .hf-ring-inner { animation: hf-spin 16s linear infinite; }
.hero-flow .hf-orb-dot { fill: var(--hf-teal-bright); filter: drop-shadow(0 0 3px var(--hf-teal-glow)); }
.hero-flow .hf-essence {
  fill: var(--hf-teal-bright);
  filter: drop-shadow(0 0 8px var(--hf-teal-glow));
  animation: hf-essence-pulse 2.2s ease-in-out infinite;
  transform-origin: center; transform-box: fill-box;
}
@keyframes hf-essence-pulse { 0%,100% { r: 6; opacity: 0.85; } 50% { r: 10; opacity: 1; } }
.hero-flow .hf-brain-label {
  position: absolute; left: 50%; top: calc(100% + 8px);
  transform: translateX(-50%);
  font-size: 13px; font-weight: 700;
  color: var(--hf-text); letter-spacing: -0.005em;
  white-space: nowrap; z-index: 4;
}
.hero-flow .hf-brain-sublabel {
  position: absolute; left: 50%; top: calc(100% + 28px);
  transform: translateX(-50%);
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 8.5px; letter-spacing: 0.14em;
  color: var(--hf-text-faint); text-transform: uppercase;
  white-space: nowrap; z-index: 4;
}
.hero-flow .hf-brain-flash {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(11,180,176,0.5), transparent 60%);
  opacity: 0; z-index: 2; pointer-events: none;
}
.hero-flow .hf-brain-flash.pulse { animation: hf-flash .55s ease-out; }
@keyframes hf-flash {
  0%   { opacity: 0;   transform: translate(-50%,-50%) scale(0.6); }
  35%  { opacity: 0.9; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0;   transform: translate(-50%,-50%) scale(1.15); }
}

/* ==========================================================
   ORG TREE
   ========================================================== */
.hero-flow .hf-tree-wrap {
  position: absolute;
  left: 620px; top: 108px;
  right: 20px; bottom: 20px;
  z-index: 3; pointer-events: none;
}
.hero-flow .hf-node {
  position: absolute;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 10px; color: var(--hf-text-dim);
  border-radius: 5px;
  transition: all .35s ease;
  border: 1px solid transparent;
  white-space: nowrap; letter-spacing: 0.02em;
  line-height: 1; background: transparent;
}
.hero-flow .hf-node .hf-n-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--hf-text-faint); flex-shrink: 0; }
.hero-flow .hf-node.hf-person { font-size: 9.5px; padding: 2px 7px; color: var(--hf-text-faint); }
.hero-flow .hf-node.hf-scale-federation { color: var(--hf-text); font-weight: 700; font-size: 11px; }
.hero-flow .hf-node.hf-scale-subsidiary { color: var(--hf-text); font-weight: 600; }
.hero-flow .hf-node.hf-scale-branch { color: var(--hf-text-dim); }
.hero-flow .hf-node.hf-scale-department { color: var(--hf-text-dim); }
.hero-flow .hf-node.active {
  color: var(--hf-teal-bright);
  background: rgba(11,180,176,0.10);
  border-color: rgba(11,180,176,0.35);
}
.hero-flow .hf-node.active .hf-n-dot { background: var(--hf-teal-bright); }
.hero-flow .hf-node.receives {
  color: var(--hf-teal-bright);
  background: rgba(11,180,176,0.22);
  border-color: var(--hf-teal-bright);
  box-shadow: 0 0 6px rgba(11,180,176,0.30);
  font-weight: 700;
}
.hero-flow .hf-node.receives .hf-n-dot { background: var(--hf-teal-bright); }

.hero-flow .hf-tree-line {
  stroke: var(--hf-line-strong);
  stroke-width: 1; fill: none;
  opacity: 0.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  transition: all .4s ease;
}
.hero-flow .hf-tree-line.active {
  stroke: var(--hf-teal-bright);
  opacity: 1; stroke-width: 2;
  filter: drop-shadow(0 0 4px var(--hf-teal-glow)) drop-shadow(0 0 8px rgba(11,180,176,0.45));
}

/* ==========================================================
   LLM caption
   ========================================================== */
.hero-flow .hf-llm-caption {
  position: absolute;
  left: 220px; top: 528px;
  width: 400px; text-align: center;
  font-family: var(--font-mono, "SF Mono", monospace);
  font-size: 9px; letter-spacing: 0.10em;
  color: var(--hf-text-faint);
  z-index: 3; pointer-events: none; white-space: nowrap;
}
.hero-flow .hf-llm-caption .n { color: var(--hf-teal-bright); font-weight: 700; }

/* ==========================================================
   RESPONSIVE — narrow viewports scale the stage proportionally
   ========================================================== */
@container (max-width: 1000px) {
  .hero-flow .hf-stage { transform-origin: top center; }
}
@media (max-width: 900px) {
  .hero-flow .hf-stage { height: 520px; }
}
