/* NETWORKING LAB · estilos de movimiento y microinteracción.
   Cada bloque recibe una sola animación de entrada; los efectos persistentes se limitan a elementos decorativos. */

@keyframes nl-rot     { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes nl-slide   { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes nl-flow-x  { from { background-position: 0% 50%; } to { background-position: 200% 50%; } }
@keyframes nl-in      { from { opacity: 0; } to { opacity: 1; } }
@keyframes nl-live    { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,.65); } 70%, 100% { box-shadow: 0 0 0 8px rgba(74,222,128,0); } }

/* Degradado de los títulos: del color del título al de acento claro (ambos ≥ 8:1 sobre el panel) */
[data-md-color-scheme="slate"]   { --nl-flow-b: #cbbcff; }
[data-md-color-scheme="default"] { --nl-flow-b: #5b14cc; }

/* ---------- Fondo: constelación (canvas) ---------- */
#nl-flow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; display: block; }
.md-container { position: relative; z-index: 1; }

/* ---------- Pausa fuera de pantalla (ahorra batería y mantiene 60 fps en móvil) ---------- */
.nl-pa:not(.nl-vis), .nl-pa:not(.nl-vis) *, .nl-pa:not(.nl-vis)::before, .nl-pa:not(.nl-vis)::after,
.nl-pa:not(.nl-vis) *::before, .nl-pa:not(.nl-vis) *::after { animation-play-state: paused !important; }

/* ---------- Barra de progreso de lectura ---------- */
#nl-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; pointer-events: none;
  transform-origin: 0 50%; transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--nl-brand), var(--nl-accent-2) 80%, #ffffff); box-shadow: 0 0 8px rgba(139,92,255,.55); }

/* ---------- Cabecera: línea de luz ---------- */
/* Línea fija (sin animación: el barrido causaba fallos en móviles). Se mantiene el degradado brillante a todo el ancho. */
.md-header::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 100%; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--nl-accent), var(--nl-accent-2), var(--nl-accent), transparent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--nl-accent) 55%, transparent); }

/* ---------- Revelado único de bloques ---------- */
/* Solo opacidad: evita competir con transformaciones de hover, zoom y estados activos. */
.nl-rv { opacity: 0; }
/* Las tarjetas de navegación de portada son contenido esencial y nunca se ocultan. */
.sx-cards, .md-typeset .sx-cards > a.sx-card { opacity: 1 !important; visibility: visible !important; }
.nl-rv.nl-in { animation: nl-in .55s ease-out var(--d, 0ms) both; }

/* ---------- Encabezados con flujo ---------- */
.md-typeset h1 { background: linear-gradient(100deg, var(--nl-h1), var(--nl-flow-b), var(--nl-h1)) 0 50% / 200% 100%;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  animation: nl-flow-x 12s linear infinite; }
.md-typeset h1 a.headerlink { -webkit-text-fill-color: currentColor; }
.md-typeset h2 { position: relative; padding-bottom: .42em; }
.md-typeset h2::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: min(100%, 15rem); border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--nl-accent), var(--nl-accent-2), var(--nl-accent), transparent) 0 50% / 200% 100%;
  animation: nl-flow-x 5s linear infinite; }

/* ---------- Enlaces, botones, tarjetas, avisos ---------- */
.md-typeset a:not(.md-button):not(.headerlink):not(.sx-card) { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1.5px no-repeat; transition: background-size .35s ease, color .2s; }
.md-typeset a:not(.md-button):not(.headerlink):not(.sx-card):hover { background-size: 100% 1.5px; }
.md-typeset .md-button { transition: transform .2s, background .2s, border-color .2s, box-shadow .2s; }
.md-typeset .md-button:active { transform: scale(.97); }
.md-typeset .md-button--primary { position: relative; overflow: hidden; }
.md-typeset .md-button--primary::after { content: ""; position: absolute; inset: 0; pointer-events: none; will-change: transform;
  background: linear-gradient(110deg, transparent 38%, rgba(255,255,255,.28) 50%, transparent 62%);
  animation: nl-slide 3.6s ease-in-out infinite; }
