/* ==========================================================================
   Tema 4 · Componentes propios del módulo (cajas didácticas, ejemplos con
   solución desplegable, mini-preguntas y simuladores). Usa los tokens de main.css.
   ========================================================================== */

.t4-tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-primary);
}

/* Cajas */
.t4-idea .t4-tag { color: #0B7285; }
.t4-conexion { background: #EEF0FA; border-left-color: var(--color-primary); }
.t4-ojo {
  background: #FDECEA;
  border-left: 4px solid var(--color-danger);
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.92rem;
}
.t4-ojo .t4-tag { color: var(--color-danger); }
.t4-ficha {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 0.93rem;
}
.t4-ficha ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.t4-ficha li { margin: 0.3rem 0; }
.t4-mapa ol { margin: 0.4rem 0 0; padding-left: 1.3rem; }
.t4-mapa li { margin: 0.35rem 0; }
.idea-box p:last-child, .t4-ojo p:last-child, .note-box p:last-child { margin-bottom: 0; }

/* Figuras */
.t4-fig { margin: 20px 0; text-align: center; }
.t4-fig img { width: 100%; max-width: 620px; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--color-border); background: #fff; }
.t4-fig figcaption { font-size: 0.82rem; color: var(--color-muted); margin: 8px auto 0; max-width: 620px; text-align: left; line-height: 1.45; }
.t4-fig--wide img, .t4-fig--wide figcaption { max-width: 860px; }

/* Tablas */
.t4-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 460px; }
.t4-table th, .t4-table td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; }
.t4-table th { background: #ECEFF8; color: var(--color-primary); font-family: var(--font-display); font-size: 0.82rem; }
.t4-table tr:last-child td { border-bottom: 0; }

/* Ecuaciones largas: scroll propio, nunca de la página */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* Ejemplos resueltos */
.t4-ejemplo {
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin: 12px 0;
  background: var(--color-surface);
}
.t4-ejemplo > p:first-child { color: var(--color-text); font-size: 0.97rem; }
.t4-sol-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: 0.88rem;
  color: #fff; background: var(--color-interactive);
  border: 0; border-radius: var(--radius-sm);
  padding: 9px 16px; cursor: pointer;
}
.t4-sol-btn:hover { filter: brightness(0.95); }
.t4-sol-btn:focus-visible, .t4-ctl input:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.t4-sol { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--color-border); }

/* Mini-preguntas al final de cada sección */
.t4-mini h3 { display: flex; align-items: center; gap: 8px; }

/* Navegación anterior / siguiente */
.t4-pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 32px; }
.t4-pager button {
  font-family: var(--font-display); font-weight: 700; font-size: 0.88rem;
  background: var(--color-surface); color: var(--color-primary);
  border: 1.5px solid var(--color-primary); border-radius: var(--radius-sm);
  padding: 9px 14px; cursor: pointer; max-width: 100%;
}
.t4-pager button:hover { background: #ECEFF8; }

/* Simuladores */
.t4-simcard { border: 1.5px solid var(--color-interactive); }
.t4-sim-title::before { content: "🧪 "; }
.t4-sim-intro { font-size: 0.93rem; }
.t4-sim-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
@media (min-width: 900px) { .t4-sim-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); } }
.t4-sim-ctrls { display: grid; gap: 12px; min-width: 0; }
.t4-ctl { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 8px; align-items: center; font-size: 0.88rem; }
.t4-ctl span { grid-column: 1 / -1; font-weight: 600; color: var(--color-primary); }
.t4-ctl input[type="range"] { width: 100%; accent-color: var(--color-interactive); }
.t4-ctl output { font-family: var(--font-mono); font-weight: 700; min-width: 4.5ch; text-align: right; }
.t4-ctl small { color: var(--color-muted); }
.t4-kvs { display: grid; gap: 6px; background: var(--color-bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.t4-kv { display: grid; grid-template-columns: 1fr auto 3.2em; gap: 8px; align-items: baseline; font-size: 0.86rem; }
.t4-kv strong { font-family: var(--font-mono); color: var(--color-primary); font-variant-numeric: tabular-nums; }
.t4-kv small { color: var(--color-muted); }
.t4-sim-note { font-size: 0.82rem; color: var(--color-muted); margin: 0; }
.t4-sim-plot { min-width: 0; background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 6px; }
.t4-sim-plot svg { width: 100%; height: auto; display: block; font-family: var(--font-body); }
.t4-axis { stroke: var(--color-text); stroke-width: 1.2; }
.t4-grid { stroke: var(--color-border); stroke-width: 1; }
.t4-tick { font-size: 10.5px; fill: var(--color-muted); }
.t4-lab { font-size: 12px; fill: var(--color-text); font-weight: 600; }
.t4-arealab { font-size: 13px; fill: var(--color-primary); font-weight: 700; }
.t4-area { fill: rgba(29, 30, 148, 0.14); stroke: none; }
.t4-curve { fill: none; stroke: var(--color-primary); stroke-width: 2.6; }
.t4-ref { fill: none; stroke-width: 1.4; stroke-dasharray: 5 4; }
.t4-ref-iso { stroke: var(--thermal-cool); }
.t4-ref-ad { stroke: var(--thermal-hot); }
.t4-pt { fill: var(--color-primary); }
.t4-bar-ind { fill: var(--color-primary); }
.t4-bar-cool { fill: var(--thermal-cool); }
.t4-bar-hot { fill: var(--thermal-hot); }

@media (max-width: 600px) {
  .t4-ejemplo { padding: 14px; }
  .t4-kv { grid-template-columns: 1fr auto 2.6em; font-size: 0.82rem; }
}
