/* ==========================================================================
   Ryddhu AI explanatory diagrams (inline SVG)
   Use with the SVGs in /diagrams. Paste each SVG inline inside:
   <figure class="rd-figure"> ...svg... <figcaption>...</figcaption></figure>
   Motion is decorative only, slow, and off for prefers-reduced-motion.
   ========================================================================== */

.rd-figure {
  margin: 0;
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

.rd-figure svg {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  overflow: visible;
}

.rd-figure figcaption {
  max-width: 420px;
  font-size: 0.8125rem;           /* 13 px */
  line-height: 1.5;
  color: #526674;                 /* 5.9:1 on white, 5.6:1 on mist */
  text-align: center;
}

/* SVG text picks up the self-hosted body font when inline */
.rd-diagram text {
  font-family: var(--font-body, "Space Grotesk", system-ui, sans-serif);
}

/* --- Motion (only when the user has not asked for less) ----------------- */
@media (prefers-reduced-motion: no-preference) {
  /* Connectors: a calm "data moving" dash along the arrow lines */
  .rd-diagram .rd-flow {
    stroke-dasharray: 5 5;
    animation: rd-flow 1.8s linear infinite;
  }

  /* Model chip / key dot: soft breathing */
  .rd-diagram .rd-pulse {
    animation: rd-pulse 2.8s ease-in-out infinite;
  }

  /* Audit trail: entries light up in order, then hold */
  .rd-diagram .rd-log {
    animation: rd-log 6s ease-in-out infinite;
  }
  .rd-diagram .rd-log--2 { animation-delay: 0.6s; }
  .rd-diagram .rd-log--3 { animation-delay: 1.2s; }
  .rd-diagram .rd-log--4 { animation-delay: 1.8s; }

  /* Quality loop: one marker travels the ring */
  .rd-diagram .rd-orbit {
    transform-box: view-box;
    transform-origin: 200px 180px;
    animation: rd-orbit 14s linear infinite;
  }

  /* Save battery: pause while the figure is off-screen (motion.js adds it) */
  .rd-figure.is-paused .rd-diagram * {
    animation-play-state: paused;
  }
}

@keyframes rd-flow {
  to { stroke-dashoffset: -20; }
}
@keyframes rd-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes rd-log {
  0%, 8% { opacity: 0.25; }
  16%, 85% { opacity: 1; }
  100% { opacity: 0.25; }
}
@keyframes rd-orbit {
  to { transform: rotate(360deg); }
}

/* Reduced motion: everything static and fully visible */
@media (prefers-reduced-motion: reduce) {
  .rd-diagram * {
    animation: none !important;
  }
  .rd-diagram .rd-log { opacity: 1; }
}

/* Forced colours (Windows high contrast): keep lines visible */
@media (forced-colors: active) {
  .rd-diagram rect,
  .rd-diagram path,
  .rd-diagram circle { stroke: CanvasText; }
  .rd-diagram text { fill: CanvasText; }
}
