/* ==========================================================================
   MathMaster – lygties sprendimo žingsnis po žingsnio grotuvas (stepsolver.js)
   ==========================================================================
   Viena kortelė (scena) + valdymo juosta po ja + taškeliai apačioje – ta
   pati struktūra, kaip teorijos naršymo juostoje (`.theory-nav`), kad
   komponentas atrodytų kaip natūrali svetainės dalis, o ne svetimas intarpas.
   ========================================================================== */

.ssv-host {
  display: block;
  margin: 18px 0 4px;
  outline: none;
}

.ssv-host:focus-visible .ssv-card {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.ssv-card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}

.ssv-progress {
  height: 3px;
  background: var(--track);
}

.ssv-progress-fill {
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  background: var(--primary);
}

/* ------------------------------ Grafikas ---------------------------------
   Neprivalomas (`opts.graph.svg`) – kai algoritmas nuskaito reikšmes iš
   grafiko, taškai/linijos jame turi būti IŠ TIKRŲJŲ matomi, o ne vien
   suminėti tekste. Elementai su `data-from-step` atsiranda kaupiamai,
   grotuvui pasiekus atitinkamą žingsnį – žr. stepsolver.js `renderStep`. */
.ssv-graph {
  padding: 16px 16px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.ssv-graph svg { width: 100%; max-width: 480px; height: auto; }
.ssv-graph [data-from-step] { opacity: 0; transition: opacity 0.45s ease; }
.ssv-graph [data-from-step].ssv-graph-show { opacity: 1; }

.ssv-g-curve { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.ssv-g-axis { stroke: var(--muted); stroke-width: 1.2; }
.ssv-g-guide { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.7; }
.ssv-g-point { fill: var(--primary); stroke: var(--card); stroke-width: 2; }
.ssv-g-label { fill: var(--text-2); font-size: 12px; font-family: 'Inter', sans-serif; }
.ssv-g-projection { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.62; }
.ssv-g-x-tick { stroke: var(--muted); stroke-width: 1.5; }
.ssv-g-reference { fill: var(--card); stroke: #F43F5E; stroke-width: 2; }

/* D (vidurio linija), A (amplitudė), T (periodas) ir fazės poslinkis – kiekvienas
   savo spalva, kad ir baigus visus žingsnius liktų aišku, kuri linija ką reiškia. */
.ssv-g-guide-d { fill: none; stroke: #A78BFA; stroke-width: 1.4; stroke-dasharray: 5 3; }
.ssv-g-label-d { fill: #A78BFA; font-size: 12px; font-weight: 700; font-family: 'Inter', sans-serif; }
.ssv-g-bracket-a { stroke: #22C55E; stroke-width: 1.6; }
.ssv-g-label-a { fill: #22C55E; font-size: 13px; font-weight: 800; font-family: 'Inter', sans-serif; }
.ssv-g-witness-t { stroke: #F59E0B; stroke-width: 1.1; stroke-dasharray: 3 3; opacity: 0.9; }
.ssv-g-bracket-t { stroke: #F59E0B; stroke-width: 1.6; }
.ssv-g-label-t { fill: #F59E0B; font-size: 13px; font-weight: 800; font-family: 'Inter', sans-serif; }
.ssv-g-witness-phase { stroke: #F43F5E; stroke-width: 1.1; stroke-dasharray: 3 3; opacity: 0.9; }
.ssv-g-arrow-phase { stroke: #F43F5E; stroke-width: 1.8; }
.ssv-g-label-phase { fill: #F43F5E; font-size: 12px; font-weight: 700; font-family: 'Inter', sans-serif; }

.ssv-g-label,
.ssv-g-label-d,
.ssv-g-label-a,
.ssv-g-label-t,
.ssv-g-label-phase {
  paint-order: stroke fill;
  stroke: var(--card);
  stroke-width: 3px;
  stroke-linejoin: round;
}

@media (max-width: 480px) {
  .ssv-graph { padding: 12px 10px 4px; }
}

.ssv-body {
  padding: 20px 22px 22px;
}

.ssv-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ssv-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-50);
}

.ssv-eq-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ssv-title {
  margin: 12px 0 0;
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text);
}

.ssv-eq {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  margin-top: 14px;
  padding: 6px 4px;
  overflow-x: auto;
}

.ssv-eq .katex { font-size: 1.5em; }
.ssv-eq .katex-display { margin: 0; }

/* `\textcolor{...}` paženklintus narius `dazyti()` (stepsolver.js) pažymi
   šia klase pagal spalvą – ČIA jiems pridedamas fonas ir pulsavimas, o ne
   KaTeX'e (kad nereikėtų `\htmlClass` ir `trust:true`). */
.ssv-hl {
  padding: 0.05em 0.16em;
  margin: 0 0.01em;
  border-radius: 0.32em;
}
.ssv-hl-r { background: color-mix(in srgb, #EF4444 16%, transparent); animation: ssvPulseR 1.7s ease-in-out 0.15s infinite; }
.ssv-hl-b { background: color-mix(in srgb, #4F46E5 14%, transparent); }
.ssv-hl-g { background: color-mix(in srgb, #22C55E 14%, transparent); }

@keyframes ssvPulseR {
  0%, 100% { background: color-mix(in srgb, #EF4444 16%, transparent); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  50% { background: color-mix(in srgb, #EF4444 30%, transparent); box-shadow: 0 0 14px rgba(239, 68, 68, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  .ssv-hl-r { animation: none; }
}

.ssv-note {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.96rem;
  line-height: 1.6;
  color: var(--text-2);
}
.ssv-note:empty,
.ssv-note[hidden] { display: none; }

.ssv-rule {
  border-top: 1px solid var(--border);
  padding: 12px 22px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

/* ------------------------------- Valdymas -------------------------------- */

.ssv-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 14px;
}

.ssv-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ssv-icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ssv-icon-btn:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.ssv-icon-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.ssv-icon-repeat.is-on {
  color: var(--primary);
  background: var(--primary-50);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.ssv-play {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 0 var(--primary-600);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ssv-play:hover { transform: translateY(-1px); }
.ssv-play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-600); }
.ssv-play:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.ssv-play svg { margin-left: 1px; }
.ssv-play.is-playing svg { margin-left: 0; }

.ssv-speed {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.ssv-speed-ic { font-size: 0.85rem; opacity: 0.75; }

.ssv-range {
  width: 120px;
  accent-color: var(--primary);
  cursor: pointer;
}

.ssv-speed-out {
  min-width: 6.4em;
  text-align: right;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* -------------------------------- Taškeliai ------------------------------ */

.ssv-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
}

.ssv-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  background: var(--track);
  border: 1px solid var(--border-strong);
  transition: background 0.15s ease, transform 0.15s ease, width 0.15s ease, border-radius 0.15s ease;
}
.ssv-dot:hover { background: var(--border-strong); transform: scale(1.2); }
.ssv-dot.active { width: 26px; border-radius: 6px; background: var(--primary); border-color: var(--primary); }

@media (max-width: 480px) {
  .ssv-body { padding: 16px 16px 18px; }
  .ssv-title { font-size: 1.05rem; }
  .ssv-range { width: 84px; }
  .ssv-speed-out { display: none; }
}
