/* =========================================================================
   Guía 5 · Teoría General de Sistemas → Arquitectura de Software → IA
   Hoja de estilo principal (autosuficiente: la página es legible y usable
   aunque el CDN de Tailwind no cargue). Tailwind sólo afina utilidades.
   Estética: IDE en modo oscuro. Mobile-first 320px → 2560px.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Tokens
   ------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* Superficies */
  --bg: #070a0f;
  --bg-1: #0b1119;
  --bg-2: #101a24;
  --bg-3: #16222f;
  --bg-elev: #0e1620;

  /* Líneas */
  --line: #1e2c3b;
  --line-soft: #17222e;
  --line-hot: #2a3d51;

  /* Texto */
  --txt: #dce6f2;
  --txt-dim: #96a8bd;
  --txt-mute: #64768c;

  /* Acentos */
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --emerald: #34d399;
  --rose: #fb7185;
  --blue: #60a5fa;

  /* Olas TGS */
  --w1: #fbbf24; /* Ola 1 · cibernética / sistema cerrado */
  --w2: #22d3ee; /* Ola 2 · sistema abierto */
  --w3: #a78bfa; /* Ola 3 · complejidad / CAS */

  /* Fondos sólidos para insignias (nunca translúcidos: el contraste
     debe ser estable sobre cualquier superficie) */
  --w1-bg: #221a08;
  --w2-bg: #07212b;
  --w3-bg: #17112c;
  --ok-bg: #06201a;
  --bad-bg: #260f16;
  --w1-line: #6b5313;
  --w2-line: #12596b;
  --w3-line: #4a3a86;
  --ok-line: #14624b;
  --bad-line: #6b2733;

  /* Tipografía */
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
    Consolas, "Liberation Mono", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* Métrica */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.9);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--cyan);

  --wrap: 1400px;
  --pad-x: clamp(1rem, 4vw, 3.5rem);
}

/* -------------------------------------------------------------------------
   2. Reset conservador
   ------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1.05rem);
  line-height: 1.7;
  overflow-wrap: break-word;
  word-break: normal;
  background-image: radial-gradient(
      ellipse 80% 55% at 50% -10%,
      rgba(34, 211, 238, 0.09),
      transparent 60%
    ),
    radial-gradient(ellipse 60% 50% at 90% 8%, rgba(167, 139, 250, 0.07), transparent 60%),
    linear-gradient(180deg, transparent, transparent);
  background-attachment: fixed;
}

img,
svg,
canvas {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4 {
  line-height: 1.18;
  margin: 0 0 0.6rem;
  letter-spacing: -0.02em;
  font-weight: 700;
  text-wrap: balance;
}

p {
  margin: 0 0 1rem;
}

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
}

li {
  margin-bottom: 0.4rem;
}

a {
  color: var(--cyan);
  text-underline-offset: 3px;
}

strong {
  color: #fff;
  font-weight: 650;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgba(34, 211, 238, 0.3);
  color: #fff;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* Barras de desplazamiento estilo IDE */
* {
  scrollbar-width: thin;
  scrollbar-color: #24344a transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: #24344a;
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: #33475f;
  background-clip: padding-box;
}

/* -------------------------------------------------------------------------
   3. Utilidades propias
   ------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

.mono {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

.dim {
  color: var(--txt-dim);
}
.mute {
  color: var(--txt-mute);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 999;
  background: var(--cyan);
  color: #04121a;
  font-weight: 700;
  padding: 0.6rem 1rem;
  border-radius: var(--r-sm);
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0.75rem;
}

.stack > * + * {
  margin-top: var(--gap, 1rem);
}

.grid {
  display: grid;
  gap: clamp(0.9rem, 2vw, 1.4rem);
}
.g2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}
.g3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}
.g4 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
}

/* -------------------------------------------------------------------------
   4. Encabezado y navegación
   ------------------------------------------------------------------------- */
