/*
 * css/guide.css
 * Guías didácticas del estudiante: una hoja de cuaderno con el marco teórico, las cuatro
 * fases de Pólya con su captura del simulador y las hojas de trabajo para rellenar.
 * Comparte tokens con el resto del sitio (tokens.css).
 */

@import url('tokens.css');

.guide {
  position: relative;
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 clamp(1rem, 5vw, 4rem) 6rem clamp(2.5rem, 8vw, 7rem);
  background: var(--paper-2);
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  min-height: 100vh;
}

/* Línea de margen roja */
.guide::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: clamp(1.4rem, 5vw, 4.4rem);
  width: 1px;
  background: var(--red);
  opacity: 0.5;
}

/* ───────────────────────── Cabecera ───────────────────────── */

.guide-bar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-top: 26px;
}

.crumb {
  font: 500 0.75rem/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.crumb:hover { color: var(--red); }

.guide-title {
  margin-top: 40px;
  font: 700 clamp(2.4rem, 6.5vw, 5rem)/0.95 var(--font-display);
  letter-spacing: -0.03em;
  font-variation-settings: 'opsz' 144;
}

.guide-title em {
  font-weight: 600;
  font-variation-settings: 'opsz' 48; /* menos contraste: los trazos finos de opsz 144 se pierden en rojo */
  color: var(--red);
}

.guide-sub {
  margin-top: 18px;
  font: 500 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.lead {
  max-width: 40rem;
  margin: 28px 0 0;
  font-size: 1.25rem;
  font-style: normal;
  color: var(--ink-soft);
}

/* Índice de la guía */
.guide ol.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 36px 0 0;
  padding: 12px 0;
  list-style: none;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  font: 500 0.75rem/1.3 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toc a {
  color: var(--ink);
  text-decoration: none;
}

.toc a:hover { color: var(--red); }

/* ───────────────────────── Texto ───────────────────────── */

.guide h2 {
  margin: 0 0 14px;
  font: 600 clamp(1.7rem, 3.4vw, 2.3rem)/1.1 var(--font-display);
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 72;
}

.guide h3 {
  margin: 30px 0 8px;
  font: 600 1.3rem/1.2 var(--font-display);
}

.guide p,
.guide li {
  max-width: 44rem;
}

.guide p {
  margin: 0 0 16px;
  color: var(--ink-soft);
}

.guide strong { color: var(--ink); }

.guide ul,
.guide ol {
  margin: 0 0 18px 1.2rem;
  color: var(--ink-soft);
}

.guide li { margin-bottom: 8px; }

.guide sub, .guide sup { font-size: 0.75em; line-height: 0; }

.guide section {
  padding: 72px 0 8px;
}

.guide section:first-of-type { padding-top: 56px; }

/* Numeral de fase */
.phase-no {
  display: block;
  margin: 0 0 6px -3px;
  font: 600 6.5rem/0.8 var(--font-display);
  color: var(--red);
  font-variation-settings: 'opsz' 48;
}

.kicker {
  display: block;
  margin-bottom: 6px;
  font: 500 0.78rem/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ───────────────────────── Ecuaciones y notas ───────────────────────── */

.eq {
  max-width: 44rem;
  margin: 18px 0 22px;
  padding: 16px 20px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  text-align: center;
  font: 500 1.05rem/1.9 var(--font-mono);
  color: var(--blue);
}

.eq small {
  display: block;
  margin-bottom: 4px;
  font: 500 0.78rem/1.3 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.eq .note {
  display: block;
  margin-top: 2px;
  font: 400 0.9rem/1.4 var(--font-body);
  color: var(--muted);
}

.margin-note,
.question {
  max-width: 44rem;
  margin: 22px 0;
  padding: 6px 0 6px 16px;
  border-left: 3px solid var(--red);
  font-style: normal;
  color: var(--ink);
}

.question::before {
  content: 'Para pensar';
  display: block;
  margin-bottom: 2px;
  font: 500 0.78rem/1.3 var(--font-mono);
  font-style: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red);
}

.question p { margin: 0 0 6px; color: var(--ink); }

/* ───────────────────────── Figuras ───────────────────────── */

figure {
  margin: 28px 0;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: 6px 6px 0 rgba(27, 26, 23, 0.1);
}

figcaption {
  max-width: 44rem;
  margin-top: 12px;
  font: 400 0.95rem/1.45 var(--font-body);
  color: var(--muted);
}

figcaption b {
  font: 500 0.78rem var(--font-mono);
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ───────────────────────── Hojas de trabajo ───────────────────────── */

.worksheet {
  margin: 28px 0;
}

.worksheet h4 {
  margin-bottom: 4px;
  font: 500 0.78rem/1.3 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red);
}

.worksheet table {
  width: 100%;
  max-width: 48rem;
  border-collapse: collapse;
}

.worksheet th {
  padding: 8px 10px 8px 0;
  text-align: left;
  font: 500 0.78rem/1.2 var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 2px solid var(--ink);
}

.worksheet td {
  padding: 11px 10px 11px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 1rem;
  color: var(--ink-soft);
}

.worksheet td:first-child { color: var(--ink); font-weight: 600; }
.worksheet td.sym { font-family: var(--font-mono); font-size: 0.9rem; color: var(--blue); }

/* Espacio para escribir a mano */
.blank {
  display: inline-block;
  min-width: 5.5rem;
  height: 1.1em;
  border-bottom: 1px solid var(--ink);
  vertical-align: baseline;
}

.blank.wide { min-width: 16rem; }

/* ───────────────────────── Cierre ───────────────────────── */

.conclusions {
  max-width: 44rem;
  margin: 24px 0;
  padding: 16px 20px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}

.conclusions h3 { margin-top: 0; color: var(--blue); }

.guide-foot {
  margin-top: 80px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font: 400 0.75rem/1.6 var(--font-mono);
  letter-spacing: 0.03em;
  color: var(--muted);
}

.guide-foot a { color: var(--ink); }

.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 11px 16px;
  font: 500 0.78rem/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-2);
  background: var(--ink);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out), visibility 0s 0.25s, background 0.2s;
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out), visibility 0s, background 0.2s;
}

.to-top:hover { background: var(--red); }

@media (max-width: 720px) {
  .guide { padding-left: 2.2rem; }
  .guide::before { left: 1rem; }
  .guide-bar { flex-direction: column; gap: 12px; }
  .phase-no { font-size: 4.6rem; }
  .worksheet { overflow-x: auto; }
}

@media print {
  body { background: none; }
  .guide { border: 0; max-width: none; }
  .guide::before { display: none; }
  figure { break-inside: avoid; }
  .to-top { display: none; }
}
