/* ═══════════════════════════════════════════════════════════════
   Interactive Flow Diagram — Light Mode
   Clean professional look, connections visible by default
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Canvas ───────────────────────────────────────────────────── */
.infographic-canvas {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  min-height: 480px;
  background: #fafbfc;
  border-radius: 20px;
  border: 1px solid #e2e6ec;
  overflow: hidden;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Subtle dot grid */
.infographic-canvas::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#d0d5dd 0.8px, transparent 0.8px);
  background-size: 24px 24px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

/* ── SVG Layer ────────────────────────────────────────────────── */
.flow-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Connections — visible + animated by default */
.flow-connection {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 8 5;
  animation: dashFlow 1.2s linear infinite;
  transition: stroke 0.35s ease, stroke-width 0.35s ease, opacity 0.35s ease;
}

@keyframes dashFlow {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -26; }
}

/* When a node is selected, highlight active connections */
.flow-connection.active {
  stroke-width: 2.8;
  stroke-dasharray: 10 4;
  animation: dashFlow 0.8s linear infinite;
  filter: url(#line-glow);
}

.flow-connection.dimmed {
  opacity: 0.15;
  animation-play-state: paused;
}

/* Connection labels */
.connection-label {
  font-size: 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.connection-label.dimmed {
  opacity: 0.12;
}

/* Label background pill */
.label-bg {
  fill: #fff;
  rx: 6;
  ry: 6;
  opacity: 0.92;
}

/* Arrowheads */
.flow-arrowhead {
  transition: opacity 0.35s ease;
}

.flow-arrowhead.dimmed {
  opacity: 0.15;
}

/* ── Nodes ────────────────────────────────────────────────────── */
.flow-node {
  position: absolute;
  width: 76px;
  height: 76px;
  transform: translate(-50%, -50%) scale(0);
  z-index: 5;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
  animation: nodeEntry 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.flow-node:nth-child(1)  { animation-delay: 0.08s; }
.flow-node:nth-child(2)  { animation-delay: 0.14s; }
.flow-node:nth-child(3)  { animation-delay: 0.20s; }
.flow-node:nth-child(4)  { animation-delay: 0.26s; }
.flow-node:nth-child(5)  { animation-delay: 0.32s; }
.flow-node:nth-child(6)  { animation-delay: 0.38s; }
.flow-node:nth-child(7)  { animation-delay: 0.44s; }
.flow-node:nth-child(8)  { animation-delay: 0.50s; }
.flow-node:nth-child(9)  { animation-delay: 0.56s; }
.flow-node:nth-child(10) { animation-delay: 0.62s; }
.flow-node:nth-child(11) { animation-delay: 0.68s; }
.flow-node:nth-child(12) { animation-delay: 0.74s; }

@keyframes nodeEntry {
  0% { transform: translate(-50%, -50%) scale(0); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.flow-node:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.flow-node.active {
  transform: translate(-50%, -50%) scale(1.12);
}

.flow-node.dimmed {
  transform: translate(-50%, -50%) scale(0.9);
  filter: grayscale(0.6) opacity(0.35);
}

/* Node circle */
.node-circle {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 3px solid #fff;
  box-shadow:
    0 3px 12px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.flow-node:hover .node-circle {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.06);
}

.flow-node.active .node-circle {
  border-color: transparent;
  box-shadow:
    0 0 0 3px rgba(99, 102, 241, 0.3),
    0 6px 24px rgba(0, 0, 0, 0.12);
}

/* Pulse ring for active */
.flow-node.active .node-circle::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.3;
  animation: pulseRing 1.8s ease-out infinite;
}

@keyframes pulseRing {
  0% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Node icon */
.node-icon {
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
  user-select: none;
  color: #fff;
}

/* Node label */
.node-label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  letter-spacing: 0.01em;
  font-family: 'Inter', system-ui, sans-serif;
  transition: color 0.3s ease;
}

.flow-node.dimmed .node-label {
  color: #d1d5db;
}

/* ── Hero Header ──────────────────────────────────────────────── */
.infographic-hero {
  text-align: center;
  padding: 52px 24px 36px;
  background: #fff;
  border-bottom: 1px solid #f0f1f3;
}

.infographic-badge {
  display: inline-block;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 16px;
  margin-bottom: 18px;
  font-family: 'Inter', system-ui, sans-serif;
}

.infographic-hero h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 800;
  color: #111827;
  line-height: 1.25;
  margin: 0 0 10px;
  font-family: 'Inter', system-ui, sans-serif;
}

.infographic-hero p {
  font-size: 1rem;
  color: #6b7280;
  max-width: 480px;
  margin: 0 auto 12px;
  line-height: 1.5;
  font-family: 'Inter', system-ui, sans-serif;
}

.infographic-date {
  font-size: 0.78rem;
  color: #9ca3af;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ── Hint ─────────────────────────────────────────────────────── */
.flow-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 5px 16px;
  font-size: 11px;
  font-weight: 500;
  color: #9ca3af;
  z-index: 10;
  white-space: nowrap;
  font-family: 'Inter', system-ui, sans-serif;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* ── Legend ────────────────────────────────────────────────────── */
.flow-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  padding: 12px 16px;
  margin-top: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0 0 14px 14px;
  font-family: 'Inter', system-ui, sans-serif;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.flow-legend h3 {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  margin: 0 8px 0 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 5px;
}

.legend-item:last-child { margin-bottom: 0; }

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}

/* ── Takeaway ─────────────────────────────────────────────────── */
.infographic-takeaway {
  text-align: center;
  padding: 44px 24px 52px;
  background: #fff;
  border-top: 1px solid #f0f1f3;
}

.takeaway-icon {
  font-size: 32px;
  margin-bottom: 14px;
}

.takeaway-label {
  font-size: 10px;
  font-weight: 700;
  color: #6366f1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 12px;
  font-family: 'Inter', system-ui, sans-serif;
}

.takeaway-text {
  font-size: 1rem;
  color: #4b5563;
  max-width: 520px;
  margin: 0 auto 22px;
  line-height: 1.6;
  font-family: 'Inter', system-ui, sans-serif;
}

.takeaway-cta {
  display: inline-block;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 30px;
  border-radius: 10px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow: 0 3px 14px rgba(99, 102, 241, 0.25);
  font-family: 'Inter', system-ui, sans-serif;
}

.takeaway-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35);
}

/* ── Share ─────────────────────────────────────────────────────── */
.infographic-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
  background: #fafbfc;
  border-top: 1px solid #f0f1f3;
}