.scroll-progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--w1), var(--w2) 50%, var(--w3));
  z-index: 80;
  transition: width 0.08s linear;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(7, 10, 15, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.hdr {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 60px;
  padding-block: 0.55rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  flex: 0 1 auto;
  min-width: 0; /* permite que el rótulo encoja en 320 px en vez de desbordar */
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #04121a;
  background: linear-gradient(145deg, var(--cyan), #0ea5b7);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 6px 18px -8px var(--cyan);
}

.brand-copy {
  min-width: 0;
}
.brand-copy strong {
  display: block;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}
.brand-copy small {
  display: none;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--txt-mute);
  letter-spacing: 0.04em;
}
.brand-long {
  display: none;
}
@media (min-width: 560px) {
  .brand-copy small {
    display: block;
  }
}
@media (min-width: 700px) {
  .brand-short {
    display: none;
  }
  .brand-long {
    display: inline;
  }
}

.nav {
  display: none;
  gap: 0.15rem;
  margin-left: auto;
  overflow-x: auto;
}

.nav-a {
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--txt-dim);
  text-decoration: none;
  padding: 0.45rem 0.6rem;
  border-radius: var(--r-sm);
  white-space: nowrap;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-a:hover {
  color: var(--txt);
  background: var(--bg-2);
}
.nav-a.is-active {
  color: var(--cyan);
  border-color: var(--line-hot);
  background: rgba(34, 211, 238, 0.08);
}

.hdr-side {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hdr-status {
  display: none;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--txt-mute);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line-soft);
  border-radius: 99px;
  background: var(--bg-1);
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.nav-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--txt-dim);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  cursor: pointer;
}

.nav-drawer {
  display: grid;
  gap: 0.2rem;
  padding: 0.5rem var(--pad-x) 0.9rem;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-1);
}
.nav-drawer[hidden] {
  display: none;
}

@media (min-width: 1024px) {
  .nav {
    display: flex;
  }
  .nav-toggle {
    display: none;
  }
  .nav-drawer {
    display: none !important;
  }
}
@media (min-width: 1280px) {
  .hdr-status {
    display: inline-flex;
  }
}

/* -------------------------------------------------------------------------
   5. Secciones
   ------------------------------------------------------------------------- */
.section {
  padding-block: clamp(2.75rem, 6vw, 5.5rem);
  position: relative;
  border-top: 1px solid var(--line-soft);
}
.section:first-of-type {
  border-top: 0;
}
.section--alt {
  background: linear-gradient(180deg, rgba(11, 17, 25, 0.85), rgba(7, 10, 15, 0));
}

.sec-head {
  max-width: 78ch;
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
  margin: 0 0 0.7rem;
}
.kicker::before {
  content: "";
  width: 26px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.sec-head h2 {
  font-size: clamp(1.6rem, 1.1rem + 2.4vw, 2.85rem);
}
.sec-head h2 span {
  color: var(--txt-mute);
}

.lede {
  color: var(--txt-dim);
  font-size: clamp(1rem, 0.95rem + 0.35vw, 1.15rem);
  max-width: 72ch;
}

/* -------------------------------------------------------------------------
   6. Panel tipo ventana de IDE
   ------------------------------------------------------------------------- */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.85rem;
  background: linear-gradient(180deg, #131d29, #0e1620);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--txt-mute);
}

.dots {
  display: flex;
  gap: 0.35rem;
  flex: 0 0 auto;
}
.dots i {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: #2a3a4c;
  display: block;
}
.dots i:nth-child(1) {
  background: #f2585b;
}
.dots i:nth-child(2) {
  background: #f5bd4f;
}
.dots i:nth-child(3) {
  background: #4bc26b;
}

.panel-title {
  overflow-wrap: break-word;
}
.panel-bar .spacer {
  margin-left: auto;
}

.panel-body {
  padding: clamp(0.95rem, 2.4vw, 1.6rem);
}

/* -------------------------------------------------------------------------
   7. Bloques de código
   ------------------------------------------------------------------------- */
.code {
  background: #060a10;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
  margin: 0 0 1rem;
}
.code figcaption {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--txt-mute);
  padding: 0.45rem 0.8rem;
  border-bottom: 1px solid var(--line-soft);
  background: #0a1119;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.code pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: clamp(0.76rem, 0.72rem + 0.15vw, 0.86rem);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
}
.t-com {
  color: #5b7288;
  font-style: italic;
}
.t-key {
  color: #c792ea;
}
.t-str {
  color: #a5e075;
}
.t-num {
  color: #f78c6c;
}
.t-fn {
  color: #82aaff;
}
.t-hi {
  color: var(--cyan);
}
.t-warn {
  color: var(--rose);
}

