/* ============================================================
   למדתי בחיידר - Math Visualizations Stylesheet
   Dark RTL theme — SVG-based interactive math models
   Supports: number lines, arrays, pie charts, bar models,
             balance scales, coordinate planes, place value blocks
   ============================================================ */

/* ============================================================
   1. Container — base wrapper for every visualization
   ============================================================ */
.viz-container {
  position: relative;
  direction: ltr; /* math is always LTR even inside RTL layout */
  background: linear-gradient(145deg, #16213e 0%, #1a1a2e 100%);
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: 16px;
  padding: 24px;
  margin: 16px 0;
  min-height: 200px;
  overflow: visible;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: vizFadeUp 0.5s ease-out both;
}

/* Subtle noise grain overlay — adds depth without images */
.viz-container::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: repeating-radial-gradient(
    circle at 1px 1px,
    rgba(255, 255, 255, 0.015) 1px,
    transparent 0
  );
  background-size: 4px 4px;
  pointer-events: none;
  z-index: 0;
}

/* Inner glow ribbon at the top edge */
.viz-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(108, 92, 231, 0.6) 40%,
    rgba(108, 92, 231, 0.6) 60%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Corner accent — top-left geometric mark */
.viz-container .viz-corner-tl,
.viz-container .viz-corner-br {
  position: absolute;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 1;
}
.viz-container .viz-corner-tl {
  top: 10px;
  left: 10px;
  border-top: 2px solid rgba(108, 92, 231, 0.4);
  border-left: 2px solid rgba(108, 92, 231, 0.4);
  border-radius: 4px 0 0 0;
}
.viz-container .viz-corner-br {
  bottom: 10px;
  right: 10px;
  border-bottom: 2px solid rgba(108, 92, 231, 0.4);
  border-right: 2px solid rgba(108, 92, 231, 0.4);
  border-radius: 0 0 4px 0;
}

/* All direct children sit above the pseudo-elements */
.viz-container > * {
  position: relative;
  z-index: 2;
}

/* ============================================================
   2. SVG inside container
   ============================================================ */
.viz-container svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 340px;
  margin: 0 auto;
  overflow: visible; /* allow glows and drop-shadows to bleed */
}

/* ============================================================
   3. Label below the visualization
   ============================================================ */
.viz-label {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 0.9rem;
  margin-top: 12px;
  direction: rtl; /* labels can be Hebrew */
  line-height: 1.4;
  letter-spacing: 0.01em;
}

/* ============================================================
   4. Number Line — jump arcs, dots, result dot
   ============================================================ */
.viz-jump-arc {
  fill: none;
  stroke: #6C5CE7;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: var(--arc-length, 300);
  stroke-dashoffset: var(--arc-length, 300);
  animation: vizDrawArc 0.8s ease-out forwards;
}

