/* ============================================================
 * theme.css — TEMA de la guía de ÁREAS Y PERÍMETROS (capa LIBRE).
 * Leyenda (perímetro=borde / área=relleno), dibujo de figuras por SVG,
 * comparativas, y los 4 widgets por toque (figlab / decisor / combinada /
 * tabla). Andamiaje en assets/guia-components.css; variables --guia-*.
 * Pisos de letra: lectura ≥17px · apoyo ≥15px · etiquetas ≥13px.
 * ============================================================ */

/* ===== Reaseguro de longitud en el hero ===== */
.guia-reassure { font-size: 15px; line-height: 1.5; color: var(--guia-muted); margin: 2px 0 0; }

/* ===== Leyenda de color (borde vs relleno) ===== */
.ap-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; background: #fff; border: 1.5px solid var(--guia-line); border-radius: 12px; padding: 10px 14px; font-size: 15px; font-weight: 600; }
.ap-legend .it { display: flex; gap: 8px; align-items: center; }
.ap-legend .it b { font-weight: 800; }
.ap-legend .sw { width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto; }
.ap-legend .sw.perim { background: #fff; border: 3px solid var(--guia-deep); }
.ap-legend .sw.area { background: rgba(40, 56, 145, .20); border: 2px solid var(--guia-navy); }

/* ===== Dibujo de la figura (SVG estático) ===== */
.ap-visual { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 2px 0; }
.ap-visual .vcap { font-size: 15px; font-weight: 700; color: var(--guia-muted); text-align: center; max-width: 44ch; }
/* Ancho RESUELTO (viewBox + max-width): el dibujo nunca colapsa a "astilla". */
.ap-svg { width: 100%; max-width: 260px; height: auto; display: block; }

/* Comparativa de dos figuras lado a lado */
.ap-pair { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.ap-pair figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ap-pair .ap-svg { max-width: 170px; }
.ap-pair figcaption { font-size: 14px; font-weight: 700; color: var(--guia-muted); text-align: center; max-width: 22ch; }

/* Dibujo dentro de un ejercicio (guiado/serie): más compacto */
.guia-pitem .ap-visual { align-items: flex-start; margin: 8px 0 4px; }
.guia-pitem .ap-visual .vcap { text-align: left; font-size: 14px; }
.guia-pitem .ap-svg { max-width: 180px; }
.guia-serie-grid .ap-svg { max-width: 156px; }
.guia-pitem .ap-pair .ap-svg, .guia-serie-grid .ap-pair .ap-svg { max-width: 130px; }

/* ===== Base común de widgets ===== */
.ap-lab, .ap-dec, .ap-comb { display: grid; gap: 12px; padding: 16px; border: 2px solid var(--guia-ink); border-radius: 14px; background: var(--guia-cream); }
.ap-lab-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-flag { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #fff; background: var(--guia-orange); border: 2px solid var(--guia-ink); border-radius: 999px; padding: 3px 11px; }
.ap-inst { font-size: 15px; font-weight: 700; color: var(--guia-deep); }
.ap-stage { text-align: center; }
.ap-lab-svg { width: 100%; max-width: 300px; margin: 0 auto; }

/* Botones tipo sticker (mismo lenguaje que el motor) */
.ap-btn { font: inherit; font-weight: 800; font-size: 16px; min-height: 44px; padding: 9px 16px; border: 2px solid var(--guia-ink); border-radius: 10px; background: #fff; color: var(--guia-ink); cursor: pointer; box-shadow: 2px 2px 0 var(--guia-ink); transition: transform .1s, box-shadow .1s; }
.ap-btn.small { font-size: 15px; padding: 8px 12px; min-height: 40px; margin-left: 8px; }
.ap-btn.ghost { background: var(--guia-cream); }
.ap-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--guia-ink); }
.ap-btn:active { transform: translate(0, 0); box-shadow: 1px 1px 0 var(--guia-ink); }

/* ===== Conmutador Ver perímetro / Ver área ===== */
.ap-show { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ap-show-btn { font: inherit; font-weight: 800; font-size: 15px; min-height: 44px; padding: 9px 14px; border: 2px solid var(--guia-line); border-radius: 999px; background: #fff; color: var(--guia-muted); cursor: pointer; transition: all .12s; }
.ap-show-btn.perim.on { color: #fff; background: var(--guia-deep); border-color: var(--guia-ink); }
.ap-show-btn.area.on { color: #fff; background: var(--guia-navy); border-color: var(--guia-ink); }

/* ===== figlab: pestañas, lectura viva, controles ===== */
.ap-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.ap-tab { font: inherit; font-weight: 800; font-size: 15px; min-height: 44px; padding: 8px 14px; border: 2px solid var(--guia-line); border-radius: 10px; background: #fff; color: var(--guia-deep); cursor: pointer; }
.ap-tab.on { background: var(--guia-ink); color: #fff; border-color: var(--guia-ink); }

.ap-read { display: grid; gap: 8px; }
.ap-read-perim, .ap-read-area { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--guia-line); background: #fff; opacity: .55; transition: opacity .12s, border-color .12s; }
.ap-read-perim.on { opacity: 1; border-color: var(--guia-deep); background: rgba(199, 93, 8, .06); }
.ap-read-area.on { opacity: 1; border-color: var(--guia-navy); background: rgba(40, 56, 145, .06); }
.ap-rl { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.ap-read-perim .ap-rl { color: var(--guia-deep); }
.ap-read-area .ap-rl { color: var(--guia-navy); }
.ap-rv { font-size: 16px; font-weight: 600; color: var(--guia-ink); }
.ap-rv b { font-weight: 800; font-size: 18px; }

.ap-ctrls { display: grid; gap: 10px; }
.ap-ctrl { display: grid; gap: 4px; }
.ap-ctrl-name { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--guia-muted); }
.ap-ctrl-row { display: flex; align-items: center; gap: 10px; }
.ap-step { font: inherit; font-weight: 800; font-size: 20px; width: 44px; height: 44px; flex: 0 0 auto; border: 2px solid var(--guia-ink); border-radius: 10px; background: #fff; color: var(--guia-ink); cursor: pointer; box-shadow: 2px 2px 0 var(--guia-ink); }
.ap-step:active { transform: translate(0, 0); box-shadow: 1px 1px 0 var(--guia-ink); }
.ap-range { flex: 1 1 auto; min-width: 80px; height: 30px; accent-color: var(--guia-orange); cursor: pointer; }
.ap-ctrl-val { font-size: 17px; font-weight: 800; color: var(--guia-ink); min-width: 2ch; text-align: center; }

/* ===== decisor ===== */
.ap-dec-prog { font-size: 14px; font-weight: 700; color: var(--guia-muted); margin: 0; }
.ap-dec-card { display: grid; gap: 10px; justify-items: center; }
.ap-dec-fig { width: 100%; text-align: center; }
.ap-dec-fig .ap-svg { max-width: 220px; margin: 0 auto; }
.ap-dec-q { font-size: 17px; font-weight: 700; color: var(--guia-ink); text-align: center; margin: 0; max-width: 40ch; }
.ap-dec-opts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.ap-dec-opt { font: inherit; font-weight: 800; font-size: 16px; min-height: 44px; padding: 10px 16px; border: 2px solid var(--guia-ink); border-radius: 12px; background: #fff; color: var(--guia-ink); cursor: pointer; box-shadow: 2px 2px 0 var(--guia-ink); }
.ap-dec-opt.perim { border-color: var(--guia-deep); }
.ap-dec-opt.area { border-color: var(--guia-navy); }
.ap-dec-opt.right { background: var(--guia-green); color: #fff; border-color: var(--guia-ink); }
.ap-dec-opt.wrong { background: #A01243; color: #fff; border-color: var(--guia-ink); }
.ap-dec-opt:disabled { cursor: default; opacity: 1; }
.ap-dec-fb { display: none; font-size: 16px; line-height: 1.5; font-weight: 600; padding: 10px 14px; border-radius: 12px; width: 100%; }
.ap-dec-fb.show { display: block; }
.ap-dec-fb.ok { background: rgba(28, 122, 58, .12); color: #14532d; }
.ap-dec-fb.miss { background: rgba(160, 18, 67, .10); color: #7a0f33; }
.ap-dec-done { font-size: 17px; font-weight: 700; color: var(--guia-green); text-align: center; margin: 0; }

/* ===== combinada ===== */
.ap-comb-note { display: none; font-size: 16px; line-height: 1.5; font-weight: 600; padding: 10px 14px; border-radius: 12px; margin: 0; }
.ap-comb-note.show { display: block; }
.ap-comb-note.perim { background: rgba(199, 93, 8, .08); color: #7a3a06; }
.ap-comb-note.area { background: rgba(40, 56, 145, .08); color: #1f2a66; }
.ap-comb-note b { font-weight: 800; }

/* ===== tabla de fórmulas ===== */
.ap-tabla { overflow-x: auto; border: 2px solid var(--guia-line); border-radius: 12px; background: #fff; }
.ap-tabla table { width: 100%; border-collapse: collapse; min-width: 320px; }
.ap-tabla th, .ap-tabla td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--guia-line); font-size: 16px; }
.ap-tabla thead th { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--guia-muted); background: var(--guia-cream); }
.ap-tabla thead th.perim { color: var(--guia-deep); }
.ap-tabla thead th.area { color: var(--guia-navy); }
.ap-tabla tbody th { font-weight: 800; color: var(--guia-ink); }
.ap-tabla tbody tr:last-child th, .ap-tabla tbody tr:last-child td { border-bottom: none; }
/* Regla CSS+KaTeX: el badge/fondo solo en > span hijo directo (aquí no hay pill, KaTeX queda plano en celdas). */
.ap-tabla .katex { font-size: 1.02em; }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .ap-btn, .ap-step, .ap-show-btn, .ap-read-perim, .ap-read-area { transition: none !important; }
}

/* ===== Impresión: oculta los widgets interactivos; deja visibles los dibujos ===== */
@media print {
  .ap-lab, .ap-dec, .ap-comb { display: none !important; }
  .ap-tabla { break-inside: avoid; }
}