/* -------------------------------------------------------------------------
   8. Piezas de contenido
   ------------------------------------------------------------------------- */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: clamp(0.95rem, 2vw, 1.35rem);
  height: 100%;
}
.card h3 {
  font-size: 1.02rem;
}
.card p:last-child {
  margin-bottom: 0;
}

.card--w1 {
  border-top: 2px solid var(--w1);
}
.card--w2 {
  border-top: 2px solid var(--w2);
}
.card--w3 {
  border-top: 2px solid var(--w3);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--txt-dim);
  white-space: normal;
}
.chip--w1 {
  color: var(--w1);
  border-color: var(--w1-line);
  background: var(--w1-bg);
}
.chip--w2 {
  color: var(--w2);
  border-color: var(--w2-line);
  background: var(--w2-bg);
}
.chip--w3 {
  color: var(--w3);
  border-color: var(--w3-line);
  background: var(--w3-bg);
}
.chip--ok {
  color: var(--emerald);
  border-color: var(--ok-line);
  background: var(--ok-bg);
}
.chip--bad {
  color: var(--rose);
  border-color: var(--bad-line);
  background: var(--bad-bg);
}

.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.07), rgba(34, 211, 238, 0));
  border-radius: 0 var(--r) var(--r) 0;
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}
.callout > :last-child {
  margin-bottom: 0;
}
.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.5rem;
}
.callout--law {
  border-left-color: var(--amber);
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.07), transparent);
}
.callout--law .callout-title {
  color: var(--amber);
}
.callout--warn {
  border-left-color: var(--rose);
  background: linear-gradient(90deg, rgba(251, 113, 133, 0.07), transparent);
}
.callout--warn .callout-title {
  color: var(--rose);
}
.callout--note {
  border-left-color: var(--violet);
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.07), transparent);
}
.callout--note .callout-title {
  color: var(--violet);
}

.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--bg-1);
}
table.matrix {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.88rem;
}
table.matrix th,
table.matrix td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
table.matrix thead th {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--txt-mute);
  background: var(--bg-2);
  position: sticky;
  top: 0;
}
table.matrix tbody tr:last-child td {
  border-bottom: 0;
}
table.matrix tbody tr:hover td {
  background: rgba(34, 211, 238, 0.04);
}

details.acc {
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--bg-1);
  margin-bottom: 0.6rem;
  overflow: hidden;
}
details.acc > summary {
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}
details.acc > summary::-webkit-details-marker {
  display: none;
}
details.acc > summary::before {
  content: "▸";
  color: var(--cyan);
  font-family: var(--mono);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
  line-height: 1.6;
}
details.acc[open] > summary::before {
  transform: rotate(90deg);
}
details.acc .acc-body {
  padding: 0 1rem 1rem 2.05rem;
  color: var(--txt-dim);
}
details.acc .acc-body > :last-child {
  margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   9. Botones
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.62rem 1.05rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--txt);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s, border-color 0.15s, color 0.15s;
  min-height: 40px;
}
.btn:hover {
  background: var(--bg-3);
  border-color: var(--line-hot);
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn--primary {
  background: linear-gradient(145deg, var(--cyan), #0ea5b7);
  border-color: transparent;
  color: #04121a;
  font-weight: 700;
}
.btn--primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(145deg, var(--cyan), #0ea5b7);
}
.btn--violet {
  background: linear-gradient(145deg, var(--violet), #7c5cf0);
  border-color: transparent;
  color: #0d0620;
  font-weight: 700;
}
.btn--danger {
  color: var(--rose);
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.08);
}
.btn--sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.72rem;
  min-height: 32px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

/* -------------------------------------------------------------------------
   10. Portada
   ------------------------------------------------------------------------- */
.hero {
  display: grid;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: center;
  padding-block: clamp(2.5rem, 7vw, 5.5rem);
}
@media (min-width: 1024px) {
  .hero {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

.hero h1 {
  font-size: clamp(2rem, 1.2rem + 4.4vw, 4.1rem);
  margin-bottom: 1.1rem;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--w1), var(--w2) 45%, var(--w3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.4rem;
}

.hero-term {
  font-family: var(--mono);
  font-size: clamp(0.72rem, 0.68rem + 0.2vw, 0.82rem);
  line-height: 1.75;
}
.hero-term .ln {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.5rem;
}
.hero-term .ln > span:first-child {
  color: #2f4257;
  text-align: right;
  user-select: none;
}

/* -------------------------------------------------------------------------
   11. Ruta de fases (Reflexión → Transferencia)
   ------------------------------------------------------------------------- */
.phases {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr));
  counter-reset: fase;
}
.phase {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 1rem 1rem 1rem 1rem;
}
.phase::before {
  counter-increment: fase;
  content: "0" counter(fase);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
}
.phase h3 {
  font-size: 0.98rem;
  margin: 0.25rem 0 0.4rem;
}
.phase p {
  color: var(--txt-dim);
  font-size: 0.88rem;
  margin: 0;
}

/* -------------------------------------------------------------------------
   12. Explorador de olas
   ------------------------------------------------------------------------- */
.wave-tabs {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  margin-bottom: 1.2rem;
}
.wave-tab {
  text-align: left;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--tab, var(--line));
  border-radius: var(--r);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.wave-tab:hover {
  background: var(--bg-2);
  transform: translateY(-1px);
}
.wave-tab[aria-selected="true"] {
  background: var(--bg-2);
  border-color: var(--line-hot);
  border-left-color: var(--tab);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}
.wave-tab .wt-id {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--tab);
  text-transform: uppercase;
}
.wave-tab .wt-name {
  display: block;
  font-weight: 650;
  margin-top: 0.15rem;
}
.wave-tab .wt-sub {
  display: block;
  font-size: 0.8rem;
  color: var(--txt-mute);
}

.wave-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 900px) {
  .wave-grid {
    grid-template-columns: 1.15fr 0.85fr;
  }
}