.viz-number-dot {
  fill: #a29bfe;
  animation: vizDotPulse 1.5s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.viz-result-dot {
  fill: #00B894;
  filter: drop-shadow(0 0 8px #00B894);
  animation: vizResultGlow 2s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* Axis line and tick marks */
.viz-axis-line {
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.viz-tick-label {
  fill: rgba(255, 255, 255, 0.55);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 11px;
}

/* ============================================================
   5. Array Model — dot grid for multiplication / division
   ============================================================ */
.viz-array-dot {
  fill: #6C5CE7;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: vizDotAppear 0.3s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  cursor: default;
  transition: filter 0.2s ease, transform 0.2s ease;
}

.viz-array-dot:hover {
  filter: brightness(1.4) drop-shadow(0 0 6px rgba(108, 92, 231, 0.8));
  transform: scale(1.25);
}

/* Row divider line (for grouping) */
.viz-array-divider {
  stroke: rgba(253, 203, 110, 0.35);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

/* ============================================================
   6. Pie / Fraction Chart
   ============================================================ */
.viz-pie-segment {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: vizPieReveal 0.6s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  stroke: #1a1a2e;
  stroke-width: 1.5;
  transition: filter 0.2s ease, transform 0.25s ease;
}

.viz-pie-segment:hover {
  filter: brightness(1.25) drop-shadow(0 0 8px rgba(108, 92, 231, 0.6));
  transform: scale(1.04);
}

/* Fraction label in center */
.viz-pie-center-label {
  fill: #e8e8f0;
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 18px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* ============================================================
   7. Bar Model — horizontal bars
   ============================================================ */
.viz-bar-fill {
  transform-box: fill-box;
  transform-origin: left center;
  animation: vizBarGrow 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  transition: filter 0.2s ease;
}

.viz-bar-fill:hover {
  filter: brightness(1.3);
}

.viz-bar-track {
  fill: rgba(255, 255, 255, 0.06);
  rx: 4;
}

.viz-bar-label {
  fill: rgba(255, 255, 255, 0.7);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 12px;
  dominant-baseline: middle;
}

/* ============================================================
   8. Balance Scale
   ============================================================ */
.viz-scale-beam {
  stroke: #a29bfe;
  stroke-width: 3;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: center;
  animation: vizBeamTilt 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.viz-scale-pan {
  fill: rgba(108, 92, 231, 0.15);
  stroke: #6C5CE7;
  stroke-width: 1.5;
  transition: transform 0.6s ease-in-out;
}

.viz-scale-fulcrum {
  fill: #6C5CE7;
}

.viz-scale-weight {
  transform-box: fill-box;
  transform-origin: center;
  animation: vizDotAppear 0.35s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  opacity: 0;
}

.viz-scale-weight-label {
  fill: #1a1a2e;
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

/* ============================================================
   9. Coordinate Plane
   ============================================================ */
.viz-coord-axis {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.viz-coord-grid {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
}

.viz-coord-point {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: vizPointBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  cursor: pointer;
  transition: filter 0.2s ease;
}

.viz-coord-point:hover {
  transform: scale(1.3);
  filter: drop-shadow(0 0 10px rgba(0, 184, 148, 0.9));
}

.viz-coord-point-label {
  fill: rgba(255, 255, 255, 0.8);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.viz-coord-point:hover + .viz-coord-point-label {
  opacity: 1;
}

.viz-coord-tick-label {
  fill: rgba(255, 255, 255, 0.4);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 10px;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* ============================================================
   10. Place Value Blocks
   ============================================================ */
.viz-block-drop {
  transform-box: fill-box;
  transform-origin: top center;
  opacity: 0;
  animation: vizBlockDrop 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-block-drop rect {
  rx: 3;
}

.viz-block-label {
  fill: #1a1a2e;
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.viz-place-value-heading {
  fill: rgba(255, 255, 255, 0.5);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 12px;
  text-anchor: middle;
}

/* ============================================================
   11. Angle Arc — protractor-style angle measurement
   ============================================================ */
.viz-angle-ray {
  stroke: #00B894;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: filter 0.2s ease;
}

.viz-angle-ray:hover {
  filter: drop-shadow(0 0 6px rgba(0, 184, 148, 0.7));
}

.viz-angle-arc {
  fill: none;
  stroke: #FDCB6E;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: var(--arc-length, 200);
  stroke-dashoffset: var(--arc-length, 200);
  animation: vizDrawArc 0.8s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  filter: drop-shadow(0 0 4px rgba(253, 203, 110, 0.4));
}

.viz-angle-label {
  fill: #FDCB6E;
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 16px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out 0.7s forwards;
}

.viz-protractor {
  fill: rgba(108, 92, 231, 0.08);
  stroke: rgba(108, 92, 231, 0.2);
  stroke-width: 1;
  transition: fill 0.3s ease;
}

.viz-protractor:hover {
  fill: rgba(108, 92, 231, 0.14);
}

.viz-protractor-tick {
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 0.5;
}

/* ============================================================
   12. Triangle Diagram — edges, angles, heights, labels
   ============================================================ */
.viz-triangle-edge {
  fill: none;
  stroke: #6C5CE7;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--edge-length, 500);
  stroke-dashoffset: var(--edge-length, 500);
  animation: vizDrawArc 1s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  filter: drop-shadow(0 0 3px rgba(108, 92, 231, 0.5));
}

.viz-triangle-side-label {
  fill: rgba(255, 255, 255, 0.75);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-triangle-angle-arc {
  fill: none;
  stroke: #FDCB6E;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: var(--arc-length, 50);
  stroke-dashoffset: var(--arc-length, 50);
  animation: vizDrawArc 0.5s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-triangle-right-mark {
  fill: none;
  stroke: #00B894;
  stroke-width: 1.5;
  opacity: 0;
  animation: vizDotAppear 0.3s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-triangle-height {
  stroke: rgba(253, 203, 110, 0.45);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

/* ============================================================
   13. Circle Diagram — outline, radius, diameter, area fill
   ============================================================ */
.viz-circle-outline {
  fill: none;
  stroke: #6C5CE7;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: var(--arc-length, 628);
  stroke-dashoffset: var(--arc-length, 628);
  animation: vizDrawArc 1.1s ease-out forwards;
  filter: drop-shadow(0 0 5px rgba(108, 92, 231, 0.45));
}

.viz-circle-radius {
  stroke: #00B894;
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-circle-diameter {
  stroke: #FDCB6E;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 6 4;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-circle-area-fill {
  fill: rgba(108, 92, 231, 0.12);
  stroke: none;
  opacity: 0;
  animation: vizPieReveal 0.7s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  transition: fill 0.3s ease;
}

.viz-circle-area-fill:hover {
  fill: rgba(108, 92, 231, 0.22);
}

.viz-circle-label {
  fill: rgba(255, 255, 255, 0.8);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

/* ============================================================
   14. Trigonometry Unit Circle — sin / cos / hypotenuse
   ============================================================ */
.viz-trig-circle {
  fill: rgba(108, 92, 231, 0.06);
  stroke: rgba(108, 92, 231, 0.35);
  stroke-width: 1.5;
  stroke-dasharray: var(--arc-length, 628);
  stroke-dashoffset: var(--arc-length, 628);
  animation: vizDrawArc 1.2s ease-out forwards;
}

.viz-trig-sin-line {
  stroke: #E17055;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: var(--edge-length, 200);
  stroke-dashoffset: var(--edge-length, 200);
  animation: vizDrawArc 0.6s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  filter: drop-shadow(0 0 4px rgba(225, 112, 85, 0.5));
}

.viz-trig-cos-line {
  stroke: #00B894;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: var(--edge-length, 200);
  stroke-dashoffset: var(--edge-length, 200);
  animation: vizDrawArc 0.6s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  filter: drop-shadow(0 0 4px rgba(0, 184, 148, 0.5));
}

.viz-trig-hyp-line {
  stroke: #6C5CE7;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: var(--edge-length, 200);
  stroke-dashoffset: var(--edge-length, 200);
  animation: vizDrawArc 0.7s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  filter: drop-shadow(0 0 4px rgba(108, 92, 231, 0.5));
}

.viz-trig-label {
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

/* ============================================================
   15. Exponent Tower — growing bars showing powers
   ============================================================ */
.viz-exp-bar {
  transform-box: fill-box;
  transform-origin: bottom center;
  rx: 4;
  animation: vizExpGrow 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  opacity: 0;
  transition: filter 0.2s ease;
}

.viz-exp-bar:hover {
  filter: brightness(1.3) drop-shadow(0 0 8px rgba(108, 92, 231, 0.6));
}

.viz-exp-label {
  fill: rgba(255, 255, 255, 0.9);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.35s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-exp-expansion {
  fill: rgba(253, 203, 110, 0.75);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 11px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: hanging;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

/* ============================================================
   16. Function Graph — curves, tangent, area, asymptotes
   ============================================================ */
.viz-func-curve {
  fill: none;
  stroke: #6C5CE7;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--arc-length, 800);
  stroke-dashoffset: var(--arc-length, 800);
  animation: vizDrawArc 1.3s ease-out forwards;
  filter: drop-shadow(0 0 4px rgba(108, 92, 231, 0.4));
  transition: filter 0.2s ease;
}

.viz-func-curve:hover {
  filter: drop-shadow(0 0 8px rgba(108, 92, 231, 0.75));
}

.viz-func-tangent {
  stroke: #FDCB6E;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: var(--edge-length, 300);
  stroke-dashoffset: var(--edge-length, 300);
  animation: vizDrawArc 0.6s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  opacity: 0.85;
}

.viz-func-area {
  fill: rgba(108, 92, 231, 0.15);
  stroke: none;
  opacity: 0;
  animation: vizPieReveal 0.8s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  transition: fill 0.3s ease;
}

.viz-func-area:hover {
  fill: rgba(108, 92, 231, 0.25);
}

.viz-func-asymptote {
  stroke: rgba(225, 112, 85, 0.5);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-func-label {
  fill: rgba(255, 255, 255, 0.75);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 500;
  font-style: italic;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

/* ============================================================
   17. Matrix Grid — cells, brackets, highlights, labels
   ============================================================ */
.viz-matrix-bracket {
  fill: none;
  stroke: #a29bfe;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  animation: vizFadeUp 0.5s ease-out forwards;
}

.viz-matrix-cell {
  fill: rgba(108, 92, 231, 0.08);
  stroke: rgba(108, 92, 231, 0.18);
  stroke-width: 1;
  rx: 3;
  opacity: 0;
  animation: vizDotAppear 0.35s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  transition: fill 0.2s ease, stroke 0.2s ease;
  cursor: default;
}

.viz-matrix-cell:hover {
  fill: rgba(108, 92, 231, 0.22);
  stroke: rgba(108, 92, 231, 0.5);
}

.viz-matrix-value {
  fill: rgba(255, 255, 255, 0.88);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.3s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  pointer-events: none;
}

.viz-matrix-highlight {
  fill: rgba(253, 203, 110, 0.18);
  stroke: rgba(253, 203, 110, 0.55);
  stroke-width: 1.5;
  rx: 3;
  animation: vizMatrixPulse 2s ease-in-out infinite;
}

.viz-matrix-label {
  fill: rgba(162, 155, 254, 0.85);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 600;
  font-style: italic;
  text-anchor: middle;
  opacity: 0;
  animation: vizFadeUp 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

/* ============================================================
   18. Expression Tree / Step-by-Step Expansion
   ============================================================ */
.viz-expr-step {
  rx: 8;
  fill: rgba(22, 33, 62, 0.9);
  stroke: rgba(108, 92, 231, 0.35);
  stroke-width: 1.5;
  opacity: 0;
  animation: vizDotAppear 0.4s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  transition: fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
  cursor: default;
}

.viz-expr-step:hover {
  fill: rgba(108, 92, 231, 0.18);
  stroke: rgba(108, 92, 231, 0.7);
  filter: drop-shadow(0 0 8px rgba(108, 92, 231, 0.35));
}

.viz-expr-connector {
  fill: none;
  stroke: rgba(162, 155, 254, 0.35);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: var(--edge-length, 100);
  stroke-dashoffset: var(--edge-length, 100);
  animation: vizDrawArc 0.5s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
}

.viz-expr-highlight {
  rx: 8;
  fill: rgba(253, 203, 110, 0.15);
  stroke: #FDCB6E;
  stroke-width: 2;
  animation: vizExprPulse 1.8s ease-in-out infinite;
  pointer-events: none;
}

.viz-expr-result {
  rx: 10;
  fill: rgba(0, 184, 148, 0.14);
  stroke: #00B894;
  stroke-width: 2;
  opacity: 0;
  animation: vizDotAppear 0.5s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  filter: drop-shadow(0 0 6px rgba(0, 184, 148, 0.35));
}

.viz-expr-text {
  fill: rgba(255, 255, 255, 0.88);
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.35s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  pointer-events: none;
}

.viz-expr-operator {
  fill: #FDCB6E;
  font-family: 'Rubik', 'Heebo', sans-serif;
  font-size: 18px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
  animation: vizFadeUp 0.35s ease-out forwards;
  animation-delay: calc(var(--delay, 0) * 1ms);
  pointer-events: none;
}

/* ============================================================
   19. Keyframe Animations
   ============================================================ */

/* Container entrance */
@keyframes vizFadeUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Number line arc draw-in */
@keyframes vizDrawArc {
  0% {
    stroke-dashoffset: var(--arc-length, 300);
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Dot on number line — gentle heartbeat */
@keyframes vizDotPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

/* Result dot — breathing glow */
@keyframes vizResultGlow {
  0%, 100% {
    filter: drop-shadow(0 0 4px #00B894);
  }
  50% {
    filter: drop-shadow(0 0 14px #00B894) drop-shadow(0 0 28px rgba(0, 184, 148, 0.4));
  }
}

/* Array / weight dots scale in */
@keyframes vizDotAppear {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pie segment fade and grow */
@keyframes vizPieReveal {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Bar model — grow from left (scaleX for SVG rects) */
@keyframes vizBarGrow {
  0% {
    transform: scaleX(0);
  }
  100% {
    transform: scaleX(1);
  }
}

/* Coordinate point — springy pop */
@keyframes vizPointBounce {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  60% {
    opacity: 1;
    transform: scale(1.25);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Place value block — drop from above */
@keyframes vizBlockDrop {
  0% {
    opacity: 0;
    transform: translateY(-30px);
  }
  80% {
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Balance scale beam tilt */
@keyframes vizBeamTilt {
  0% {
    transform: rotate(0deg);
  }
}

/* Exponent bar — grow from bottom up */
@keyframes vizExpGrow {
  0% {
    opacity: 0;
    transform: scaleY(0);
  }
  60% {
    opacity: 1;
    transform: scaleY(1.05);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* Matrix highlight cell — gentle pulse */
@keyframes vizMatrixPulse {
  0%, 100% {
    fill: rgba(253, 203, 110, 0.12);
    stroke: rgba(253, 203, 110, 0.45);
  }
  50% {
    fill: rgba(253, 203, 110, 0.26);
    stroke: rgba(253, 203, 110, 0.85);
  }
}

/* Expression tree highlighted step — breathing glow */
@keyframes vizExprPulse {
  0%, 100% {
    fill: rgba(253, 203, 110, 0.1);
    stroke: rgba(253, 203, 110, 0.65);
    filter: drop-shadow(0 0 4px rgba(253, 203, 110, 0.3));
  }
  50% {
    fill: rgba(253, 203, 110, 0.22);
    stroke: rgba(253, 203, 110, 1);
    filter: drop-shadow(0 0 10px rgba(253, 203, 110, 0.55));
  }
}

/* ============================================================
   20. Reduced Motion — honour OS accessibility preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .viz-container,
  .viz-container *,
  .viz-container *::before,
  .viz-container *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }

  /* Ensure elements that start at opacity:0 become visible */
  .viz-jump-arc,
  .viz-angle-arc,
  .viz-triangle-edge,
  .viz-circle-outline,
  .viz-trig-circle,
  .viz-trig-sin-line,
  .viz-trig-cos-line,
  .viz-trig-hyp-line,
  .viz-func-curve,
  .viz-func-tangent,
  .viz-expr-connector {
    stroke-dashoffset: 0;
  }
  .viz-array-dot,
  .viz-pie-segment,
  .viz-coord-point,
  .viz-scale-weight,
  .viz-block-drop,
  .viz-angle-label,
  .viz-triangle-side-label,
  .viz-triangle-angle-arc,
  .viz-triangle-right-mark,
  .viz-triangle-height,
  .viz-circle-radius,
  .viz-circle-diameter,
  .viz-circle-area-fill,
  .viz-circle-label,
  .viz-trig-label,
  .viz-exp-bar,
  .viz-exp-label,
  .viz-exp-expansion,
  .viz-func-area,
  .viz-func-asymptote,
  .viz-func-label,
  .viz-matrix-bracket,
  .viz-matrix-cell,
  .viz-matrix-value,
  .viz-matrix-label,
  .viz-expr-step,
  .viz-expr-result,
  .viz-expr-text,
  .viz-expr-operator {
    opacity: 1;
    transform: none;
  }
  .viz-bar-fill {
    transform: scaleX(1);
  }
  /* Suppress infinite animations to avoid flicker */
  .viz-matrix-highlight,
  .viz-expr-highlight {
    animation: none;
  }
}

/* ============================================================
   21. Mobile Responsive
   ============================================================ */
@media (max-width: 480px) {
  .viz-container {
    padding: 12px 8px;
    margin: 12px 0;
    border-radius: 12px;
    min-height: 140px;
    overflow: visible;
  }

  .viz-container svg {
    max-height: none;
    min-height: 180px;
    width: 100%;
    height: auto;
  }

  .viz-label {
    font-size: 0.8rem;
    margin-top: 8px;
  }

  .viz-tick-label,
  .viz-coord-tick-label,
  .viz-bar-label,
  .viz-place-value-heading,
  .viz-triangle-side-label,
  .viz-circle-label,
  .viz-trig-label,
  .viz-exp-expansion,
  .viz-func-label,
  .viz-matrix-value,
  .viz-matrix-label,
  .viz-expr-text {
    font-size: 9px;
  }

  .viz-pie-center-label {
    font-size: 14px;
  }

  /* Thinner strokes on small screens */
  .viz-angle-ray,
  .viz-angle-arc,
  .viz-triangle-edge,
  .viz-circle-outline,
  .viz-trig-sin-line,
  .viz-trig-cos-line,
  .viz-trig-hyp-line,
  .viz-func-curve {
    stroke-width: 2;
  }

  .viz-angle-label {
    font-size: 13px;
  }

  .viz-exp-label,
  .viz-expr-operator {
    font-size: 11px;
  }

  .viz-matrix-bracket {
    stroke-width: 2;
  }
}

/* Larger phones (375-480px) — slightly more space */
@media (min-width: 375px) and (max-width: 480px) {
  .viz-container svg {
    min-height: 200px;
  }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 768px) {
  .viz-container {
    padding: 20px 16px;
  }
  .viz-container svg {
    max-height: 320px;
  }
}

/* =============================================
   19. VIDEO TUTORIAL SECTION
   ============================================= */

.video-section {
  max-width: 740px;
  margin: 0 auto 24px;
  padding: 0 16px;
}

.video-card {
  background: linear-gradient(145deg, #16213e 0%, #1a1a2e 60%, #0f1729 100%);
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: 18px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.video-card:hover {
  border-color: rgba(108, 92, 231, 0.45);
  box-shadow: 0 6px 28px rgba(108, 92, 231, 0.12);
}

.video-card-open {
  border-color: rgba(108, 92, 231, 0.5);
  box-shadow: 0 8px 40px rgba(108, 92, 231, 0.15);
}

/* ---------- Collapsed: Thumbnail Preview ---------- */

.video-preview {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.video-preview:hover {
  transform: scale(1.005);
}

.video-preview:active {
  transform: scale(0.995);
}

.video-thumbnail-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.video-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease, filter 0.3s ease;
  filter: brightness(0.75);
}

.video-preview:hover .video-thumbnail {
  transform: scale(1.05);
  filter: brightness(0.6);
}

.video-thumbnail-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.35) 70%);
}

.video-play-btn {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s ease;
  opacity: 0.9;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.video-preview:hover .video-play-btn {
  transform: scale(1.12);
  opacity: 1;
}

.play-btn-bg {
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.video-preview:hover .play-btn-bg {
  opacity: 1;
}

.video-preview-info {
  padding: 16px 20px 18px;
}

.video-preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(108, 92, 231, 0.15);
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: 20px;
  padding: 4px 12px;
  margin-bottom: 8px;
}

.badge-icon {
  font-size: 10px;
  color: #6C5CE7;
  line-height: 1;
}

.badge-text {
  font-size: 11px;
  font-weight: 600;
  color: #a29bfe;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.video-preview-title {
  font-size: 16px;
  font-weight: 700;
  color: #e8e8f8;
  margin: 0 0 4px;
  line-height: 1.4;
  font-family: 'Heebo', 'Rubik', sans-serif;
}

.video-preview-cta {
  font-size: 13px;
  color: #6b6b8d;
  margin: 0;
  font-weight: 400;
}

/* ---------- Expanded: Video Player ---------- */

.video-player-wrapper {
  padding: 0;
}

.video-player-header {
  padding: 16px 20px 12px;
}

.video-player-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.video-player-title {
  font-size: 15px;
  font-weight: 600;
  color: #c8c8e8;
  margin: 0;
  font-family: 'Heebo', 'Rubik', sans-serif;
}

.video-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #8888aa;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.video-close-btn:hover {
  background: rgba(225, 112, 85, 0.15);
  border-color: rgba(225, 112, 85, 0.3);
  color: #E17055;
}

.video-responsive {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  margin: 0 16px;
  border-radius: 12px;
  background: #0a0a1a;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5),
              inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.video-responsive iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 12px;
}

.video-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px 16px;
  font-size: 12px;
  color: #6b6b8d;
}

.video-credit a {
  color: #a29bfe;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.video-credit a:hover {
  color: #6C5CE7;
}

.credit-icon {
  font-size: 14px;
}

/* Video section transitions */
.video-enter {
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.video-enter-start {
  opacity: 0;
  transform: translateY(-8px);
}
.video-enter-end {
  opacity: 1;
  transform: translateY(0);
}
.video-leave {
  transition: all 0.3s ease;
}
.video-leave-start {
  opacity: 1;
}
.video-leave-end {
  opacity: 0;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .video-section {
    padding: 0 8px;
    margin-bottom: 16px;
  }

  .video-card {
    border-radius: 14px;
  }

  .video-preview-info {
    padding: 12px 14px 14px;
  }

  .video-preview-title {
    font-size: 14px;
  }

  .video-preview-cta {
    font-size: 12px;
  }

  .video-player-header {
    padding: 12px 14px 8px;
  }

  .video-player-title {
    font-size: 13px;
  }

  .video-responsive {
    margin: 0 10px;
    border-radius: 8px;
  }

  .video-responsive iframe {
    border-radius: 8px;
  }

  .video-credit {
    padding: 10px 14px 12px;
  }
}