.md-typeset a.sx-card { position: relative; overflow: hidden; }
/* Las tarjetas no animan transform de forma continua: se reserva transform para hover/active. */
.md-typeset a.sx-card:active { transform: scale(.985); }
.md-typeset .admonition, .md-typeset details { transition: transform .25s, box-shadow .25s; }
.md-typeset .admonition:hover, .md-typeset details:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -18px var(--nl-glow); }
.md-nav__link--active { position: relative; }
.md-nav__link--active::before { content: ""; position: absolute; left: -.55rem; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%;
  background: var(--nl-accent-2); animation: nl-live 1.8s infinite; }

/* foco de luz bajo el puntero (solo dispositivos con ratón; en móvil no aporta y cuesta repintado) */
.admonition, .nl-fig { position: relative; }
@media (hover: hover) {
  .sx-card::before, .admonition::before, .nl-fig::before, .md-typeset__table::before {
    content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .3s;
    background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(160,120,255,.10), transparent 62%); }
  .sx-card:hover::before, .admonition:hover::before, .nl-fig:hover::before, .md-typeset__table:hover::before { opacity: 1; }
}

/* =====================================================
   TABLAS: marco, cabecera viva, cebra y fila activa
   Texto sobre filas ≥ 15:1 (oscuro) / ≥ 15:1 (claro); texto blanco sobre cabecera ≥ 6.9:1
   ===================================================== */
[data-md-color-scheme="default"] {
  --nl-tb-bd: #8a6fd8; --nl-tb-head-a: #4a0fa8; --nl-tb-head-b: #6d28d9; --nl-tb-head-fg: #ffffff;
  --nl-tb-odd: #ffffff; --nl-tb-even: #f2effb; --nl-tb-line: #d4d0e4; --nl-tb-fg: #16131f; --nl-tb-first: #2e1073; --nl-tb-hover: rgba(91,20,204,.10); --nl-tb-edge: #6d28d9;
}
[data-md-color-scheme="slate"] {
  --nl-tb-bd: #3c3170; --nl-tb-head-a: #4c11a8; --nl-tb-head-b: #6a2be0; --nl-tb-head-fg: #ffffff;
  --nl-tb-odd: #0e0e14; --nl-tb-even: #15151e; --nl-tb-line: #2c2c3c; --nl-tb-fg: #ececf2; --nl-tb-first: #ffffff; --nl-tb-hover: rgba(139,92,255,.18); --nl-tb-edge: #a78bfa;
}
.md-typeset .md-typeset__table { position: relative; display: block; width: 100%; margin: 1.7rem 0; padding: 0;
  border: 2px solid var(--nl-tb-bd); border-radius: 16px; overflow-x: auto; background: var(--nl-tb-odd); -webkit-overflow-scrolling: touch;
  box-shadow: 0 16px 40px -22px var(--nl-glow); }
.md-typeset .md-typeset__table table:not([class]) { display: table; width: 100%; min-width: 0; margin: 0; border: 0; border-collapse: collapse; background: transparent; box-shadow: none; }
.md-typeset .md-typeset__table th { position: relative; overflow: hidden; background: linear-gradient(100deg, var(--nl-tb-head-a), var(--nl-tb-head-b));
  color: var(--nl-tb-head-fg); font: 600 1em/1.3 var(--nl-f-head); letter-spacing: 0; text-transform: none;
  padding: .8em .9em; border: 0; border-bottom: 2px solid var(--nl-tb-edge); white-space: normal; text-align: left; }
