/* Motion refinements: progressive APIM reveal + animated 01 -> 02 -> 03 arrow.
 * No concentric ring rotates in this version. */

/* The APIM orbit stays geometrically static. On mobile it appears as the user
 * reaches the diagnostic card instead of spinning continuously. */
.math-orbit {
  isolation: isolate;
  overflow: visible;
}

.math-orbit::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(210, 176, 165, 0.30);
  border-radius: 50%;
  pointer-events: none;
}

.math-orbit::after {
  content: "";
  position: absolute;
  inset: 15px;
  border: 1px dashed rgba(67, 82, 87, 0.30);
  border-top-color: rgba(210, 176, 165, 0.66);
  border-right-color: rgba(149, 111, 103, 0.48);
  border-radius: 50%;
  pointer-events: none;
}

.math-orbit.apim-orbit-reveal-ready {
  opacity: 0;
  transform: translateY(18px) scale(0.90);
  transition:
    opacity 900ms cubic-bezier(.22,.72,.24,1),
    transform 1050ms cubic-bezier(.22,.72,.24,1);
}

.math-orbit.apim-orbit-reveal-ready.apim-orbit-revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Subject circles are also static. Their inner ring keeps the two-tone visual
 * language without pretending that motion adds meaning here. */
.subject-symbol {
  position: relative;
  isolation: isolate;
}

.subject-symbol::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed rgba(210, 176, 165, 0.62);
  border-right-color: rgba(166, 173, 152, 0.56);
  border-bottom-color: rgba(67, 82, 87, 0.46);
  border-radius: 50%;
  pointer-events: none;
}

/* Diagnostic 01 -> 02 -> 03.
 * JavaScript injects one growing arrow whose real geometry is measured from the
 * numbered circles. The arrow is behind the markers, so it disappears under 02
 * instead of drawing across it, then re-emerges and continues to 03. */
.diagnostic-card ol {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-auto-rows: 78px;
  gap: 0;
  overflow: visible;
}

.diagnostic-card ol::before,
.diagnostic-card ol::after {
  content: none !important;
}

.diagnostic-card li {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 15px;
  min-height: 78px;
  border-top: 0;
  padding: 0;
  opacity: 1;
  transform: none;
}

.diagnostic-card li::after {
  content: none !important;
}

.diagnostic-card li > span {
  position: relative;
  z-index: 4;
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--pink-dark);
  background: #fffdf8;
  border: 1px solid rgba(210, 176, 165, 0.95);
  border-radius: 50%;
  box-shadow: 0 7px 18px rgba(47, 52, 55, 0.08);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.72rem;
  line-height: 1;
}

.diagnostic-card li > div {
  position: relative;
  z-index: 4;
  min-width: 0;
  padding-top: 0;
}

.apim-diagnostic-arrow {
  position: absolute;
  z-index: 0;
  width: 3px;
  pointer-events: none;
  transform: translateX(-50%);
}

.apim-diagnostic-arrow__track,
.apim-diagnostic-arrow__shaft {
  position: absolute;
  inset: 0;
  width: 3px;
  border-radius: 999px;
}

.apim-diagnostic-arrow__track {
  background: linear-gradient(
    to bottom,
    rgba(210, 176, 165, 0.16),
    rgba(67, 82, 87, 0.13),
    rgba(210, 176, 165, 0.16)
  );
}

.apim-diagnostic-arrow__shaft {
  background: linear-gradient(
    to bottom,
    rgba(149, 111, 103, 0.98) 0%,
    rgba(210, 176, 165, 0.98) 42%,
    rgba(67, 82, 87, 0.92) 68%,
    rgba(149, 111, 103, 0.98) 100%
  );
  box-shadow: 0 0 12px rgba(149, 111, 103, 0.16);
  transform: scaleY(0);
  transform-origin: top center;
}

.apim-diagnostic-arrow__head {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 50%;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(149, 111, 103, 0.98);
  border-bottom: 2px solid rgba(149, 111, 103, 0.98);
  opacity: 0;
  transform: translate(-50%, -45%) rotate(45deg);
}

.diagnostic-card.apim-timeline-active .apim-diagnostic-arrow__shaft {
  animation: apimArrowDraw 5.6s cubic-bezier(.24,.69,.27,1) forwards;
}

.diagnostic-card.apim-timeline-active .apim-diagnostic-arrow__head {
  animation: apimArrowTravel 5.6s cubic-bezier(.24,.69,.27,1) forwards;
}

@keyframes apimArrowDraw {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

@keyframes apimArrowTravel {
  0% {
    top: 0;
    opacity: 0;
  }
  4% {
    opacity: 1;
  }
  96% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 1;
  }
}

@media (max-width: 760px) {
  .diagnostic-card ol {
    grid-auto-rows: 88px;
  }

  .diagnostic-card li {
    min-height: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .math-orbit.apim-orbit-reveal-ready {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .diagnostic-card .apim-diagnostic-arrow__shaft {
    transform: scaleY(1);
    animation: none !important;
  }

  .diagnostic-card .apim-diagnostic-arrow__head {
    top: 100%;
    opacity: 1;
    animation: none !important;
  }
}
