/* ═══════════════════════════════════════════════════════════════════════════
   Laboratorio del grafo (lab-grafo.html) — sandbox interactivo del motor de la Wiki.
   Reutiliza los tokens de styles.css.
   ═══════════════════════════════════════════════════════════════════════════ */

.lab-intro {
  margin: 0 0 28px;
  padding: 0 2px;
}
.lab-intro h1 {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 1.9rem; font-weight: 800; line-height: 1.15;
  color: var(--text); margin: 0 0 12px;
}
.lab-intro p {
  font-family: 'Source Serif 4', serif;
  font-size: 1rem; line-height: 1.6; color: var(--muted); margin: 0 0 12px;
}
.lab-intro code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.85em;
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}

/* ── Sandbox: controles + grafo ──────────────────────────────────────────── */
.lab-sandbox {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  height: 70vh; min-height: 520px;
  margin-bottom: 28px;
}
.lab-panel {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  padding: 16px; overflow-y: auto;
}
.lab-panel-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.lab-panel-actions .lab-btn { flex: 1; }   /* "Regenerar" ocupa todo el panel */
.lab-btn {
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  transition: border-color .15s, background .15s;
}
.lab-btn:hover { border-color: var(--accent); }
.lab-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.lab-group { margin-bottom: 18px; }
.lab-group-title {
  font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.lab-control { display: block; margin-bottom: 12px; }
.lab-control-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: 'Inter', sans-serif; font-size: 12.5px; color: var(--text); margin-bottom: 5px;
}
.lab-control-head output {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 500;
  color: var(--accent);
}
.lab-control input[type="range"] {
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 999px; outline: none; cursor: pointer;
}
.lab-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--surface);
}
.lab-control input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 2px solid var(--surface);
}

.lab-canvas {
  position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
}
#labGraph { position: absolute; inset: 0; }

/* ── Receta copiable ─────────────────────────────────────────────────────── */
.lab-recipe-wrap {
  max-width: 900px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden;
}
.lab-recipe-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.lab-recipe-head h2 {
  font-family: 'Hanken Grotesk', sans-serif; font-size: 1rem; font-weight: 700;
  color: var(--text); margin: 0;
}
.lab-recipe {
  margin: 0; padding: 16px; overflow-x: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px; line-height: 1.55;
  color: var(--muted); white-space: pre-wrap;
}

@media (max-width: 820px) {
  .lab-list { grid-template-columns: 1fr; }
  .lab-sandbox { grid-template-columns: 1fr; height: auto; }
  .lab-canvas { height: 60vh; min-height: 420px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   lab.html — índice del área lab
   ═══════════════════════════════════════════════════════════════════════════ */

.lab-loading {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--muted);
}

.lab-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
  margin-bottom: 40px;
}

/* ── Card: viz encima, texto abajo ──────────────────────────────────────────── */
.lab-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transition: border-color .15s;
}

.lab-card:hover { border-color: var(--accent); }

/* El panel visual reusa el lenguaje .cmzo-viz pero sin borde propio */
.lab-card-viz {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.lab-card-viz-body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
  padding: 16px 20px;
  min-height: 155px;
}

/* Texto inferior */
.lab-card-foot {
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lab-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lab-card-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--on-accent);
  background: var(--accent);
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.lab-card-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

.lab-card-title {
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin: 0;
}

.lab-card-title a { color: inherit; text-decoration: none; }
.lab-card-title a:hover { color: var(--accent); }

.lab-card-summary {
  font-family: 'Source Serif 4', serif;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
  flex: 1;
}

.lab-card-cta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-top: 2px;
  align-self: flex-start;
}

.lab-card-cta:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════════════
   Laboratorio de fractales (lab-fractales.html)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Sandbox: canvas + panel info ───────────────────────────────────────────── */
.frac-sandbox {
  display: grid;
  grid-template-columns: 58fr 42fr;
  gap: 16px;
  height: 65vh;
  min-height: 480px;
  margin-bottom: 16px;
}

.frac-canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
}

#fracCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.frac-info {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ── Gramática ──────────────────────────────────────────────────────────────── */
.frac-grammar {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.frac-grammar-row {
  display: grid;
  grid-template-columns: 56px 18px 1fr;
  align-items: baseline;
  gap: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

.frac-grammar-key {
  font-weight: 600;
  color: var(--accent);
}

.frac-grammar-arrow {
  color: var(--muted);
  text-align: center;
}

.frac-grammar-code {
  color: var(--text);
  word-break: break-all;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ── Iteración ──────────────────────────────────────────────────────────────── */
.frac-iter {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.frac-iter-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 8px;
  align-items: baseline;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.45;
}

.frac-iter-n {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

.frac-iter-str { color: var(--text); word-break: break-all; }
.frac-iter-str--long { color: var(--muted); font-style: italic; }
.frac-iter-str--current { color: var(--accent); font-weight: 600; }

/* ── Dimensión ──────────────────────────────────────────────────────────────── */
.frac-dim-formula {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.frac-dim-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 32px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 6px;
}

.frac-dim-desc {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Controles ──────────────────────────────────────────────────────────────── */
.frac-controls {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 28px;
}

.frac-selector {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  min-width: 150px;
  gap: 2px;
}

.frac-selector-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.frac-selector-btns { display: flex; flex-direction: column; gap: 2px; }

.frac-selector-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: color .15s, background .15s, border-color .15s;
}

.frac-selector-btn:hover { color: var(--text); background: var(--bg); }

.frac-selector-btn.is-active {
  background: var(--accent);
  color: var(--on-accent);
}

.frac-sliders {
  display: flex;
  flex: 1;
  align-items: center;
  flex-wrap: wrap;
}

.frac-slider-group {
  flex: 1;
  min-width: 160px;
  padding: 14px 20px;
  border-right: 1px solid var(--border);
}

.frac-slider-group:last-child { border-right: none; }

.frac-color-group { display: flex; flex-direction: column; gap: 0; }

.frac-color-pills { display: flex; gap: 6px; margin-top: 2px; }

.frac-color-pill {
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}

.frac-color-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .frac-sandbox { grid-template-columns: 1fr; height: auto; }
  .frac-canvas-wrap { height: 65vw; min-height: 280px; }
  .frac-controls { flex-direction: column; }
  .frac-selector {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-width: 0;
    padding: 10px 14px;
    gap: 6px;
    align-items: center;
  }
  .frac-selector-label { margin-bottom: 0; }
  .frac-selector-btns { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .frac-slider-group { min-width: 140px; border-right: none; padding: 10px 16px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   lab-editorial.html — maqueta viva de la tipografía de los posts
   El espécimen (.ed-spec) usa una COPIA parametrizada de los estilos de
   .article-content: variables --ed-* que setean los diales (editorial-lab.js).
   ═══════════════════════════════════════════════════════════════════════════ */

.ed-sandbox { height: auto; min-height: 0; align-items: start; }
.ed-sandbox .lab-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); }
.ed-stage {
  border: 1px solid var(--border); border-radius: 12px; overflow: auto;
  background-color: var(--bg);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
  padding: 40px 24px; max-height: 78vh;
}
.ed-spec-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 48px 40px; }

.ed-spec {
  max-width: var(--ed-measure, 720px);
  margin: 0 auto; min-width: 0;
}
/* Guías del ancho de caja (dial «mostrar bordes») */
.ed-spec--box { position: relative; }
.ed-spec--box::before, .ed-spec--box::after {
  content: ''; position: absolute; top: -24px; bottom: -24px; width: 0;
  border-left: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}
.ed-spec--box::before { left: -12px; }
.ed-spec--box::after { right: -12px; }

/* ── Copia parametrizada de la tipografía editorial ── */
.ed-spec p {
  margin: 0 0 var(--ed-pspace, 26px) 0;
  font-family: var(--ed-body-font, 'Source Serif 4', Georgia, serif);
  font-size: var(--ed-body-size, 18px);
  line-height: var(--ed-lh, 1.8);
  color: var(--text);
}
.ed-spec a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.ed-spec mark { background: color-mix(in srgb, var(--accent) 18%, transparent); color: inherit; padding: 0 2px; }
.ed-spec h2 {
  margin: var(--ed-h2-top, 48px) 0 20px 0;
  font-family: var(--ed-display-font, 'Hanken Grotesk', sans-serif);
  font-size: var(--ed-h2-size, 42px);
  font-weight: var(--ed-h2-weight, 700);
  line-height: 1.2; letter-spacing: -0.02em; color: var(--text);
}
.ed-spec h2:first-child { margin-top: 0; }
.ed-spec h3 {
  margin: 32px 0 10px 0;
  font-family: var(--ed-display-font, 'Hanken Grotesk', sans-serif);
  font-size: var(--ed-h3-size, 28px);
  font-weight: 600; line-height: 1.3; letter-spacing: -0.02em; color: var(--text);
}
.ed-spec ul, .ed-spec ol {
  margin: 16px 0 24px 0; padding-left: 24px;
  font-family: var(--ed-body-font, 'Source Serif 4', Georgia, serif);
  font-size: var(--ed-body-size, 18px);
  line-height: var(--ed-lh, 1.8); color: var(--text);
}
.ed-spec li { margin: 6px 0; }
.ed-spec blockquote {
  margin: 24px 0; padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent);
}
.ed-spec blockquote p { font-style: italic; color: var(--muted); margin-bottom: 0; }
.ed-spec figure { margin: var(--ed-fig-my, 44px) 0; text-align: center; }
.ed-spec figure img {
  max-width: 100%; height: auto;
  border-radius: var(--ed-fig-radius, 2px);
  border: 1px solid var(--border); background: var(--bg);
}
.ed-spec figcaption {
  margin-top: 8px; font-size: var(--ed-cap-size, 13px);
  color: var(--muted); font-family: 'Inter', sans-serif; line-height: 1.4; font-style: italic;
}
.ed-spec .image-gallery {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin: var(--ed-fig-my, 44px) 0;
}
.ed-spec .image-gallery figure { margin: 0; }
.ed-spec .table-wrapper { margin: 24px 0; overflow-x: auto; }
.ed-spec table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 14px; }
.ed-spec th {
  text-align: left; font-family: var(--mono); font-weight: 500; font-size: 10.5px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  padding: 9px 14px; background: var(--bg);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.ed-spec td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); line-height: 1.5; }
