/* =====================================================================
   HOW QUANTITIES COMBINE: UNDERSTANDING DATA (CLASS 9) — Maths Notes
   Figure wrappers, SVG styles, animated diagrams, proof 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.
   ===================================================================== */

.hq-fig { display: flex; flex-direction: column; align-items: center; margin: 22px auto; max-width: 500px; }
.hq-fig svg { display: block; width: 100%; height: auto; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; user-select: none; }
.hq-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; }

.hq-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 20px 0; }
.hq-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); }
.hq-card h4 { margin: 0 0 8px; font-size: 15.5px; font-weight: 700; color: #0f172a; }
.hq-card p { margin: 0 0 10px; font-size: 13.5px; color: #475569; line-height: 1.55; }
.hq-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; }

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

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

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

/* Average of averages: marker slides from the midpoint to the weighted mean */
.hq-mean-marker { animation: hqSlide 6s ease-in-out infinite; }
@keyframes hqSlide { 0%, 20% { transform: translateX(70px); } 55%, 100% { transform: translateX(0); } }

/* Mixtures: mixture glass fills up */
.hq-fill { transform-box: fill-box; transform-origin: bottom; animation: hqRise 6s ease-in-out infinite; }
@keyframes hqRise { 0%, 15% { transform: scaleY(0); } 60%, 100% { transform: scaleY(1); } }

/* Weighted mean: each value is repeated as many times as its weight */
.hq-groups { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; margin: 6px 0; font-size: 13px; font-weight: 600; color: #1e293b; text-align: center; }
.hq-dots { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }
.hq-dots i { width: 22px; height: 22px; border-radius: 50%; border: 1.8px solid #0f172a; background: var(--c); opacity: 0; animation: hqPop 7s ease infinite; animation-delay: calc(var(--i) * 0.3s); }
.hq-g1 { --c: #fef3c7; } .hq-g2 { --c: #bfdbfe; } .hq-g3 { --c: #bbf7d0; }
@keyframes hqPop { 0% { opacity: 0; transform: scale(0.3); } 8%, 85% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }

/* Stacked bars: segments grow in */
.hq-seg { transform-box: fill-box; transform-origin: left; animation: hqGrow 1.1s ease-out both; }
@keyframes hqGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Stacked bar to 100% stacked bar: bars stretch to full length */
.hq-bars { width: 100%; }
.hq-mode { position: relative; height: 2.6em; text-align: center; margin: 0 0 6px; font-size: 13px; color: #334155; }
.hq-mode b { position: absolute; left: 0; right: 0; top: 0; }
.hq-m1 { animation: hqL1 8s infinite; } .hq-m2 { animation: hqL2 8s infinite; }
@keyframes hqL1 { 0%, 40% { opacity: 1; } 50%, 90% { opacity: 0; } 100% { opacity: 1; } }
@keyframes hqL2 { 0%, 40% { opacity: 0; } 50%, 90% { opacity: 1; } 100% { opacity: 0; } }
.hq-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.hq-row em { width: 46px; font-style: normal; font-size: 12.5px; color: #64748b; }
.hq-lane { flex: 1; }
.hq-track { display: flex; height: 34px; border: 1.8px solid #0f172a; border-radius: 4px; overflow: hidden; width: var(--w); animation: hqStretch 8s ease-in-out infinite; }
.hq-track span { display: block; height: 100%; }
.hq-c1 { background: #fef3c7; } .hq-c2 { background: #bbf7d0; } .hq-c3 { background: #bfdbfe; }
.hq-track span + span { border-left: 1.8px solid #0f172a; }
@keyframes hqStretch { 0%, 35% { width: var(--w); } 55%, 85% { width: 100%; } 100% { width: var(--w); } }
.hq-legend { display: flex; gap: 16px; justify-content: center; font-size: 12.5px; color: #64748b; margin-top: 8px; }
.hq-legend i { display: inline-block; width: 11px; height: 11px; border: 1.5px solid #0f172a; margin-right: 5px; vertical-align: -1px; }

@media (prefers-reduced-motion: reduce) {
  .hq-mean-marker, .hq-fill, .hq-seg, .hq-dots i, .hq-track, .hq-m1, .hq-m2 { animation: none !important; }
  .hq-dots i { opacity: 1; }
  .hq-m2 { opacity: 0; }
}