.infographic-share span {
  font-size: 0.78rem;
  color: #9ca3af;
  font-weight: 500;
  font-family: 'Inter', system-ui, sans-serif;
}

.infographic-share a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #6b7280;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.infographic-share a:hover {
  background: #e5e7eb;
  color: #374151;
}

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .infographic-canvas {
    aspect-ratio: auto;
    min-height: 380px;
    border-radius: 14px;
  }

  .flow-node {
    width: 56px;
    height: 56px;
  }

  .node-circle {
    width: 56px;
    height: 56px;
    border-width: 2px;
  }

  .node-label {
    font-size: 9px;
    bottom: -18px;
  }

  .flow-legend {
    padding: 8px 12px;
    gap: 4px 14px;
  }

  .flow-hint {
    font-size: 9px;
    padding: 4px 10px;
  }

  .infographic-hero {
    padding: 36px 16px 24px;
  }

  .infographic-takeaway {
    padding: 32px 16px 40px;
  }

  .infographic-article {
    padding: 28px 16px;
  }
}

/* ── Article Content ─────────────────────────────────────────────── */
.infographic-article {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 24px;
  font-family: 'Inter', system-ui, sans-serif;
}

.infographic-article p {
  font-size: 1.05rem;
  line-height: 1.75;
  color: #374151;
  margin: 0 0 18px;
}

.infographic-article h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #111827;
  margin: 32px 0 14px;
  padding-left: 14px;
  border-left: 3px solid #6366f1;
  line-height: 1.3;
}

.infographic-article strong {
  color: #111827;
  font-weight: 600;
}

.infographic-article em {
  font-style: italic;
  color: #4b5563;
}

.infographic-article code {
  background: #f3f4f6;
  color: #6366f1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.infographic-article ul, .infographic-article ol {
  padding-left: 24px;
  margin: 0 0 18px;
}

.infographic-article li {
  font-size: 1.05rem;
  line-height: 1.75;
  color: #374151;
  margin-bottom: 6px;
}

.article-section {
  margin-bottom: 8px;
}

.article-intro {
  font-size: 1.1rem;
}

.article-intro p:first-child {
  font-size: 1.15rem;
  color: #1f2937;
  font-weight: 450;
}

/* Diagram label */
.diagram-label {
  text-align: center;
  margin-bottom: 12px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6366f1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.diagram-label span {
  margin-right: 4px;
}

/* ── Watermark ────────────────────────────────────────────────── */
.infographic-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-25deg);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  font-weight: 700;
  color: rgba(0, 0, 0, 0.04);
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* ── GIF Export Mode ──────────────────────────────────────────── */
/* Shows only the canvas area for client-side GIF capture.
   Nodes appear immediately (no entry animation).
   Dash-flow animation keeps running for the animated GIF. */
.gif-export-mode .infographic-hero,
.gif-export-mode .infographic-article,
.gif-export-mode .infographic-takeaway,
.gif-export-mode .infographic-share,
.gif-export-mode .article-conclusion-wrap,
.gif-export-mode .flow-hint,
.gif-export-mode .diagram-label {
  display: none !important;
}

.gif-export-mode {
  background: #fafbfc;
  padding: 0;
  margin: 0;
}

.gif-export-mode .infographic-canvas {
  border-radius: 0;
  border: none;
  box-shadow: none;
  max-width: 100%;
  min-height: auto;
  aspect-ratio: 16 / 9;
}

/* Skip entry animations — nodes appear at full scale immediately */
.gif-export-mode .flow-node {
  animation: none !important;
  transform: translate(-50%, -50%) scale(1) !important;
}

/* ── Reduced motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .flow-node {
    animation: none;
    transform: translate(-50%, -50%) scale(1);
  }

  .flow-node.active .node-circle::after {
    animation: none;
  }

  .flow-connection {
    animation: none;
  }
}
