/* ============================================================
 * theme.css — TEMA de la guía de NÚMEROS DECIMALES (capa LIBRE).
 * SOLO estilos del tema (prefijo nd-): leyenda de color, visuales del
 * concepto (tabla-pos, columna, recta-est) y widgets por toque (tablero,
 * comparador, recta). NO redefine clases `guia-*` (capa bloqueada).
 * Pisos de letra: lectura ≥17px · apoyo ≥15px · etiquetas MAYÚSCULAS ≥13px.
 * Tap targets ≥44px. Sin overflow horizontal a 360px. Light-mode fijo.
 * ============================================================ */

/* ===== Paleta del tema (eco de las variables de marca) ===== */
.nd-tp, .nd-col, .nd-recta-est, .nd-wg, .nd-legend {
  --nd-ent: #283891;     /* parte entera (navy) */
  --nd-dec: #C75D08;     /* parte decimal / foco (naranja) */
  --nd-green: #1C7A3A;   /* resultado / correcto */
  --nd-ink: #181B22;
  --nd-mut: #4b5563;
  --nd-line: #e7e2da;
  --nd-cream: #FFF3E7;
}

/* enlace al puente con fracciones */
.nd-link { color: var(--nd-dec, #C75D08); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.nd-link:hover { text-decoration: none; }

/* ===== Leyenda de color ===== */
.nd-legend {
  display: flex; flex-wrap: wrap; gap: 10px 18px;
  margin: 4px 0 18px; padding: 12px 14px;
  border: 2px solid var(--nd-ink); border-radius: 14px; background: #fff;
}
.nd-legend .it { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--nd-mut); }
.nd-legend .it b { color: var(--nd-ink); }
.nd-legend .sw { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--nd-ink); flex: 0 0 auto; }
.nd-legend .sw.ent { background: var(--nd-ent); }
.nd-legend .sw.dec { background: var(--nd-dec); }
.nd-legend .sw.dot {
  width: 18px; height: 18px; background: #fff; display: flex; align-items: flex-end; justify-content: center;
  font-size: 22px; font-weight: 900; line-height: .6; color: var(--nd-ink); border-color: var(--nd-ink);
}