.kv {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--line-soft);
}
.kv:last-child {
  border-bottom: 0;
}
.kv dt {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--txt-mute);
}
.kv dd {
  margin: 0;
  color: var(--txt);
}

/* -------------------------------------------------------------------------
   13. Mapa evolutivo (SVG generado)
   ------------------------------------------------------------------------- */
.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.9rem;
}

.map-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: var(--r);
  background: #060a10;
  border: 1px solid var(--line-soft);
}
.map-scroll svg {
  min-width: 940px;
  height: auto;
  display: block;
}

.era-node {
  cursor: pointer;
}
.era-node rect {
  transition: fill 0.15s, stroke 0.15s;
}
.era-node:hover rect,
.era-node[data-active="true"] rect {
  fill: #16222f;
  stroke: var(--cyan);
}
.era-node text {
  pointer-events: none;
}

.map-detail {
  margin-top: 1rem;
}

.mermaid-host {
  background: #060a10;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 1rem;
  overflow-x: auto;
}
.mermaid-host svg {
  max-width: none;
  height: auto;
}

/* -------------------------------------------------------------------------
   14. Simulador de red neuronal
   ------------------------------------------------------------------------- */
.sim {
  display: grid;
  gap: 1rem;
}
@media (min-width: 1080px) {
  .sim {
    grid-template-columns: minmax(0, 1fr) 330px;
    align-items: start;
  }
}

.sim-stage {
  display: grid;
  gap: 0.85rem;
}
@media (min-width: 720px) {
  .sim-stage {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }
}

.canvas-box {
  position: relative;
  background: #05080d;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
}
.canvas-box > canvas {
  width: 100%;
  height: auto;
  display: block;
}
.canvas-label {
  position: absolute;
  top: 0.5rem;
  left: 0.6rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  color: var(--txt-mute);
  background: rgba(5, 8, 13, 0.75);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  pointer-events: none;
}

.sim-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 118px), 1fr));
  gap: 0.5rem;
}
.metric {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.65rem;
}
.metric .m-lab {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--txt-mute);
}
.metric .m-val {
  display: block;
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--txt);
  margin-top: 0.15rem;
}

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  padding: 0.35rem 0.7rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--txt-dim);
}
.state-badge[data-state="homeostasis"] {
  color: var(--emerald);
  border-color: var(--ok-line);
  background: var(--ok-bg);
}
.state-badge[data-state="perturbado"] {
  color: var(--amber);
  border-color: var(--w1-line);
  background: var(--w1-bg);
}
.state-badge[data-state="divergente"],
.state-badge[data-state="abierto"] {
  color: var(--rose);
  border-color: var(--bad-line);
  background: var(--bad-bg);
}
.state-badge[data-state="atrapado"] {
  color: var(--violet);
  border-color: var(--w3-line);
  background: var(--w3-bg);
}

