/* ============================================================
 * theme.css — TEMA Estequiometría (capa LIBRE).
 * Prefijo: est-
 * Solo estilos del tema. NO redefinir clases guia-*.
 * Variables de marca disponibles: --guia-ink / --guia-orange / --guia-navy
 * / --guia-green / --guia-deep / --guia-cream / --guia-line / --guia-muted.
 * No hardcodear hex: usa var(--guia-*).
 * Pisos: lectura ≥17px · apoyo ≥15px · etiquetas MAYÚS ≥13px.
 * ============================================================ */

/* ── Leyenda de color del tema ── */
.est-leyenda {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
  font-size: 15px;
}
.est-leyenda-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 15px;
}
.est-leyenda-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.est-leyenda-dot.reactivo  { background: var(--guia-orange); }
.est-leyenda-dot.producto  { background: var(--guia-navy); }
.est-leyenda-dot.limitante { background: #B91C1C; }

/* ── Mapa de conversiones (widget M6) ── */
.est-mapa-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
}
.est-mapa-svg {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-width: 280px;
}

/* Nodos del mapa */
.est-nodo {
  cursor: pointer;
  transition: filter 0.2s;
}
.est-nodo:hover .est-nodo-rect,
.est-nodo.activo .est-nodo-rect {
  filter: drop-shadow(0 0 6px currentColor);
}
.est-nodo-rect {
  rx: 8;
  ry: 8;
  transition: opacity 0.2s;
}
.est-nodo-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Flechas del mapa */
.est-flecha {
  cursor: pointer;
  transition: opacity 0.2s;
}
.est-flecha:hover .est-flecha-bg,
.est-flecha.activa .est-flecha-bg {
  opacity: 1;
}
.est-flecha-bg {
  opacity: 0.12;
  transition: opacity 0.2s;
}
.est-flecha-path {
  stroke-width: 2.5;
  fill: none;
  marker-end: url(#arrowhead);
}

/* Etiqueta de operación activa */
.est-label-op {
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--guia-cream);
  border: 1px solid var(--guia-line);
  font-size: 17px;
  color: var(--guia-ink);
  margin: 0.5rem 0 1rem;
  text-align: center;
}
.est-label-op:empty::before {
  content: "Toca una flecha para ver la operación";
  color: var(--guia-muted);
  font-size: 15px;
}

/* ── Simulación de reactivo limitante (widget M7) ── */
.est-sim-wrap {
  width: 100%;
  margin: 1rem 0;
}
.est-sim-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 420px) {
  .est-sim-grid { grid-template-columns: 1fr; }
}
.est-sim-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.est-sim-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--guia-muted);
}
.est-sim-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.est-sim-input input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--guia-orange);
}
.est-sim-val {
  font-size: 15px;
  min-width: 3.5rem;
  text-align: right;
  color: var(--guia-ink);
}

/* Barras visuales */
.est-barra-track {
  height: 20px;
  border-radius: 4px;
  background: var(--guia-line);
  overflow: hidden;
  position: relative;
}
.est-barra-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.est-barra-fill.reactivo  { background: var(--guia-orange); }
.est-barra-fill.producto  { background: var(--guia-navy); }

/* Resultado de la simulación */
.est-sim-resultado {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--guia-cream);
  border: 1px solid var(--guia-line);
  font-size: 15px;
}
@media (max-width: 420px) {
  .est-sim-resultado { grid-template-columns: 1fr; }
}
.est-sim-tag {
  font-size: 13px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--guia-muted);
  margin-bottom: 0.25rem;
}
.est-limitante-val {
  font-size: 17px;
  font-weight: 700;
  color: #B91C1C;
}
.est-producto-val {
  font-size: 17px;
  font-weight: 700;
  color: var(--guia-navy);
}

/* ── Árbol de decisión (widget M10) ── */
.est-arbol-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
}
.est-arbol {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.est-arbol-paso {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.5rem 0.75rem;
  align-items: start;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--guia-cream);
  border: 1px solid var(--guia-line);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.est-arbol-paso:hover,
.est-arbol-paso.activo {
  border-color: var(--guia-orange);
  background: #fff8f4;
}
.est-arbol-n {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--guia-orange);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.est-arbol-pregunta {
  font-size: 17px;
  font-weight: 600;
  color: var(--guia-ink);
  margin-bottom: 0.25rem;
}
.est-arbol-respuestas {
  grid-column: 2;
  font-size: 15px;
  color: var(--guia-muted);
  display: none;
  margin-top: 0.25rem;
}
.est-arbol-paso.activo .est-arbol-respuestas {
  display: block;
}
.est-arbol-respuestas .si {
  color: var(--guia-green);
  font-weight: 600;
}
.est-arbol-respuestas .no {
  color: var(--guia-orange);
  font-weight: 600;
}

/* ── Visual estático: escala del mol (M2) ── */
.est-escala-svg {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0.75rem auto;
}

/* ── Visual estático: razones molares anotadas (M5) ── */
.est-razones-svg {
  display: block;
  width: 100%;
  max-width: 500px;
  margin: 0.75rem auto;
}

/* ── Visual estático: barras de rendimiento (M9) ── */
.est-barras-svg {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 0.75rem auto;
}

/* ── Visual estático: balance de ecuación (M4) ── */
.est-balance-svg {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 0.75rem auto;
}

/* ── Visual: analogía brownies (M7) ── */
.est-brownies-svg {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 0.75rem auto;
}

/* ── Botones de flecha (mapa de conversiones) ── */
.est-flecha-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.est-flecha-btn:hover,
.est-flecha-btn.est-flecha-active {
  background: var(--guia-cream, #F0F4F8);
  outline: 2px solid var(--guia-orange, #C75D08);
}
.est-flecha-central {
  /* la flecha central (razón estequiométrica) se destaca */
  position: relative;
}

/* Panel de operación activa (est-label-op) */
.est-label-op:not(:empty) {
  padding: 0.75rem 1rem;
}

@media print {
  .est-mapa-wrap,
  .est-sim-wrap,
  .est-arbol-wrap { display: none !important; }
}