/* ===== Visual: tabla de valor posicional ===== */
.nd-visual { margin: 14px 0; }
.nd-tp {
  border: 2px solid var(--nd-line); border-radius: 14px; background: #fff; padding: 14px 12px;
}
.nd-tp-row { display: flex; align-items: stretch; justify-content: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; }
.nd-tp-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 60px; padding: 8px 6px; border: 2px solid var(--nd-line); border-radius: 12px; background: #fcfbf9;
}
.nd-tp-cell.ent { border-color: var(--nd-ent); background: #f4f6fc; }
.nd-tp-cell.dec { border-color: var(--nd-dec); background: var(--nd-cream); }
.nd-tp-digit { font-size: 28px; font-weight: 800; line-height: 1; }
.nd-tp-cell.ent .nd-tp-digit { color: var(--nd-ent); }
.nd-tp-cell.dec .nd-tp-digit { color: var(--nd-dec); }
.nd-tp-lbl { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; color: var(--nd-mut); text-align: center; }
.nd-tp-dot { display: flex; align-items: flex-end; font-size: 34px; font-weight: 900; color: var(--nd-ink); padding-bottom: 6px; }
.nd-tp-cap { margin: 10px 0 0; font-size: 15px; color: var(--nd-mut); text-align: center; }
.nd-sw-ent, .nd-sw-dec { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: middle; border: 1.5px solid var(--nd-ink); }
.nd-sw-ent { background: var(--nd-ent); }
.nd-sw-dec { background: var(--nd-dec); }

/* ===== Visual: operación en columna ===== */
.nd-col {
  border: 2px solid var(--nd-line); border-radius: 14px; background: #fff; padding: 16px 14px;
  display: flex; flex-direction: column; align-items: center;
}
.nd-col-line {
  font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-size: 26px; font-weight: 800; line-height: 1.2; display: flex; align-items: center; letter-spacing: 1px;
}
.nd-col-line.empty { min-height: 31px; }
.nd-col-op { width: 22px; text-align: center; color: var(--nd-mut); }
.nd-col-d.ent { color: var(--nd-ent); width: 17px; text-align: center; }
.nd-col-d.dec { color: var(--nd-dec); width: 17px; text-align: center; }
.nd-col-gap { width: 17px; display: inline-block; }
.nd-col-dot { width: 10px; text-align: center; color: var(--nd-ink); }
.nd-col-rule { width: 100%; max-width: 200px; height: 3px; background: var(--nd-ink); border-radius: 2px; margin: 6px 0; }
.nd-col-line.res { color: var(--nd-green); }
.nd-col-line.res .nd-col-d.ent, .nd-col-line.res .nd-col-d.dec, .nd-col-line.res .nd-col-dot { color: var(--nd-green); }
.nd-col-cap { margin: 10px 0 0; font-size: 15px; color: var(--nd-mut); text-align: center; }

/* ===== Visual: recta estática ===== */
.nd-recta-est { border: 2px solid var(--nd-line); border-radius: 14px; background: #fff; padding: 10px 8px; }
.nd-recta-svg { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto; }

/* ===== Andamiaje común de widgets ===== */
.nd-wg {
  margin: 16px 0; padding: 16px 14px;
  border: 2px solid var(--nd-ink); border-radius: 16px; background: #fff;
  box-shadow: 4px 4px 0 var(--nd-ink);
}
.nd-wg-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 12px; }
.nd-flag {
  font-size: 13px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  color: #fff; background: var(--nd-dec); border-radius: 999px; padding: 3px 11px; flex: 0 0 auto;
}
.nd-wg-inst { font-size: 15px; color: var(--nd-mut); line-height: 1.4; }

.nd-btn {
  font: inherit; font-weight: 800; font-size: 17px; min-height: 44px; padding: 10px 18px;
  border: 2px solid var(--nd-ink); border-radius: 12px; background: var(--nd-ent); color: #fff;
  cursor: pointer; box-shadow: 3px 3px 0 var(--nd-ink); transition: transform .1s, box-shadow .1s;
}
.nd-btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--nd-ink); }
.nd-btn:active { transform: none; box-shadow: 1px 1px 0 var(--nd-ink); }
.nd-btn.small { font-size: 15px; min-height: 44px; padding: 9px 14px; }
.nd-btn.ghost { background: #fff; color: var(--nd-ink); box-shadow: none; }
.nd-btn.ghost:hover { border-color: var(--nd-dec); transform: none; box-shadow: none; }

/* ===== Widget: tablero de valor posicional ===== */
.nd-tb-board {
  display: flex; align-items: stretch; justify-content: center; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto; padding-bottom: 4px;
}
.nd-tb-dot { display: flex; align-items: center; font-size: 32px; font-weight: 900; color: var(--nd-ink); padding: 0 2px; }
.nd-tb-col {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 66px; padding: 8px 6px; border: 2px solid var(--nd-line); border-radius: 12px; background: #fcfbf9;
}
.nd-tb-col[data-pos="u"] { border-color: var(--nd-ent); background: #f4f6fc; }
.nd-tb-col[data-pos="d"], .nd-tb-col[data-pos="c"], .nd-tb-col[data-pos="m"] { border-color: var(--nd-dec); background: var(--nd-cream); }
.nd-tb-name { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; color: var(--nd-mut); text-align: center; }
.nd-tb-btn {
  width: 44px; height: 44px; font-size: 24px; font-weight: 800; line-height: 1;
  border: 2px solid var(--nd-ink); border-radius: 10px; background: #fff; color: var(--nd-ink);
  cursor: pointer; transition: transform .1s; flex: 0 0 auto;
}
.nd-tb-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--nd-dec); }
.nd-tb-btn:disabled { opacity: .35; cursor: default; }
.nd-tb-digit { font-size: 30px; font-weight: 800; line-height: 1; color: var(--nd-ink); }
.nd-tb-col[data-pos="u"] .nd-tb-digit { color: var(--nd-ent); }
.nd-tb-col[data-pos="d"] .nd-tb-digit, .nd-tb-col[data-pos="c"] .nd-tb-digit, .nd-tb-col[data-pos="m"] .nd-tb-digit { color: var(--nd-dec); }
.nd-tb-worth { font-size: 13px; font-weight: 700; color: var(--nd-mut); text-align: center; }
.nd-tb-out { margin-top: 14px; text-align: center; border-top: 2px dashed var(--nd-line); padding-top: 12px; }
.nd-tb-num { font-size: 34px; font-weight: 800; color: var(--nd-ink); line-height: 1.1; }
.nd-tb-read { margin: 6px 0 0; font-size: 17px; font-weight: 700; color: var(--nd-ent); }
.nd-tb-sum { margin: 8px 0 0; font-size: 15px; color: var(--nd-mut); line-height: 1.5; }
.nd-tb-p { font-weight: 800; padding: 1px 7px; border-radius: 7px; }
.nd-tb-p.ent { color: var(--nd-ent); background: #f4f6fc; }
.nd-tb-p.dec { color: var(--nd-dec); background: var(--nd-cream); }
.nd-tb-plus { color: var(--nd-mut); font-weight: 800; margin: 0 3px; }
.nd-tb [data-tb-reset] { display: block; margin: 14px auto 0; }

/* ===== Widget: comparador ===== */
.nd-cmp-prog, .nd-recta-prog { margin: 0 0 8px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--nd-mut); }
.nd-cmp-pair { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.nd-cmp-card {
  font-size: 30px; font-weight: 800; color: var(--nd-ink); padding: 8px 16px;
  border: 2px solid var(--nd-line); border-radius: 12px; background: #fcfbf9; min-width: 86px; text-align: center;
}
.nd-cmp-pad0 { color: var(--nd-dec); }
.nd-cmp-vs {
  font-size: 28px; font-weight: 900; color: var(--nd-mut); min-width: 36px; text-align: center;
}
.nd-cmp-vs.set { color: var(--nd-green); }
.nd-cmp-lbl { margin: 0 0 8px; font-size: 15px; font-weight: 800; color: var(--nd-dec); text-align: center; }
.nd-cmp-opts { display: flex; gap: 10px; justify-content: center; }
.nd-cmp-opt {
  width: 64px; height: 56px; font-size: 28px; font-weight: 800;
  border: 2px solid var(--nd-ink); border-radius: 12px; background: #fff; color: var(--nd-ink);
  cursor: pointer; box-shadow: 3px 3px 0 var(--nd-ink); transition: transform .1s, box-shadow .1s;
}
.nd-cmp-opt:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--nd-ink); }
.nd-cmp-opt.right { border-color: var(--nd-green); background: #e6f5ec; color: var(--nd-green); }
.nd-cmp-opt.wrong { border-color: #d6336c; background: #fdecf1; color: #a01243; }
.nd-cmp-opt:disabled { cursor: default; }
.nd-cmp-fb { margin: 12px 0 0; font-size: 17px; line-height: 1.5; display: none; }
.nd-cmp-fb.show { display: block; }
.nd-cmp-fb.ok { color: var(--nd-ink); }
.nd-cmp-fb.miss { color: #a01243; }
.nd-cmp-done { margin: 0 0 12px; font-size: 17px; line-height: 1.5; color: var(--nd-ink); }
.nd-cmp [data-cmp-pad] { display: block; margin: 0 auto 12px; }

/* ===== Widget: recta numérica por toque ===== */
.nd-recta-task { margin: 0 0 8px; font-size: 17px; line-height: 1.5; color: var(--nd-ink); text-align: center; }
.nd-recta-x { color: var(--nd-dec); }
.nd-recta-stage { display: flex; flex-direction: column; align-items: center; }
.nd-recta-svg2 { width: 100%; max-width: 340px; height: auto; display: block; }
.nd-recta-hit { cursor: pointer; }
.nd-recta-ctrls { margin-top: 8px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.nd-recta-fb { margin: 12px 0 0; font-size: 17px; line-height: 1.5; display: none; text-align: center; }
.nd-recta-fb.show { display: block; }
.nd-recta-fb.ok { color: var(--nd-ink); }
.nd-recta-fb.miss { color: #a01243; }
.nd-recta-done { margin: 0 0 12px; font-size: 17px; line-height: 1.5; color: var(--nd-ink); text-align: center; }

/* botón "siguiente / terminar" embebido en feedback (todos los widgets) */
.nd-cmp-fb .nd-btn, .nd-recta-fb .nd-btn { display: inline-block; margin: 10px 0 0 8px; vertical-align: middle; }

/* ===== 360px: sin overflow horizontal ===== */
@media (max-width: 380px) {
  .nd-tp-cell, .nd-tb-col { min-width: 54px; }
  .nd-col-line { font-size: 22px; }
  .nd-cmp-card { font-size: 24px; min-width: 70px; padding: 6px 10px; }
  .nd-cmp-fb .nd-btn, .nd-recta-fb .nd-btn { display: block; margin: 10px auto 0; }
}

/* ===== Movimiento reducido ===== */
@media (prefers-reduced-motion: reduce) {
  .nd-btn, .nd-tb-btn, .nd-cmp-opt { transition: none !important; }
}

/* ===== Impresión: oculta lo interactivo (apoyo, no contenido SEO) ===== */
@media print {
  .nd-wg { display: none !important; }
}