.ctl-panel {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 0.95rem;
  display: grid;
  gap: 0.85rem;
}

.ctl {
  display: grid;
  gap: 0.3rem;
}
.ctl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--txt-dim);
}
.ctl-head b {
  color: var(--cyan);
  font-weight: 600;
}
.ctl-hint {
  font-size: 0.72rem;
  color: var(--txt-mute);
  line-height: 1.5;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  height: 22px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-3);
  border-radius: 99px;
  border: 1px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -7px;
  border-radius: 99px;
  background: var(--cyan);
  border: 2px solid #04121a;
  box-shadow: 0 0 0 1px var(--cyan);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--bg-3);
  border-radius: 99px;
  border: 1px solid var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 99px;
  background: var(--cyan);
  border: 2px solid #04121a;
}

select,
input[type="text"],
textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  min-height: 38px;
}
textarea {
  line-height: 1.6;
  resize: vertical;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}
.switch span {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--txt-dim);
}
.switch input {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 18px;
  border-radius: 99px;
  background: #2a3a4c;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  margin: 0;
  transition: background 0.15s;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 99px;
  background: #7a8ca1;
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked {
  background: rgba(52, 211, 153, 0.35);
}
.switch input:checked::after {
  transform: translateX(16px);
  background: var(--emerald);
}

.term-log {
  background: #05080d;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 0.6rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.71rem;
  line-height: 1.7;
  height: 150px;
  overflow-y: auto;
  color: var(--txt-dim);
}
.term-log p {
  margin: 0;
  overflow-wrap: break-word;
}
.term-log .t {
  color: #35506b;
}
.term-log .ok {
  color: var(--emerald);
}
.term-log .warn {
  color: var(--amber);
}
.term-log .err {
  color: var(--rose);
}
.term-log .info {
  color: var(--cyan);
}

/* -------------------------------------------------------------------------
   15. Laboratorio de arquitectura (micro-reto)
   ------------------------------------------------------------------------- */
.lab {
  display: grid;
  gap: 1rem;
}
@media (min-width: 1080px) {
  .lab {
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: start;
  }
}

.tray {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 0.85rem;
  display: grid;
  gap: 0.45rem;
  align-content: start;
}
.tray h3 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--txt-mute);
  margin: 0 0 0.2rem;
}

.piece {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 0.55rem;
  align-items: start;
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.65rem;
  cursor: grab;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.piece:hover {
  border-color: var(--line-hot);
  background: var(--bg-3);
}
.piece:active {
  cursor: grabbing;
}
.piece[aria-pressed="true"] {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan);
  background: rgba(34, 211, 238, 0.08);
}
.piece[data-used="true"] {
  opacity: 0.35;
  pointer-events: none;
}
.piece .p-ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--cyan);
  font-size: 0.78rem;
}
.piece .p-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
}
.piece .p-kind {
  display: block;
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--txt-mute);
  letter-spacing: 0.04em;
}

.board {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr));
}

.slot {
  display: grid;
  gap: 0.3rem;
  align-content: start;
  text-align: left;
  min-height: 118px;
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.012),
    rgba(255, 255, 255, 0.012) 8px,
    transparent 8px,
    transparent 16px
  );
  border: 1px dashed var(--line-hot);
  border-radius: var(--r);
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.slot:hover,
.slot[data-over="true"] {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.06);
}
.slot .s-zone {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cyan);
}
.slot .s-ask {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}
.slot .s-why {
  font-size: 0.74rem;
  color: var(--txt-mute);
  line-height: 1.5;
}
.slot .s-fill {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  overflow-wrap: break-word;
}
.slot[data-verdict="ok"] {
  border-style: solid;
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(52, 211, 153, 0.05);
}
.slot[data-verdict="ok"] .s-fill {
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--emerald);
}
.slot[data-verdict="bad"] {
  border-style: solid;
  border-color: rgba(251, 113, 133, 0.55);
  background: rgba(251, 113, 133, 0.05);
}
.slot[data-verdict="bad"] .s-fill {
  border-color: rgba(251, 113, 133, 0.45);
  color: var(--rose);
}
.slot .s-verdict {
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--txt-dim);
  border-top: 1px dashed var(--line-soft);
  padding-top: 0.4rem;
  margin-top: 0.15rem;
}