.md-typeset .md-typeset__table th::after { content: ""; position: absolute; inset: 0; pointer-events: none; will-change: transform;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.16) 50%, transparent 65%); animation: nl-slide 5.5s ease-in-out infinite; }
.md-typeset .md-typeset__table td { color: var(--nl-tb-fg); padding: .7em .9em; border: 0; border-bottom: 1px solid var(--nl-tb-line); vertical-align: top; transition: background .2s, box-shadow .2s; }
.md-typeset .md-typeset__table tbody tr:nth-child(odd)  td { background: var(--nl-tb-odd); }
.md-typeset .md-typeset__table tbody tr:nth-child(even) td { background: var(--nl-tb-even); }
.md-typeset .md-typeset__table td:first-child { font-weight: 700; color: var(--nl-tb-first); }
.md-typeset .md-typeset__table tbody tr:last-child td { border-bottom: 0; }
.md-typeset .md-typeset__table tbody tr:hover td, .md-typeset .md-typeset__table tbody tr:active td { background: var(--nl-tb-hover); }
.md-typeset .md-typeset__table tbody tr:hover td:first-child { box-shadow: inset 4px 0 0 var(--nl-tb-edge); }
.md-typeset .md-typeset__table td code { background: var(--nl-code-bg); color: var(--nl-code-fg); border: 1px solid var(--nl-tb-line); border-radius: 6px; padding: .05em .4em; }

/* Tabla apilada: solo cuando no cabe ni con texto compacto. Cada fila pasa a ser un bloque «etiqueta + valor».
   Sin silabeo, alineada a la izquierda, ocupa el ancho disponible y nunca lo supera. */
.md-typeset .md-typeset__table table[data-nl-fit="stack"] { display: block; width: 100%; font-size: .9em; }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] tbody { display: block; }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] tr { display: block; border-bottom: 2px solid var(--nl-tb-edge); }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] tbody tr:last-child { border-bottom: 0; }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] td { display: block; width: auto; padding: .45em .8em; border: 0; }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] td:first-child { padding-top: .7em; font-size: 1.05em; box-shadow: inset 0 -1px 0 var(--nl-tb-line); }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] td:last-child { padding-bottom: .75em; }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] td:not(:first-child)::before { content: attr(data-label); display: block; margin-bottom: .1em; font: 600 .82em/1.3 var(--nl-f-head); color: var(--nl-tb-edge); }
.md-typeset .md-typeset__table table[data-nl-fit="stack"] td[data-label=""]::before { display: none; }

/* =====================================================
   TERMINALES: ventana oscura en ambos temas, con aro de luz giratorio (solo transform/opacity)
   Texto: comando #f2f2f7 18:1 · salida #cfcfdc 13:1 · prompt #b9a6ff 9.6:1 · ruta/nota #9a9ab3 7.4:1 (sobre #06060a)
   Estructura: ::before = aro cónico que gira · ::after = relleno interior (deja 2px de borde visible)
   ===================================================== */
