/* ============================================================
   LAYOUT — fondo, cabecera, navegación, secciones
   ============================================================ */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

/* ------------------------------------------------------------
   FONDO
   Tres capas: grilla técnica enmascarada, puntos en las
   intersecciones y dos manchas de luz que se mueven muy lento.
   Nada de esto es un canvas: es CSS, pesa 0 y no gasta batería.
   ------------------------------------------------------------ */
.fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bg);
  overflow: hidden;
}

.fx-grid,
.fx-dots {
  position: absolute;
  inset: -10%;
  /* La máscara es lo que evita que la grilla compita con el texto:
     nítida arriba, desvanecida hacia abajo y a los costados. */
  -webkit-mask-image: radial-gradient(120% 80% at 50% 0%, #000 0%, #000 38%, transparent 82%);
          mask-image: radial-gradient(120% 80% at 50% 0%, #000 0%, #000 38%, transparent 82%);
}

.fx-grid {
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
}

.fx-dots {
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1.4px);
  background-size: 56px 56px;
  background-position: 0 0;
  opacity: .8;
}

.fx-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}
.fx-glow--a {
  width: 62vw; height: 62vw;
  min-width: 420px; min-height: 420px;
  top: -22vw; left: -12vw;
  background: var(--glow-a);
  animation: drift-a 88s var(--ease) infinite alternate;
}
.fx-glow--b {
  width: 48vw; height: 48vw;
  min-width: 340px; min-height: 340px;
  top: 4vw; right: -16vw;
  background: var(--glow-b);
  animation: drift-b 112s var(--ease) infinite alternate;
}

/* Movimiento deliberadamente lentísimo: si lo notas mientras lees,
   está mal calibrado. */
@keyframes drift-a {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(14vw, 8vh, 0) scale(1.14); }
  100% { transform: translate3d(4vw, 18vh, 0) scale(.96); }
}
@keyframes drift-b {
  0%   { transform: translate3d(0, 0, 0) scale(1.05); }
  50%  { transform: translate3d(-12vw, 12vh, 0) scale(.92); }
  100% { transform: translate3d(-4vw, 2vh, 0) scale(1.12); }
}

.fx-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 0%, transparent 45%, var(--bg) 100%);
}

/* ------------------------------------------------------------
   TOPBAR
   ------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__in {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 10px var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark { color: var(--acc); flex-shrink: 0; }
.brand__txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand__txt strong { font-size: 14.5px; font-weight: 600; letter-spacing: -0.02em; }
.brand__txt small { font-size: 11px; color: var(--ink-3); letter-spacing: .02em; }

.topbar__actions { display: flex; gap: 8px; }
.ghost-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 15px;
  transition: color var(--t), border-color var(--t), background var(--t);
}
.ghost-btn:hover { color: var(--ink); border-color: var(--line-2); }

/* ------------------------------------------------------------
   AVISO
   ------------------------------------------------------------ */
.notice {
  max-width: var(--shell);
  margin: 14px auto 0;
  padding: 11px 16px;
  border: 1px solid var(--wood);
  background: var(--wood-soft);
  color: var(--wood);
  border-radius: var(--r);
  font-size: 12.5px;
  line-height: 1.5;
}
.notice strong { color: var(--ink); }
@media (max-width: 1140px) { .notice { margin-inline: var(--pad-x); } }

/* ------------------------------------------------------------
   HERO
   ------------------------------------------------------------ */
.hero { padding: clamp(48px, 10vw, 96px) 0 clamp(28px, 5vw, 48px); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-3);
  margin-bottom: 20px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
}
.eyebrow .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-soft);
  animation: pulse 3.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

.hero__title {
  font-size: clamp(30px, 6.4vw, 54px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  max-width: 17ch;
  margin-bottom: 18px;
}
.hero__title em {
  font-style: normal;
  color: var(--acc);
}
.hero__lead {
  max-width: 58ch;
  color: var(--ink-2);
  font-size: clamp(14.5px, 2.4vw, 16.5px);
  line-height: 1.62;
}

.stats {
  margin: clamp(30px, 6vw, 48px) 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.stat {
  background: var(--bg-2);
  padding: 16px 18px;
}
.stat dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.stat dd {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.stat dd span {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.stat dd i {
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ------------------------------------------------------------
   FAENA
   ------------------------------------------------------------ */
.faena {
  border: 1px solid var(--acc-line);
  border-radius: var(--r-lg);
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: clamp(16px, 3.4vw, 22px);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.faena::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--acc), transparent);
  opacity: .5;
}
.faena__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.faena__title { font-size: 14px; letter-spacing: -0.01em; }
.faena__hint { font-size: 12px; color: var(--ink-3); }
.faena__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

/* ------------------------------------------------------------
   NAV DE MÓDULOS
   ------------------------------------------------------------ */
.modnav {
  position: sticky;
  top: 57px;
  z-index: 30;
  margin-top: clamp(30px, 6vw, 52px);
  padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-block: 1px solid var(--line);
}
.modnav__track {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad-x);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.modnav__track::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 99px;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--t), background var(--t), border-color var(--t);
}
.pill:hover { color: var(--ink); background: var(--surface-s); }
.pill.is-active {
  color: var(--acc);
  background: var(--acc-soft);
  border-color: var(--acc-line);
}

/* ------------------------------------------------------------
   MÓDULOS
   ------------------------------------------------------------ */
.mod { padding: clamp(44px, 9vw, 80px) 0 0; }
.mod:last-of-type { padding-bottom: clamp(44px, 9vw, 80px); }

.mod__head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: clamp(18px, 3.4vw, 26px);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.mod__idx {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  padding-top: 5px;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.mod__head h2 {
  font-size: clamp(20px, 3.6vw, 27px);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.mod__head p {
  color: var(--ink-2);
  font-size: 14px;
  max-width: 62ch;
  line-height: 1.55;
}
.mod--key .mod__head h2 { color: var(--acc); }

/* ------------------------------------------------------------
   REFERENCIA
   ------------------------------------------------------------ */
.refgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--gap);
}
.refcard {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  padding: 18px;
}
.refcard--key { border-color: var(--acc-line); background: var(--acc-soft); }
.refcard h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--acc);
  margin-bottom: 8px;
}
.refcard h3 + h3 { margin-top: 14px; }
.refcard code {
  display: block;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  margin-bottom: 6px;
  overflow-x: auto;
  white-space: nowrap;
}
.refcard p {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}
.refcard p code {
  display: inline;
  padding: 1px 5px;
  border: none;
  background: var(--raised);
  white-space: normal;
}

/* ------------------------------------------------------------
   FOOTER
   ------------------------------------------------------------ */
.foot {
  margin-top: clamp(48px, 9vw, 90px);
  border-top: 1px solid var(--line);
  padding: 26px 0 40px;
}
.foot__in {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ------------------------------------------------------------
   ENTRADA ANIMADA
   Los estados ocultos viven bajo .js y hay un temporizador en el
   script que quita la clase si algo falló. Sin JS, todo visible.
   ------------------------------------------------------------ */
.js .mod__head,
.js .panel,
.js .refcard,
.js .totals {
  opacity: 0;
  transform: translateY(14px);
}
.js .is-in {
  opacity: 1;
  transform: none;
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}

/* ------------------------------------------------------------
   MOVIMIENTO REDUCIDO
   Se apaga lo que se mueve solo. Los hovers y los fundidos quedan:
   sin ellos el sitio se ve muerto.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fx-glow { animation: none; }
  .eyebrow .dot { animation: none; }
}
