*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* Cross-fade entre páginas: la retícula de fondo no "parpadea" al navegar. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===== Tipografía ===== */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--blueprint);
  margin: 0 0 var(--space-2);
}
h2, h3 { letter-spacing: 0.02em; }

p { margin: 0 0 var(--space-2); color: var(--ink); }
a { color: var(--blueprint); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { color: var(--race-red); }
strong { color: var(--blueprint); font-weight: 700; }
code, .formula, .data-table, .cota { font-family: var(--font-mono); }

/* Cota inline: número de plano (mono, gris cota) */
.cota { font-family: var(--font-mono); color: var(--dim); font-size: 0.9em; letter-spacing: 0.01em; }
.dim  { font-family: var(--font-mono); color: var(--race-red); font-weight: 600; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible {
  outline: 2px solid var(--race-red);
  outline-offset: 3px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

/* ===== Header / nav (cabecera de plano) ===== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center;
  background: rgba(240, 237, 228, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1.5px solid var(--blueprint);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.site-header__brand {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-weight: 600; font-size: 1.2rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--blueprint); text-decoration: none;
}
.site-header__brand img { height: 50px; width: auto; }
.site-header__brand .tick { color: var(--race-red); }
/* Distintivo de nivel: este curso es el "Básico" del temario CAD */
.level-badge {
  font-family: var(--font-mono); font-style: normal;
  font-size: 0.62rem; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; line-height: 1;
  padding: 4px 8px; border-radius: var(--radius);
  color: var(--race-red); background: var(--red-wash);
  border: 1px solid var(--race-red);
}

/* Puntos de navegación = "componentes que se acoplan al ensamble" */
.nav-dots { display: flex; align-items: center; gap: 10px; list-style: none; margin: 0; padding: 0; }
.nav-dots a {
  display: block; width: 12px; height: 12px;
  background: transparent; border: 1.5px solid var(--line-strong);
  text-indent: -9999px; overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.nav-dots a:hover { border-color: var(--race-red); }
.nav-dots a.is-done { background: var(--blueprint); border-color: var(--blueprint); }
.nav-dots a.is-current { background: var(--race-red); border-color: var(--race-red); transform: scale(1.3) rotate(45deg); }
/* Sesión 6+ (proyecto): rombo hueco con contorno rojo para distinguirla */
.nav-dots a.nav-dot--bonus { border-radius: 0; border: 1.5px solid var(--race-red); transform: rotate(45deg); }
.nav-dots a.nav-dot--bonus.is-current { background: var(--race-red); transform: rotate(45deg) scale(1.3); }
.nav-dots a.nav-dot--bonus.is-done { background: var(--race-red); }

/* ===== Botones ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius);
  font-family: var(--font-display); font-weight: 500; font-size: 0.95rem;
  letter-spacing: 0.04em; text-transform: uppercase;
  text-decoration: none; border: 1.5px solid transparent; cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
}
.btn--primary { background: var(--blueprint); color: var(--paper); border-color: var(--blueprint); }
.btn--primary:hover { background: var(--race-red); border-color: var(--race-red); color: #fff; transform: translateY(-1px); }
.btn--ghost { background: transparent; border-color: var(--blueprint); color: var(--blueprint); }
.btn--ghost:hover { border-color: var(--race-red); color: var(--race-red); transform: translateY(-1px); }

/* ===== Tarjetas = "callout de pieza" (cajetín con esquinas de plano) ===== */
.card {
  position: relative;
  background: var(--paper-2);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
/* marcas de esquina tipo plano */
.card::before, .card::after {
  content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none;
  border-color: var(--blueprint); border-style: solid; border-width: 0;
  opacity: 0.55; transition: opacity 0.2s ease, border-color 0.2s ease;
}
.card::before { top: 6px; left: 6px; border-top-width: 1.5px; border-left-width: 1.5px; }
.card::after  { bottom: 6px; right: 6px; border-bottom-width: 1.5px; border-right-width: 1.5px; }
.card:hover {
  border-color: var(--blueprint);
  transform: translateY(-3px);
  box-shadow: 6px 6px 0 -1px var(--paper-3), 6px 6px 0 0 var(--line-strong);
}
.card:hover::before, .card:hover::after { opacity: 1; border-color: var(--race-red); }
.card--alert { border-color: var(--race-red); }
.card--alert::before, .card--alert::after { border-color: var(--race-red); }
.card--alert:hover { border-color: var(--race-red); box-shadow: 6px 6px 0 -1px var(--red-wash), 6px 6px 0 0 var(--race-red); }

/* ===== Badges (etiqueta de anotación) ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 2px;
  background: var(--paper); color: var(--dim); border: 1px solid var(--line-strong);
}
.badge--red { color: var(--race-red); border-color: var(--race-red); }

/* ===== Callouts = línea de referencia (leader) ===== */
.callout {
  border-left: 3px solid var(--blueprint);
  background: var(--blueprint-wash);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-3);
}
.callout h2, .callout h3 { margin-top: 0; }
.callout--alert { border-left-color: var(--race-red); background: var(--red-wash); }

/* ===== Tablas (aspecto de cuadro de cotas / cut list) ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table caption { text-align: left; }
.data-table th, .data-table td {
  text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line);
}
.data-table thead th { border-bottom: 1.5px solid var(--blueprint); }
.data-table th { color: var(--blueprint); font-family: var(--font-display); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.05em; }
.data-table td { color: var(--ink); }
.data-table tbody tr:nth-child(even) td { background: var(--paper-2); }

.formula {
  display: block; background: var(--paper-2); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--race-red);
  border-radius: var(--radius); padding: var(--space-2); white-space: pre-wrap;
  color: var(--blueprint); font-size: 0.92rem; line-height: 1.5;
}

/* ===== Checklist (criterio "lo lograste o no" / revisión) ===== */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checklist__item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--paper-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: var(--space-2);
}
.checklist__item::before {
  content: "▢"; color: var(--race-red); flex-shrink: 0;
  font-family: var(--font-mono); font-size: 1.05em; line-height: 1.5;
}
/* Variante "criterio de logro" (check) para el reto de cada sesión */
.checklist--goal .checklist__item::before { content: "◺"; color: var(--blueprint); }

/* ===== Placeholder de modelo / referencia visual ===== */
.photo-placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  aspect-ratio: 4 / 3; border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  color: var(--dim); font-size: 0.85rem; font-family: var(--font-mono); padding: var(--space-2);
  background:
    repeating-linear-gradient(0deg, transparent, transparent calc(var(--grid-step) - 1px), var(--line) calc(var(--grid-step) - 1px), var(--line) var(--grid-step)),
    repeating-linear-gradient(90deg, transparent, transparent calc(var(--grid-step) - 1px), var(--line) calc(var(--grid-step) - 1px), var(--line) var(--grid-step)),
    var(--paper);
}

/* ===== Reveal (entrada al hacer scroll) ===== */
.reveal { opacity: 0; transform: translateY(22px); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ===== Footer (cajetín inferior del plano) ===== */
.site-footer {
  border-top: 1.5px solid var(--blueprint);
  padding: var(--space-4) 0;
  color: var(--dim);
  font-size: 0.88rem;
  background: var(--paper-2);
}
.site-footer strong { color: var(--blueprint); }
.site-footer .cota-strip {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: var(--space-2); padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

/* ===== Fondo: retícula de plano (fija, cubre todo) ===== */
.bg-grid {
  /* overscan de 25vh arriba/abajo: el parallax (animations.js) mueve la retícula
     hasta 12vh, así que su borde nunca queda visible dentro del viewport */
  position: fixed; inset: -25vh 0; z-index: -1; pointer-events: none; overflow: hidden;
  background:
    /* retícula fina */
    repeating-linear-gradient(0deg, transparent, transparent calc(var(--grid-step) - 1px), rgba(15,42,67,0.05) calc(var(--grid-step) - 1px), rgba(15,42,67,0.05) var(--grid-step)),
    repeating-linear-gradient(90deg, transparent, transparent calc(var(--grid-step) - 1px), rgba(15,42,67,0.05) calc(var(--grid-step) - 1px), rgba(15,42,67,0.05) var(--grid-step)),
    /* retícula gruesa cada 5 pasos */
    repeating-linear-gradient(0deg, transparent, transparent calc(var(--grid-step) * 5 - 1px), rgba(15,42,67,0.09) calc(var(--grid-step) * 5 - 1px), rgba(15,42,67,0.09) calc(var(--grid-step) * 5)),
    repeating-linear-gradient(90deg, transparent, transparent calc(var(--grid-step) * 5 - 1px), rgba(15,42,67,0.09) calc(var(--grid-step) * 5 - 1px), rgba(15,42,67,0.09) calc(var(--grid-step) * 5)),
    var(--paper);
  will-change: transform, opacity;
}
/* Cajetín (título block): marco fino y esquinas alrededor de todo el viewport */
.bg-frame {
  position: fixed; inset: 14px; z-index: -1; pointer-events: none;
  border: 1px solid rgba(15,42,67,0.18);
}
.bg-frame::before, .bg-frame::after {
  content: ""; position: absolute; width: 22px; height: 22px;
  border: 2px solid rgba(15,42,67,0.35);
}
.bg-frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.bg-frame::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ===== Aviso "reducir movimiento" ===== */
.reduced-motion-notice {
  position: fixed; left: 50%; bottom: var(--space-2); transform: translateX(-50%);
  z-index: 30; display: flex; align-items: center; gap: var(--space-2);
  max-width: min(92vw, 540px); padding: 10px 12px 10px 16px;
  background: var(--paper); color: var(--ink);
  border: 1.5px solid var(--line-strong); border-left: 3px solid var(--race-red);
  border-radius: var(--radius); font-size: 0.85rem; line-height: 1.4;
  box-shadow: 4px 4px 0 -1px var(--paper-3), 4px 4px 0 0 var(--line-strong);
}
.reduced-motion-notice strong { color: var(--race-red); font-weight: 700; }
.reduced-motion-notice button {
  flex-shrink: 0; width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 3px;
  color: var(--dim); font-size: 1.3rem; line-height: 1; cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.reduced-motion-notice button:hover { background: var(--paper-3); color: var(--ink); }
