/* =====================================================================
   THE WORLD OF ALGORITHMS (CLASS 9) — Maths Notes
   Figure wrappers, SVG styles, animated diagrams, algorithm boxes, tables and cards.
   Base styles (.notes-page-wrap, .notes-toc, .topic-section, .concept-card,
   .formula-box, .definition-box, .props-list) come from /css/notes-content.css.
   ===================================================================== */

.wa-fig { display: flex; flex-direction: column; align-items: center; margin: 22px auto; max-width: 500px; }
.wa-fig svg { display: block; width: 100%; height: auto; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; user-select: none; }
.wa-caption { margin-top: 8px; font-size: 13px; color: #64748b; text-align: center; line-height: 1.5; }

.proof-box { background: #f8fafc; border: 1px solid #e2e8f0; border-left: 4px solid #2563eb; border-radius: 6px; padding: 16px 20px; margin: 18px 0; font-size: 14.5px; line-height: 1.7; color: #334155; }
.proof-header { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #2563eb; margin-bottom: 8px; }
.proof-step { margin-bottom: 8px; }
.proof-step strong { color: #0f172a; }

/* Algorithm boxes */
.wa-algo { background: #f8fafc; border: 1px solid #e2e8f0; border-left: 4px solid #16a34a; border-radius: 6px; padding: 16px 20px; margin: 18px 0; font-size: 14.5px; line-height: 1.7; color: #334155; }
.wa-algo-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #16a34a; margin-bottom: 8px; }
.wa-step { margin-bottom: 6px; }
.wa-sub { margin: 2px 0 6px 22px; font-size: 14px; color: #475569; }
.wa-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: #eef2f7; border-radius: 4px; padding: 1px 5px; color: #0f172a; }

.wa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 20px 0; }
.wa-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); }
.wa-card h4 { margin: 0 0 8px; font-size: 15.5px; font-weight: 700; color: #0f172a; }
.wa-card p { margin: 0 0 10px; font-size: 13.5px; color: #475569; line-height: 1.55; }
.wa-badge { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: #2563eb; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 4px; padding: 2px 7px; margin-bottom: 8px; }

.wa-table-wrap { overflow-x: auto; margin: 16px 0; }
.wa-table { width: 100%; border-collapse: collapse; font-size: 13.5px; line-height: 1.55; color: #334155; }
.wa-table th, .wa-table td { border: 1px solid #e2e8f0; padding: 8px 10px; text-align: left; vertical-align: top; }
.wa-table th { background: #f1f5f9; color: #0f172a; font-weight: 700; }

.wa-svg-axis { stroke: #0f172a; stroke-width: 1.8; }
.wa-svg-line { fill: none; stroke: #2563eb; stroke-width: 2.2; }
.wa-svg-dash { fill: none; stroke: #94a3b8; stroke-width: 1.3; stroke-dasharray: 4; }
.wa-svg-t { font-size: 12.5px; font-weight: 600; fill: #1e293b; }
.wa-svg-tb { font-size: 12.5px; font-weight: 700; fill: #2563eb; }
.wa-svg-tr { font-size: 12.5px; font-weight: 700; fill: #dc2626; }
.wa-svg-tg { font-size: 12.5px; font-weight: 700; fill: #16a34a; }
.wa-svg-tm { font-size: 11.5px; font-weight: 500; fill: #64748b; }

/* ---------- Animated diagrams ---------- */

/* Addition: the carry moves one column to the left at a time */
.wa-carry { opacity: 0.15; animation: waFlash 6s ease-in-out infinite; }
.wa-a2 { animation-delay: 1.5s; }
.wa-a3 { animation-delay: 3s; }
@keyframes waFlash { 0%, 100% { opacity: 0.15; } 10%, 30% { opacity: 1; } 45% { opacity: 0.15; } }

/* Divisors: the pointer j scans 1, 2, 3, ... n */
.wa-ptr { animation: waScan 7s ease-in-out infinite; }
@keyframes waScan { 0%, 5% { transform: translateX(0); } 90%, 100% { transform: translateX(360px); } }

/* Euclid: the leftover m - n is also tiled by blocks of size d */
.wa-pulse { animation: waPulse 3s ease-in-out infinite; }
@keyframes waPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* Subtraction hops vs one division jump */
.wa-hop { opacity: 0; animation: waHop 9s ease infinite; animation-delay: calc(var(--i) * 0.3s); }
@keyframes waHop { 0% { opacity: 0; } 6%, 80% { opacity: 1; } 100% { opacity: 0; } }
.wa-jump { opacity: 0; animation: waJump 9s ease infinite; animation-delay: 3s; }
@keyframes waJump { 0% { opacity: 0; } 8%, 70% { opacity: 1; } 90%, 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .wa-carry, .wa-ptr, .wa-pulse, .wa-hop, .wa-jump { animation: none !important; }
  .wa-carry, .wa-hop, .wa-jump, .wa-pulse { opacity: 1; }
}