.bars {
  display: grid;
  gap: 0.55rem;
}
.bar-row {
  display: grid;
  gap: 0.25rem;
}
.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--txt-dim);
}
.bar {
  height: 7px;
  border-radius: 99px;
  background: var(--bg-3);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.bar-fill[data-low="true"] {
  background: linear-gradient(90deg, var(--rose), var(--amber));
}

/* -------------------------------------------------------------------------
   16. Quiz de apropiación
   ------------------------------------------------------------------------- */
.quiz-q {
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--bg-1);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.quiz-q h3 {
  font-size: 0.98rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.quiz-q h3 .qn {
  font-family: var(--mono);
  color: var(--cyan);
  font-size: 0.78rem;
  flex: 0 0 auto;
  padding-top: 0.15rem;
}
.opts {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.opt {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.55rem;
  align-items: start;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s;
}
.opt:hover {
  border-color: var(--line-hot);
}
.opt .o-key {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--txt-mute);
  border: 1px solid var(--line);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}
.opt[data-r="ok"] {
  border-color: rgba(52, 211, 153, 0.6);
  background: rgba(52, 211, 153, 0.08);
}
.opt[data-r="ok"] .o-key {
  color: var(--emerald);
  border-color: var(--emerald);
}
.opt[data-r="bad"] {
  border-color: rgba(251, 113, 133, 0.6);
  background: rgba(251, 113, 133, 0.08);
}
.opt[data-r="bad"] .o-key {
  color: var(--rose);
  border-color: var(--rose);
}
.quiz-why {
  margin-top: 0.6rem;
  font-size: 0.84rem;
  color: var(--txt-dim);
  border-left: 2px solid var(--cyan);
  padding-left: 0.7rem;
}

/* -------------------------------------------------------------------------
   17. Glosario
   ------------------------------------------------------------------------- */
.glo-search {
  max-width: 420px;
  margin-bottom: 1rem;
}
.glo-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
}
.glo-item {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--cyan);
  border-radius: var(--r-sm);
  padding: 0.7rem 0.85rem;
}
.glo-item h3 {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.glo-item p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--txt-dim);
}
.glo-item .glo-eng {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--txt-mute);
}

/* -------------------------------------------------------------------------
   18. Diagnóstico de reflexión
   ------------------------------------------------------------------------- */
.symptoms {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 265px), 1fr));
}
.symptom {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 0.6rem;
  align-items: start;
  text-align: left;
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1.5;
}
.symptom:hover {
  border-color: var(--line-hot);
}
.symptom .s-box {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--line-hot);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  color: transparent;
  margin-top: 0.15rem;
}
.symptom[aria-pressed="true"] {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.07);
}
.symptom[aria-pressed="true"] .s-box {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #04121a;
}

/* -------------------------------------------------------------------------
   19. Pie
   ------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line-soft);
  padding-block: 2.5rem 3rem;
  color: var(--txt-mute);
  font-size: 0.85rem;
}
.foot-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}
.site-footer h4 {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--txt-dim);
  margin-bottom: 0.5rem;
}
.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* -------------------------------------------------------------------------
   20. Estados de carga y accesibilidad de movimiento
   ------------------------------------------------------------------------- */
/* Islas Vue: se ocultan hasta el montaje para evitar el destello de plantilla.
   Si Vue no carga, app.js retira el atributo y sustituye por un aviso. */
[v-cloak] {
  display: none;
}

.js-fallback {
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08);
  color: var(--amber);
  border-radius: var(--r);
  padding: 0.85rem 1rem;
  font-size: 0.86rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* -------------------------------------------------------------------------
   21. Impresión
   ------------------------------------------------------------------------- */
@media print {
  body {
    background: #fff;
    color: #111;
  }
  .site-header,
  .scroll-progress,
  .btn,
  .ctl-panel,
  .tray,
  .nav-drawer {
    display: none !important;
  }
  .panel,
  .card,
  .callout {
    border: 1px solid #ccc;
    box-shadow: none;
    background: #fff;
    color: #111;
  }
}
