/*!
 * SciParaTodos · Funciones de variable real y gráficos — estilos
 * Paleta y tarjetas de la versión original; se añaden cabecera, navegación,
 * controles deslizantes, lecturas de coordenadas y las secciones de
 * Teoría, Actividades y Preguntas.
 */
:root {
  --bg-1: #f0f9ff;
  --bg-2: #ffffff;
  --bg-3: #eef2ff;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --secondary: #4f46e5;
  --text: #0f172a;
  --muted: #64748b;
  --card: rgba(255,255,255,0.88);
  --border: #e2e8f0;
  --soft: #f8fafc;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --green: #10b981;
  --red: #ef4444;
  --ok: #047857; --okbg: #ecfdf5;
  --bad: #b91c1c; --badbg: #fef2f2;
  --warn: #b45309; --warnbg: #fffbeb;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  background-attachment: fixed;
  min-height: 100vh;
}

/* ================= Cabecera y navegación (nuevo) ================= */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  width: min(1200px, calc(100% - 32px)); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 0;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); min-width: 0; }
.brand img { height: 46px; width: auto; }
.brand-tx { display: flex; flex-direction: column; line-height: 1.2; }
.brand-tx b { font-weight: 900; font-size: 15px; }
.brand-tx small { color: var(--muted); font-size: 12.5px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.tabs a {
  text-decoration: none; color: #475569; font-weight: 800; font-size: 14px;
  padding: 9px 14px; border-radius: 999px; transition: .18s ease;
}
.tabs a:hover { background: #f1f5f9; }
.tabs a.on { background: #e0f2fe; color: var(--primary-dark); }
.lang { display: flex; gap: 6px; }
.lang button { min-width: 44px; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--border); background: #fff; color: #475569; }
.lang button.on { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(2,132,199,.2); }
.lang button:hover { transform: none; }

/* ================= Contenido original ================= */
.page {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 36px;
  padding: clamp(28px, 5vw, 56px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  margin-bottom: 22px;
}

.hero::after {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(14,165,233,.20), transparent 65%);
  right: -120px;
  top: -130px;
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: center;
  position: relative;
  z-index: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e0f2fe;
  color: var(--primary-dark);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 16px;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  margin: 0;
  color: #020617;
}

.hero p {
  color: var(--muted);
  line-height: 1.75;
  font-size: 1.05rem;
  max-width: 720px;
  margin: 20px 0 0;
}

.author-names {
  margin-top: 12px !important;
  color: #16a34a !important;
  font-size: clamp(1rem, 1.5vw, 1.35rem) !important;
  font-weight: 800;
  line-height: 1.25 !important;
  letter-spacing: -0.02em;
}

.objective {
  background: linear-gradient(145deg, #0ea5e9, #4f46e5);
  color: white;
  border-radius: 30px;
  padding: 26px;
  box-shadow: 0 20px 45px rgba(14,165,233,.22);
}

.objective small {
  display: block;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: #dbeafe;
  font-weight: 800;
  margin-bottom: 10px;
}

.objective strong {
  display: block;
  font-size: 1.6rem;
  line-height: 1.1;
}

.objective ul { margin: 16px 0 0; padding-left: 18px; color: #e0f2fe; font-size: .92rem; line-height: 1.55; }

.concepts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.concept,
.panel {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.concept {
  padding: 22px;
}

.concept .icon,
.section-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #eef2ff;
  color: var(--secondary);
  font-weight: 900;
  margin-bottom: 12px;
}

.concept h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.concept p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: .92rem;
}

.stack {
  display: grid;
  gap: 22px;
}

.panel {
  padding: clamp(20px, 3vw, 30px);
  scroll-margin-top: 90px;
}

.section-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  letter-spacing: -0.03em;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: .96rem;
}

.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: stretch;
}

.controls {
  display: grid;
  gap: 14px;
  align-content: start;
}

label span {
  display: block;
  color: #334155;
  font-size: .9rem;
  font-weight: 800;
  margin-bottom: 7px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--soft);
  color: var(--text);
  border-radius: 16px;
  padding: 13px 14px;
  font-size: 1rem;
  outline: none;
  transition: .18s ease;
}

input:focus,
select:focus {
  border-color: #38bdf8;
  background: white;
  box-shadow: 0 0 0 4px #e0f2fe;
}

input.bad { border-color: #f87171; background: #fff5f5; }

.hint {
  display: block;
  color: #94a3b8;
  font-size: .78rem;
  line-height: 1.45;
  margin-top: 6px;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.formula {
  background: linear-gradient(145deg, #f0f9ff, #eef2ff);
  border: 1px solid #dbeafe;
  border-radius: 18px;
  padding: 14px 15px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  color: #1e293b;
  font-weight: 800;
  line-height: 1.5;
  overflow-x: auto;
}

.note {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #edf2f7;
  border-radius: 18px;
  padding: 15px;
  line-height: 1.65;
  font-size: .92rem;
}

.note strong { color: #0f172a; }

.chart-wrap {
  position: relative;
  min-height: 390px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 24px;
  padding: 14px;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 360px;
  display: block;
  background: white;
  border-radius: 18px;
  border: 1px solid #e5e7eb;
  touch-action: none;
  cursor: crosshair;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  color: #475569;
  font-size: .88rem;
  font-weight: 700;
}

.legend-item {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.swatch {
  width: 22px;
  height: 4px;
  border-radius: 999px;
  display: inline-block;
}
.swatch.dot { width: 10px; height: 10px; }

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

button {
  border: 0;
  border-radius: 16px;
  background: #f1f5f9;
  color: #475569;
  padding: 13px 10px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: .18s ease;
}

button:hover { background: #e2e8f0; transform: translateY(-1px); }
button.active { background: #0284c7; color: white; box-shadow: 0 10px 20px rgba(2,132,199,.18); }

.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.7);
  border-radius: 24px;
  padding: 18px;
}
.footer a { color: var(--primary-dark); font-weight: 800; text-decoration: none; }
.footer p { margin: 6px 0 0; }

/* ================= Laboratorio: añadidos ================= */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1f5f9; padding: 5px; border-radius: 16px; }
.seg button { padding: 10px 8px; border-radius: 12px; background: transparent; font-size: .88rem; }
.seg button.active { background: #fff; color: var(--primary-dark); box-shadow: 0 4px 12px rgba(15,23,42,.08); }
.seg button:hover { transform: none; }

.slider-row { display: grid; grid-template-columns: 1fr 96px; gap: 10px; align-items: center; }
.slider-row input[type=number] { padding: 10px 10px; }
input[type=range] {
  padding: 0; border: 0; background: transparent; box-shadow: none !important;
  accent-color: var(--primary); height: 28px; cursor: pointer;
}

.readout {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  margin-top: 10px; min-height: 26px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace; font-size: .84rem; color: #334155;
}
.readout .tip { font-family: Inter, system-ui, sans-serif; color: #94a3b8; font-weight: 600; }
.readout b { font-weight: 800; }

.chart-tools { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.mini-btn { padding: 8px 12px; border-radius: 12px; font-size: .82rem; background: #fff; border: 1px solid var(--border); }
.mini-btn:hover { background: #f1f5f9; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.facts:empty { display: none; }
#line-canvas, #circle-canvas { height: 430px; }
.side-block { margin-top: 12px; }
.fact { background: #fff; border: 1px solid #edf2f7; border-radius: 14px; padding: 10px 12px; min-width: 0; }
.fact small { display: block; color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.fact b { display: block; margin-top: 2px; font-family: "JetBrains Mono", Consolas, monospace; font-size: .92rem; overflow-wrap: anywhere; }
.fact.wide { grid-column: 1 / -1; }

.msg { border-radius: 14px; padding: 10px 12px; font-size: .88rem; font-weight: 700; line-height: 1.5; }
.msg.err { background: var(--badbg); color: var(--bad); }
.msg.warn { background: var(--warnbg); color: var(--warn); }
.msg.ok { background: var(--okbg); color: var(--ok); }
.msg:empty { display: none; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.chk { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-weight: 700; font-size: .88rem; color: #334155; }
.chk input { width: 17px; height: 17px; padding: 0; accent-color: var(--primary); }
.chk span { display: inline; margin: 0; font-weight: 700; font-size: .88rem; }

.eval-table { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; border-radius: 14px; overflow: hidden; border: 1px solid #edf2f7; }
.eval-table th, .eval-table td { padding: 8px 10px; border-bottom: 1px solid #edf2f7; text-align: left; }
.eval-table th { background: #f8fafc; color: #475569; font-size: .8rem; }
.eval-table td:last-child { font-family: "JetBrains Mono", Consolas, monospace; font-weight: 800; text-align: right; }

/* ================= Secciones nuevas ================= */
.block { margin-top: 40px; scroll-margin-top: 80px; }
.block-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.kicker { margin: 0 0 6px; color: var(--primary); font-weight: 900; letter-spacing: .16em; text-transform: uppercase; font-size: 13px; }
.block-head h2 { margin: 0; font-size: clamp(1.8rem, 3.4vw, 2.6rem); letter-spacing: -0.04em; line-height: 1.05; }
.block-head p { margin: 8px 0 0; color: var(--muted); max-width: 720px; line-height: 1.6; }

.theory-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.th-card { padding: clamp(20px, 3vw, 28px); }
.th-card h3 { margin: 0 0 10px; font-size: 1.25rem; letter-spacing: -0.02em; display: flex; gap: 10px; align-items: center; }
.th-card h3 .section-icon { margin: 0; width: 38px; height: 38px; border-radius: 12px; }
.th-card p, .th-card li { color: #334155; line-height: 1.7; font-size: .95rem; }
.th-card ul { padding-left: 20px; margin: 8px 0; }
.th-card .formula { margin: 10px 0; }
.th-fig { margin: 14px 0 4px; background: #fff; border: 1px solid #edf2f7; border-radius: 18px; padding: 8px; }
.th-fig svg { width: 100%; height: auto; display: block; }
.th-fig figcaption { color: var(--muted); font-size: .82rem; text-align: center; padding: 4px 6px 2px; }
.th-card.full { grid-column: 1 / -1; }
.table-forms { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: 8px; }
.table-forms th, .table-forms td { border-bottom: 1px solid var(--border); padding: 9px 8px; text-align: left; vertical-align: top; }
.table-forms th { background: #f8fafc; }
.table-forms td code { font-family: "JetBrains Mono", Consolas, monospace; font-weight: 700; color: #1e293b; }
.tscroll { overflow-x: auto; }

.act-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.act { padding: clamp(20px, 3vw, 26px); display: flex; flex-direction: column; gap: 10px; }
.act-top { display: flex; align-items: center; gap: 10px; }
.act-num { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg, #0ea5e9, #4f46e5); color: #fff; font-weight: 900; flex: none; }
.act h3 { margin: 0; font-size: 1.1rem; }
.act .lvl { margin-left: auto; font-size: .74rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: #eef2ff; color: var(--secondary); white-space: nowrap; }
.act p { margin: 0; color: #334155; line-height: 1.65; font-size: .94rem; }
.act ol { margin: 0; padding-left: 20px; color: #334155; line-height: 1.65; font-size: .94rem; }
.act ol li { margin: 3px 0; }
.act .go { align-self: flex-start; background: var(--primary); color: #fff; padding: 11px 16px; }
.act .go:hover { background: var(--primary-dark); }
.act details { background: #f8fafc; border: 1px solid #edf2f7; border-radius: 14px; padding: 10px 14px; }
.act summary { cursor: pointer; font-weight: 800; color: var(--primary-dark); }
.act details p { margin-top: 8px; }

.quiz { padding: clamp(20px, 3vw, 30px); }
.quiz-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.score { font-weight: 900; font-size: 1.05rem; }
.progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; flex: 1 1 220px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #0ea5e9, #4f46e5); transition: width .3s ease; }
.q { border-top: 1px solid var(--border); padding: 18px 0; }
.q:first-of-type { border-top: 0; }
.q h4 { margin: 0 0 10px; font-size: 1rem; line-height: 1.5; }
.q h4 em { font-style: normal; color: var(--primary); margin-right: 6px; }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.opts button { text-align: left; background: #fff; border: 1px solid var(--border); font-weight: 700; color: #334155; padding: 12px 14px; line-height: 1.4; }
.opts button:hover:not(:disabled) { border-color: #93c5fd; background: #f0f9ff; }
.opts button:disabled { cursor: default; transform: none; }
.opts button.ok { background: var(--okbg); border-color: #6ee7b7; color: var(--ok); }
.opts button.no { background: var(--badbg); border-color: #fca5a5; color: var(--bad); }
.fb { margin-top: 10px; }
.quiz-end { margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.mono { font-family: "JetBrains Mono", Consolas, monospace; }

/* ================= Responsivo ================= */
@media (max-width: 1060px) {
  .tabs a { padding: 8px 10px; font-size: 13px; }
  .brand-tx small { display: none; }
}

@media (max-width: 920px) {
  .hero-grid,
  .workspace,
  .concepts,
  .theory-grid,
  .act-grid {
    grid-template-columns: 1fr;
  }
  .theory-grid, .act-grid, .workspace { grid-template-columns: minmax(0, 1fr); }
  .objective { max-width: 100%; }
  .topbar-in { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .tabs a { white-space: nowrap; }
}

@media (max-width: 560px) {
  .page { width: min(100% - 20px, 1200px); padding-top: 18px; }
  .hero, .panel { border-radius: 24px; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .three-col.keep { grid-template-columns: repeat(3, 1fr); }
  .two-col.keep { grid-template-columns: 1fr 1fr; }
  .btn-grid { grid-template-columns: 1fr; }
  canvas { height: 320px; }
  .chart-wrap { min-height: 350px; }
  .opts { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .brand img { height: 38px; }
}

@media print {
  .topbar, .lang, .mini-btn, .act .go { display: none !important; }
  body { background: #fff; }
}