.nl-term {
  --nl-t-bg: #06060a; --nl-t-head: #101018; --nl-t-fg: #f2f2f7; --nl-t-prompt: #b9a6ff; --nl-t-muted: #9a9ab3; --nl-t-out: #cfcfdc; --nl-t-btn: #1c1c2a; --nl-t-bd: #5b3fc4;
  position: relative; margin: 2rem 0; padding: 2px; border: 0; border-radius: 18px; overflow: hidden; isolation: isolate;
  background: var(--nl-t-bg);
  box-shadow: 0 16px 38px -20px rgba(0,0,0,.75), 0 0 30px -12px rgba(139,92,255,.30);
}
.nl-term::before { content: ""; position: absolute; z-index: -2; left: 50%; top: 50%; width: 145%; aspect-ratio: 1; will-change: transform, opacity;
  background: conic-gradient(from 0deg, #5b14cc, #8b5cff, #e7defc 9%, #8b5cff 16%, #5b14cc 30%, #2a0b6e 62%, #5b14cc);
  transform: translate(-50%, -50%);
  animation: nl-rot 8s linear infinite; }
.nl-term::after { content: ""; position: absolute; z-index: -1; inset: 2px; border-radius: 16px; background: var(--nl-t-bg); pointer-events: none; }
.nl-term__bar { position: relative; z-index: 2; overflow: hidden; border-radius: 16px 16px 0 0; background: linear-gradient(100deg, #12121c, #1d1840); border-bottom: 1px solid #34305a; }
.nl-term__bar::after { content: ""; position: absolute; inset: 0; pointer-events: none; will-change: transform;
  background: linear-gradient(100deg, transparent 38%, rgba(255,255,255,.07) 50%, transparent 62%); animation: nl-slide 6s linear infinite; }
.nl-term__dots i { border: 0; box-shadow: 0 0 6px currentColor; }
.nl-term__dots i:nth-child(1) { background: #ff5f57; color: rgba(255,95,87,.5); }
.nl-term__dots i:nth-child(2) { background: #febc2e; color: rgba(254,188,46,.5); }
.nl-term__dots i:nth-child(3) { background: #28c840; color: rgba(40,200,64,.5); }
.nl-term__badge { color: #ffffff; border-color: #7c5ce0; background: rgba(91,20,204,.45); }
.nl-term__badge::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: .5em; border-radius: 50%; background: #4ade80; animation: nl-live 1.6s infinite; vertical-align: 1px; }
.nl-term__path { color: #b0b0c6; }
.nl-term__body { position: relative; z-index: 2; border-radius: 0 0 16px 16px; font-size: .86rem; line-height: 1.6;
  background-image:
    radial-gradient(300px circle at var(--mx, 50%) var(--my, -40%), rgba(160,120,255,.08), transparent 62%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px); }
.nl-term__prompt { color: var(--nl-t-prompt); }
.nl-term__cmd { color: #ffffff; }
.nl-term__note { color: var(--nl-t-muted); font-style: italic; }
.nl-term__out { color: var(--nl-t-out); margin: .1rem 0 .4rem; padding-left: .75rem; border-left: 2px solid #6d4bd8; }
.nl-term__caret { box-shadow: 0 0 8px var(--nl-t-prompt); }
.nl-term__btn { color: #f2f2f7; min-width: 36px; min-height: 36px; }
.nl-term--full { padding: 0; border-radius: 0; background: var(--nl-t-bg); box-shadow: none; }
.nl-term--full::before, .nl-term--full::after { display: none; }
.nl-term--full .nl-term__bar, .nl-term--full .nl-term__body { border-radius: 0; }

/* ---------- Pausa manual de animaciones (WCAG 2.2.2): botón de la cabecera ---------- */
html[data-nl-motion="off"] *, html[data-nl-motion="off"] *::before, html[data-nl-motion="off"] *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
html[data-nl-motion="off"] .nl-rv { opacity: 1 !important; transform: none !important; }
html[data-nl-motion="off"] #nl-flow { display: none; }
.nl-motion-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nl-motion-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nl-motion-btn .nl-i-play { display: none; }
html[data-nl-motion="off"] .nl-motion-btn .nl-i-play { display: block; }
html[data-nl-motion="off"] .nl-motion-btn .nl-i-pause { display: none; }

@media (hover: none) { .md-typeset .admonition:hover, .md-typeset details:hover { transform: none; } }
@media (max-width: 40em) {
  .md-typeset .md-typeset__table { border-radius: 12px; margin: 1.3rem 0; }
  .nl-term { border-radius: 14px; margin: 1.5rem 0; }
  .nl-term::after { border-radius: 12px; }
  .nl-term__bar { border-radius: 12px 12px 0 0; }
  .nl-term__body { border-radius: 0 0 12px 12px; font-size: .78rem; }
}
@media print { .nl-rv { opacity: 1 !important; transform: none !important; animation: none !important; } #nl-flow, #nl-progress { display: none !important; } }

/* ---------- Corrección móvil: menú lateral y contenido oculto ----------
   .md-container y .md-main creaban un contexto de apilamiento (z-index:1) que dejaba el cajón del menú
   por debajo de .md-overlay (oscurecido, sin poder tocarse). Los fondos animados pasan a z-index:-1. */
@media (max-width: 76.1875em) {
  .md-container, .md-main { z-index: auto; }
  #nl-flow, body::before { z-index: -1; }
  .md-sidebar--primary .md-sidebar__scrollwrap { background: var(--nl-bg); backdrop-filter: none; -webkit-backdrop-filter: none; border-radius: 0; }
  .md-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