.ed-spec .mermaid { margin: 32px 0; max-width: 100%; overflow-x: auto; display: flex; justify-content: center; }

/* Controles extra del panel (select y checkbox) */
.ed-select {
  width: 100%; margin-top: 4px; padding: 5px 8px;
  font-family: var(--mono); font-size: 12px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
}
.ed-check { display: flex; align-items: center; gap: 8px; font-family: var(--sans); font-size: 12.5px; color: var(--muted); cursor: pointer; }
.ed-check input { accent-color: var(--accent); }

@media (max-width: 900px) {
  .ed-sandbox .lab-panel { position: static; max-height: none; }
  .ed-stage { max-height: none; padding: 20px 12px; }
  .ed-spec-wrap { padding: 24px 16px; }
}

/* Modo amplio del laboratorio editorial: la maqueta ocupa toda la pantalla */
.ed-sandbox--full {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg); margin: 0; padding: 16px;
  grid-template-columns: 280px 1fr; gap: 16px;
}
.ed-sandbox--full .lab-panel { position: static; max-height: calc(100vh - 32px); }
.ed-sandbox--full .ed-stage { max-height: none; height: calc(100vh - 32px); }
@media (max-width: 900px) {
  .ed-sandbox--full { grid-template-columns: 1fr; overflow-y: auto; }
  .ed-sandbox--full .lab-panel { max-height: none; }
  .ed-sandbox--full .ed-stage { height: auto; }
}

/* Aviso: el ancho pedido no entra en el área visible */
.ed-hint {
  position: sticky; top: 0; z-index: 5;
  display: block; margin: 0 auto 16px; padding: 6px 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em;
  color: var(--on-accent); background: var(--accent);
  border: none; border-radius: 999px; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}
.ed-hint:hover { opacity: 0.9; }
