/* ============================================================
   styles.css — Explora el Triángulo de Pascal
   Diseño minimalista, sin fuentes ni recursos externos.
   Secciones: 1 Base · 2 Componentes · 3 Triángulo SVG · 4 Vistas ·
              5 Menú · 6 Laboratorio · 7 Fichas e impresión
   ============================================================ */

/* ---------- 1. Base ---------- */
:root {
  --bg: #f7f8fa; --card: #ffffff; --ink: #1f2933; --muted: #667085; --line: #e4e7ec;
  --accent: #2a6cb3; --accent-ink: #ffffff;
  --red: #f09aa0; --yellow: #f8dc7c; --blue: #8dbdf0; --green: #93d8a6; --gray: #f1f4f8;
  --red-d: #c0392b; --yellow-d: #b88a00; --blue-d: #2a6cb3; --green-d: #2a8a4b;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.5; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.7rem; } h3 { font-size: 1.1rem; margin-top: 1.1em; } h3:first-child { margin-top: 0; }
p { margin: 0 0 .7em; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #1f2933; outline-offset: 2px; }
main:focus { outline: none; }
main { max-width: 1320px; margin: 0 auto; padding: 8px 16px 40px; outline: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; color: var(--muted); }
.hint { font-size: .88rem; color: var(--muted); margin: .4em 0; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 16px; max-width: 1320px; margin: 0 auto; min-height: 72px; }
.crumb { font-weight: 600; color: var(--muted); }
.pagefoot { text-align: center; color: var(--muted); font-size: .8rem; padding: 12px; }

/* ---------- 2. Componentes ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: 12px;
  border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.btn.big-btn { width: 100%; min-height: 58px; font-size: 1.1rem; margin-top: 8px; }
.btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 10px; margin-top: 16px; } .btnrow.wrap { flex-wrap: wrap; margin-top: 10px; }
.x { background: none; border: none; font-size: 1.05rem; color: var(--muted); cursor: pointer; min-width: 36px; min-height: 36px; border-radius: 8px; }
.x:hover { background: var(--line); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.view-head { margin: 4px 0 18px; } .lead { font-size: 1.08rem; color: var(--muted); max-width: 70ch; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.segbtn { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid #d0d5dd; background: #fff; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.segbtn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg.small .segbtn { min-height: 38px; padding: 0 14px; font-size: .9rem; }

.ctl { margin: 14px 0; }
.ctl > label:first-child:not(.switch), .ctl > label.check { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.check { display: flex !important; align-items: center; gap: 10px; font-weight: 500 !important; cursor: pointer; margin: 6px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check small { color: var(--muted); font-weight: 400; }
input[type=range] { width: 100%; height: 34px; accent-color: var(--accent); }
input[type=number], input[type=text], select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border: 2px solid #d0d5dd; border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
textarea { resize: vertical; }
.inline { display: flex; gap: 8px; } .inline input { flex: 1; min-width: 0; }
output { font-weight: 700; }

.switch { position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 42px; font-weight: 600; font-size: .95rem; }
.switch input { position: absolute; opacity: 0; width: 46px; height: 26px; margin: 0; cursor: pointer; }
.switch .track { width: 46px; height: 26px; border-radius: 13px; background: #cbd2da; position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 23px; }
.switch input:focus-visible + .track { outline: 3px solid var(--ink); outline-offset: 2px; }

.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.cbtn { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-size: .75rem; color: var(--muted); }
.cbtn input { position: absolute; opacity: 0; }
.cbtn span { width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(0,0,0,.2); display: block; }
.cbtn input:checked + span { outline: 4px solid var(--ink); outline-offset: 2px; }
.cbtn input:focus-visible + span { outline: 4px solid var(--accent); outline-offset: 2px; }
.cbtn em { font-style: normal; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 12px 0; align-items: center; }
.lg { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; } .lg small { color: var(--muted); }
.swatch { flex: none; vertical-align: middle; }
.ringsample { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--green-d); display: inline-block; }

.info { background: var(--gray); border-radius: 12px; padding: 12px 16px; margin-top: 12px; min-height: 56px; }
.info p { margin: 0 0 .4em; } .info p:last-child { margin: 0; }
.big { font-size: 1.5rem; } .calc { font-size: 1.15rem; }
.chip { display: inline-block; min-width: 2em; text-align: center; padding: 2px 10px; border-radius: 8px; background: #fff; border: 2px solid #1f2933; font-weight: 700; }
.callout { background: #fff8e1; border-left: 5px solid var(--yellow); padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.badge { font-size: .75rem; background: var(--gray); border-radius: 99px; padding: 2px 10px; margin-left: 8px; font-weight: 600; color: var(--muted); }
.badge.warn { background: #fdecea; color: var(--red-d); }

.questions { padding-left: 1.2em; margin: 0 0 10px; } .questions li { margin-bottom: 6px; }
.hintbox, .explain { background: var(--gray); border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
.hintbox summary, .explain summary, .tcard summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.hintbox > div, .explain p { margin-top: 8px; }
.hintline { background: #fff8e1; padding: 8px 12px; border-radius: 8px; }

/* ---------- 3. Triángulo SVG ---------- */
.tri-scroll { overflow: auto; max-width: 100%; padding-bottom: 4px; }
.tri-box { min-width: 100%; margin: 0 auto; }
.pt-svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.pt-svg .hexline { stroke: #aab3c0; stroke-width: 1; }
.pt-svg .num { fill: #1f2933; font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.pt-svg .num.given { fill: #1f2933; } .pt-svg .num.mine { fill: #1d5fb4; font-weight: 700; }
.pt-svg .cell.clickable { cursor: pointer; } .pt-svg .cell.clickable:hover .hexline { stroke: #1f2933; stroke-width: 2.5; }
.pt-svg .cell.dim { opacity: .38; }
.pt-svg .ring { fill: none; stroke-width: 4; pointer-events: none; }
.pt-svg .ring-sel { stroke: #1f2933; } .pt-svg .ring-parent { stroke: #1f2933; stroke-dasharray: 6 4; }
.pt-svg .ring-mirror { stroke: #7a4fd0; } .pt-svg .ring-ok { stroke: #1f9d55; } .pt-svg .ring-bad { stroke: #d62839; }
.pt-svg .ring-diag { stroke: var(--green-d); }
.pt-svg .axis { stroke: #98a2b3; stroke-width: 2; stroke-dasharray: 8 6; }
.pt-svg .rowlab { fill: #98a2b3; font-size: 14px; }
.pt-svg .guide { fill: none; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; opacity: .6; pointer-events: none; }
.pt-svg.bw .num { paint-order: stroke; stroke: #fff; stroke-width: 4.5px; stroke-linejoin: round; }
.painting, .painting * { touch-action: none; }
.painting .cell.clickable { cursor: crosshair; }

/* ---------- 4. Vistas ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 20px; align-items: start; }
.panel h3 { margin-top: 1.2em; } .panel h3:first-child { margin-top: 0; }
.vlist { margin: 8px 0; line-height: 2; } .vchip { display: inline-block; padding: 0 9px; margin: 2px 3px; border-radius: 8px; font-weight: 600; font-size: .9rem; border: 1px solid rgba(0,0,0,.15); }
.vchip.c-red { background: var(--red); } .vchip.c-yellow { background: var(--yellow); } .vchip.c-blue { background: var(--blue); } .vchip.c-green { background: var(--green); }
.figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 10px; }
.fig { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; padding: 8px 4px; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; min-height: 110px; }
.fig .dots { max-width: 100%; height: auto; } .fig .sum { font-size: .66rem; color: var(--muted); word-break: break-all; text-align: center; line-height: 1.1; }
.fig b { font-size: 1.2rem; } .fig.on { border-color: var(--green-d); background: #eef9f1; }
.fibrow { display: flex; flex-wrap: wrap; gap: 8px; }
.fchip { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 62px; min-height: 64px; padding: 6px 10px; border: 3px solid; border-radius: 14px; background: #fff; font: inherit; cursor: pointer; }
.fchip .v { font-size: 1.3rem; font-weight: 700; } .fchip small { font-size: .7rem; color: var(--muted); } .fchip.on { background: var(--gray); box-shadow: 0 0 0 3px #1f2933; }
.note { display: block; margin: 12px 0; } .note > span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }

/* ---------- 5. Menú ---------- */
.hero { text-align: center; padding: 14px 0 26px; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.8rem); letter-spacing: .02em; margin-bottom: .2em; }
.sub { font-size: 1.2rem; color: var(--muted); }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.mcard { display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; overflow: hidden; transition: transform .12s, border-color .12s; }
.mcard:hover, .mcard:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.mthumb { padding: 14px 18px 4px; background: #fcfcfd; border-bottom: 1px solid var(--line); } .mthumb svg { max-height: 120px; margin: 0 auto; }
.mtxt { display: grid; grid-template-columns: 34px 1fr; column-gap: 10px; padding: 14px 16px 16px; align-items: start; }
.mtxt b { font-size: 1.08rem; line-height: 1.25; } .mtxt small { grid-column: 2; color: var(--muted); font-size: .9rem; }
.n { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; font-weight: 700; font-size: .95rem; background: var(--gray); }
.n.c0 { background: var(--red); } .n.c1 { background: var(--yellow); } .n.c2 { background: var(--blue); } .n.c3 { background: var(--green); }
.menu-more { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 26px; }

/* ---------- 6. Laboratorio ---------- */
.lab-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
.tabs { display: flex; gap: 6px; margin: 14px 0 10px; flex-wrap: wrap; }
.tab { flex: 1; min-height: 44px; border: 2px solid #d0d5dd; background: #fff; border-radius: 10px; font: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; padding: 4px 6px; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.rules { list-style: none; padding: 0; margin: 12px 0; }
.rules li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: #fff; }
.rules li.off { opacity: .5; } .rules .rt { flex: 1; font-size: .92rem; } .rules .mini input { width: 22px; height: 22px; }
.sumbtn { min-width: 44px; min-height: 36px; border-radius: 8px; border: 2px solid var(--ink); background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.lab-bottom { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-top: 20px; align-items: start; }
.lab-bottom h3 { margin-top: 0; }
.challenge { margin-top: 14px; background: #fff8e1; border-radius: 12px; padding: 12px 16px; } .stars { font-size: .9rem; }
.saved { list-style: none; padding: 0; margin: 10px 0; }
.saved li { display: flex; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.saved .thumb { width: 92px; flex: none; } .saved .sinfo { flex: 1; min-width: 0; } .saved .sinfo small { display: block; color: var(--muted); }
.saved .btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
#compare { margin-top: 20px; } .cmpgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } .cmpcol h4 { margin-bottom: 8px; }

/* ---------- Retos y docente ---------- */
.retos-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; margin-bottom: 18px; }
.reto h3 { display: flex; gap: 10px; align-items: flex-start; }
.teacher-list { display: grid; gap: 12px; margin: 16px 0; } .tcard { padding: 14px 20px; }
.tcols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 12px 0; } .tcols h4 { margin: 14px 0 4px; } .tcols ul, .tcols ol { margin: 0; padding-left: 1.2em; }

/* ---------- 7. Fichas (pantalla e impresión) ---------- */
.print-grid { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 20px; align-items: start; }
.print-side { display: grid; gap: 20px; }
.tpls { display: grid; gap: 8px; }
.tpl { display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: inherit; cursor: pointer; min-height: 56px; }
.tpl small { display: block; color: var(--muted); font-size: .8rem; } .tpl.on { border-color: var(--accent); background: #eef4fb; }
.prev { background: #e9ecf1; border-radius: 12px; padding: 0; overflow: hidden; position: relative; }
.prev-scale { transform-origin: top left; width: max-content; }
.preview { position: sticky; top: 8px; }

.sheet { box-sizing: border-box; width: 210mm; height: 296mm; padding: 13mm 14mm; display: flex; flex-direction: column; background: #fff; color: #111; overflow: hidden; font-family: var(--font); font-size: 11pt; line-height: 1.35; }
.sheet.landscape { width: 297mm; height: 209mm; padding: 10mm 14mm; }
.sheet h1 { font-size: 18pt; margin: 0; } .sheet h2 { font-size: 11pt; margin: 0 0 1mm; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm; border-bottom: 2px solid #222; padding-bottom: 2.5mm; margin-bottom: 3.5mm; }
.sheet-name { display: flex; gap: 6mm; font-size: 10.5pt; white-space: nowrap; }
.line { display: inline-block; border-bottom: 1px solid #333; width: 48mm; height: 1em; vertical-align: baseline; } .line.short { width: 26mm; } .line.long { width: 110mm; }
.sheet-instr { border: 1.5px solid #777; border-radius: 3mm; padding: 2mm 4mm; font-size: 10.5pt; margin-bottom: 3mm; }
.sheet-fig { position: relative; flex: 1; min-height: 0; }
.sheet-fig svg, .mini-fig svg, .cmp-fig svg, .retos-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sheet-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 2mm 7mm; margin: 3mm 0 0; font-size: 10.5pt; }
.sheet-legend span, .mini-leg span { display: inline-flex; align-items: center; gap: 2mm; }
.sheet-sub { margin-top: 3mm; font-size: 10.5pt; } .sheet-sub .swatch { margin: 0 1mm; vertical-align: middle; }
.sumboxes { display: flex; flex-wrap: wrap; gap: 2mm; margin-top: 2mm; }
.sumbox { display: flex; align-items: center; gap: 1mm; border: 1.5px solid #333; border-radius: 2mm; padding: 1mm 1.5mm; min-width: 17mm; height: 10mm; } .sumbox b { flex: 1; text-align: center; font-size: 11pt; }
.sheet-foot { display: flex; justify-content: space-between; font-size: 8pt; color: #555; margin-top: 3mm; border-top: 1px solid #bbb; padding-top: 1.5mm; letter-spacing: .04em; }
.lines { margin-top: 1.5mm; } .lines i { display: block; height: 7.5mm; border-bottom: 1px solid #777; }
.research { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3mm; margin-top: 1mm; }
.mini { display: flex; flex-direction: column; min-height: 0; border: 1px solid #aaa; border-radius: 3mm; padding: 2mm 3mm; }
.mini-fig { position: relative; flex: 1; min-height: 0; } .mini-leg { display: flex; gap: 4mm; flex-wrap: wrap; font-size: 9pt; margin-top: 1mm; } .mini .lines i { height: 5.5mm; }
.retos-fig { position: relative; height: 52mm; margin-bottom: 3mm; }
.retos { margin: 0; padding-left: 6mm; display: flex; flex-direction: column; gap: 2.5mm; font-size: 10.5pt; } .retos .lines i { height: 6.5mm; }
.obs { display: grid; grid-template-columns: 1fr 1fr; gap: 1mm 6mm; margin-top: 3mm; font-size: 10pt; } .written { margin: 1mm 0 0; white-space: pre-wrap; border-bottom: 1px solid #777; padding-bottom: 1mm; font-size: 10pt; }
.cmp { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; } .cmpc { display: flex; flex-direction: column; min-height: 0; } .cmp-fig { position: relative; flex: 1; min-height: 0; }

#printRoot { display: none; }

/* ---------- Adaptación a tablet y móvil ---------- */
@media (max-width: 1000px) {
  .layout, .lab-grid, .print-grid { grid-template-columns: minmax(0, 1fr); }
  .lab-grid .stage { order: -1; } .preview { position: static; }
  .tcols, .cmpgrid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 16px; } main { padding: 4px 10px 30px; } .card { padding: 14px; } h2 { font-size: 1.4rem; }
  .menu-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .mtxt { grid-template-columns: 28px 1fr; padding: 10px; } .mtxt b { font-size: .95rem; } .mtxt small { display: none; }
  .retos-list { grid-template-columns: 1fr; }
}

/* ---------- Impresión: solo se imprime la ficha ---------- */
@media print {
  html, body { background: #fff !important; }
  body > *:not(#printRoot) { display: none !important; }
  #printRoot { display: block; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet { break-after: page; page-break-after: always; margin: 0; box-shadow: none; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
}
