/* ==========================================================================
   OgbonMath — Unified Loading States
   --------------------------------------------------------------------------
   Two reusable primitives:

   1. .thinking-dots — the "AI is working" indicator (3 bouncing dots).
      Color-inherits via currentColor, so it looks right in accent buttons,
      neutral buttons, or on a paper surface.

   2. .sk-line / .sk-card / .sk-circle — skeleton placeholders with
      shimmer. Use during slow data loads.

   Both respect prefers-reduced-motion.
   ========================================================================== */

/* ==========================================================================
   Thinking dots
   ==========================================================================
   Matches InlineTutor's .itr-typing-dot styling so both surfaces look
   identical. Uses currentColor so it picks up the parent's color (white
   on primary buttons, accent on neutral buttons, etc.).
*/
.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
  line-height: 0;
}

.thinking-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: thinking-bounce 1.2s var(--ease-calm) infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes thinking-bounce {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ==========================================================================
   Buttons in "thinking" state — preserve width to prevent layout shift
   ==========================================================================
*/
button.btn-thinking,
.btn.btn-thinking {
  /* Keep the original footprint so the button doesn't collapse to
     just 3 dots' width when the label is swapped out. */
  min-width: var(--thinking-min-width, 92px);
  pointer-events: none;
  opacity: 0.9;
}

/* Small buttons (inline hint / math-vision button / etc) need less min-width */
button.btn-thinking.btn-thinking-sm,
.btn.btn-thinking.btn-thinking-sm {
  min-width: 60px;
}

/* For labeled "Thinking ..." composite, gap between label and dots */
.thinking-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}

/* ==========================================================================
   Skeleton blocks — shimmer loading placeholders
   ==========================================================================
*/
.sk-line,
.sk-card,
.sk-circle {
  display: block;
  position: relative;
  background: var(--bg3);
  background-image: linear-gradient(
    90deg,
    var(--bg3) 0%,
    var(--bg4) 50%,
    var(--bg3) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s var(--ease-calm) infinite;
  border-radius: var(--radius-sm);
}

.sk-line {
  height: 14px;
  margin-bottom: 10px;
  width: 100%;
}

.sk-card {
  min-height: 80px;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
}

.sk-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* Width utility classes for varying skeleton line lengths */
.sk-w-40 { width: 40% !important; }
.sk-w-50 { width: 50% !important; }
.sk-w-60 { width: 60% !important; }
.sk-w-70 { width: 70% !important; }
.sk-w-80 { width: 80% !important; }
.sk-w-90 { width: 90% !important; }

/* Height utility classes for cards */
.sk-h-40  { min-height: 40px !important; }
.sk-h-80  { min-height: 80px !important; }
.sk-h-120 { min-height: 120px !important; }
.sk-h-200 { min-height: 200px !important; }

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   Math Hub solution skeleton — matches the shape of a real solution card
   ==========================================================================
*/
.sk-solution {
  padding: var(--sp-5);
  background: var(--bg2);
  border: 1px solid var(--bdr);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-height: 280px;
}

.sk-solution-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--tx2);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  margin-bottom: var(--sp-4);
  letter-spacing: var(--ls-wide);
}

/* Step-like blocks in the skeleton */
.sk-solution-step {
  display: flex;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}

.sk-solution-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  background-image: linear-gradient(
    90deg,
    var(--bg3) 0%,
    var(--bg4) 50%,
    var(--bg3) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s var(--ease-calm) infinite;
}

.sk-solution-step-body {
  flex: 1;
  min-width: 0;
}

/* ==========================================================================
   Reduced motion — disable all animations
   ==========================================================================
*/
@media (prefers-reduced-motion: reduce) {
  .thinking-dot,
  .sk-line,
  .sk-card,
  .sk-circle,
  .sk-solution-step-num {
    animation: none;
  }
  .thinking-dot {
    opacity: 0.6;
  }
}
