/* ══════════════════════════════════════════════════════════════
   SISTEMA EXPEDIENTE — CUANTICA-IT
   Mundo visual: expediente técnico parcialmente desclasificado.
   Papel técnico frío en light, navy profundo en dark.
   Reglas: monospace SOLO para datos/cifras/versiones; una sola
   pieza viva (Dotted Surface); contraste AA en ambos temas.
   ══════════════════════════════════════════════════════════════ */

:root {
  --exp-ink: #0A2B4C;               /* tinta principal (light) */
  --exp-ink-2: #3d5a77;             /* tinta secundaria (4.6:1 sobre papel) */
  --exp-paper: #fafbfc;             /* papel técnico frío, no crema */
  --exp-paper-2: #f1f4f7;
  --exp-rule: rgba(10, 43, 76, 0.16);   /* hairlines */
  --exp-rule-strong: rgba(10, 43, 76, 0.38);
  --exp-accent: #b45309;            /* ámbar sello (4.6:1 sobre papel) */
  --exp-accent-bright: #d97706;
  --exp-action: #0066D6;            /* azul interactivo AA sobre papel */
  --redact-bg: #0A2B4C;             /* barra censura light: tinta sólida */
  --redact-label: #b45309;
}
html.dark {
  --exp-ink: #eef3f8;
  --exp-ink-2: #a8bccf;
  --exp-paper: #071A2B;
  --exp-paper-2: #0d2438;
  --exp-rule: rgba(238, 243, 248, 0.14);
  --exp-rule-strong: rgba(238, 243, 248, 0.34);
  --exp-accent: #f5a623;            /* ámbar claro AA sobre navy */
  --exp-accent-bright: #fbbf24;
  --exp-action: #4da9ff;
  --redact-bg: #d7e3ee;             /* invertido: barra clara sobre navy */
  --redact-label: #f5a623;
}

/* ── Tipografía de datos ─────────────────────────────────────── */
.dato,
.exp-num,
.exp-meta,
.stamp {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.exp-meta {
  font-size: 0.75rem;
  color: var(--exp-ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Numeración de norma técnica ─────────────────────────────── */
.exp-num {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--exp-accent);
  border: 1px solid var(--exp-rule-strong);
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  display: inline-block;
  line-height: 1;
}

/* ── Reglas / separadores de documento ───────────────────────── */
.exp-rule-t { border-top: 1px solid var(--exp-rule); }
.exp-rule-b { border-bottom: 1px solid var(--exp-rule); }
.exp-section {
  border-top: 1px solid var(--exp-rule-strong);
}

/* ── Barra de censura ────────────────────────────────────────── */
.redacted {
  display: inline-block;
  height: 1em;
  min-width: 6ch;
  vertical-align: text-bottom;
  background: var(--redact-bg);
  border-radius: 2px;
  position: relative;
  /* esquinas levemente irregulares: censura de plumón, no CSS perfecto */
  clip-path: polygon(0 8%, 100% 0, 99% 92%, 1% 100%);
}
.redacted-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.redacted-note {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6875rem;
  color: var(--redact-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Sello (stamp) ───────────────────────────────────────────── */
.stamp {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--exp-accent);
  border: 2px solid var(--exp-accent);
  border-radius: 3px;
  padding: 0.3rem 0.7rem;
  transform: rotate(-1.5deg);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 40'%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0.25'/%3E%3CfeComposite operator='in' in2='SourceGraphic'/%3E%3C/filter%3E%3Crect width='200' height='40' filter='url(%23r)'/%3E%3C/svg%3E");
  -webkit-mask-size: cover;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 40'%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9 0.25'/%3E%3CfeComposite operator='in' in2='SourceGraphic'/%3E%3C/filter%3E%3Crect width='200' height='40' filter='url(%23r)'/%3E%3C/svg%3E");
  mask-size: cover;
}

/* ── Ficha (dossier card) ────────────────────────────────────── */
.ficha {
  background: var(--exp-paper);
  border: 1px solid var(--exp-rule-strong);
  border-radius: 6px;
  position: relative;
}
html.dark .ficha {
  background: var(--exp-paper-2);
}
.ficha-tab {
  position: absolute;
  top: -0.85rem;
  left: 1.25rem;
  background: var(--exp-accent);
  color: #fff;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 3px 3px 0 0;
}
html.dark .ficha-tab { color: #071A2B; }
.ficha-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--exp-rule);
}
.ficha-row:last-child { border-bottom: none; }
.ficha-row dt {
  font-size: 0.8125rem;
  color: var(--exp-ink-2);
}
.ficha-row dd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--exp-ink);
  text-align: right;
}

/* ── Botón de tinta: contraste garantizado en ambos temas ────── */
.btn-ink {
  background: #0A2B4C;
  color: #ffffff;
}
html.dark .btn-ink {
  background: #eef3f8;
  color: #071A2B;
}

/* ── Fondo cuadrícula de plano técnico (muy sutil) ───────────── */
.exp-grid-bg {
  background-image:
    linear-gradient(var(--exp-rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--exp-rule) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ── Selección y caret con la tinta del mundo ────────────────── */
::selection {
  background: rgba(217, 119, 6, 0.25);
  color: var(--exp-ink);
}
input, textarea { caret-color: var(--exp-accent-bright); }

/* ── Hero humano: fotos con Ken Burns + crossfade (estilo VitalRed,
   gramática Expediente). La máscara funde la foto hacia el texto y
   hacia abajo, dejando visible la ola de puntos; el lavado de papel
   /navy garantiza AA sobre el titular. Reduced-motion: primera foto
   estática. ── */
.hero-humanos {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(97deg, transparent 2%, rgba(0,0,0,0.45) 34%, #000 60%, #000 100%);
  mask-image: linear-gradient(97deg, transparent 2%, rgba(0,0,0,0.45) 34%, #000 60%, #000 100%);
}
.hero-humanos img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  animation: hero-ken 22s ease-in-out infinite;
  will-change: opacity, transform;
}
.hero-humanos img:nth-child(1) { animation-delay: 0s; }
.hero-humanos img:nth-child(2) { animation-delay: 11s; }
.hero-humanos img:nth-child(3) { animation-delay: 22s; }
/* Lavado del sistema encima de la foto (bajo el contenido) */
.hero-humanos::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--exp-paper) 0%, rgba(250,251,252,0.72) 42%, rgba(250,251,252,0.30) 70%, rgba(250,251,252,0.45) 100%),
    linear-gradient(0deg, var(--exp-paper) 2%, transparent 30%);
}
html.dark .hero-humanos::after {
  background:
    linear-gradient(90deg, #071A2B 0%, rgba(7,26,43,0.78) 42%, rgba(7,26,43,0.42) 70%, rgba(7,26,43,0.55) 100%),
    linear-gradient(0deg, #071A2B 2%, transparent 30%);
}
@keyframes hero-ken {
  0%   { opacity: 0; transform: scale(1); }
  6%   { opacity: 1; }
  50%  { opacity: 1; transform: scale(1.07); }
  60%  { opacity: 0; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-humanos img { animation: none; }
  .hero-humanos img:first-child { opacity: 1; }
}
@media (max-width: 1023px) {
  .hero-humanos::after {
    background:
      linear-gradient(180deg, rgba(250,251,252,0.88) 0%, rgba(250,251,252,0.75) 60%, var(--exp-paper) 100%);
  }
  html.dark .hero-humanos::after {
    background:
      linear-gradient(180deg, rgba(7,26,43,0.88) 0%, rgba(7,26,43,0.78) 60%, #071A2B 100%);
  }
}

/* ── Cierre navy con aurora: el "video de fondo" del sistema ───
   Degradado animado generado a la medida (2KB, no un mp4): dos
   masas de luz ámbar/azul que derivan lento sobre el navy, bajo
   la cuadrícula técnica. GPU-barato (solo transform/opacity),
   loop perfecto, y estático si el usuario pide menos movimiento. */
.cierre-navy {
  position: relative;
  overflow: hidden;
  background: #0A2B4C;
  isolation: isolate;
}
html.dark .cierre-navy { background: #0d2438; }
.cierre-navy::before,
.cierre-navy::after {
  content: '';
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  filter: blur(58px);
  opacity: 1;
  pointer-events: none;
}
/* Ámbar: recorre el borde SUPERIOR (el centro navy del texto queda limpio) */
.cierre-navy::before {
  width: 44vw;
  height: 44vw;
  min-width: 420px;
  min-height: 420px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.95) 0%, rgba(217, 119, 6, 0.45) 38%, rgba(217, 119, 6, 0) 58%);
  top: -17vw;
  left: -4%;
  animation: aurora-a 14s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.cierre-navy.aurora-live::before { animation-play-state: running; }
/* Azul: recorre el borde INFERIOR en contrafase */
.cierre-navy::after {
  width: 48vw;
  height: 48vw;
  min-width: 460px;
  min-height: 460px;
  background: radial-gradient(circle, rgba(54, 165, 255, 0.9) 0%, rgba(10, 132, 255, 0.4) 38%, rgba(10, 132, 255, 0) 58%);
  bottom: -19vw;
  right: -4%;
  animation: aurora-b 18s ease-in-out infinite alternate;
  animation-play-state: paused;
}
.cierre-navy.aurora-live::after { animation-play-state: running; }
/* Cuadrícula técnica sobre la aurora, bajo el contenido */
.cierre-navy > * {
  position: relative;
  z-index: 2;
}
.cierre-navy .aurora-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image:
    linear-gradient(rgba(238, 243, 248, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 243, 248, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
@keyframes aurora-a {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(28vw, 4vw, 0) scale(1.15); }
  100% { transform: translate3d(55vw, 0, 0) scale(0.95); }
}
@keyframes aurora-b {
  0%   { transform: translate3d(0, 0, 0) scale(1.1); }
  50%  { transform: translate3d(-30vw, -4vw, 0) scale(0.92); }
  100% { transform: translate3d(-58vw, 0, 0) scale(1.18); }
}
@media (prefers-reduced-motion: reduce) {
  .cierre-navy::before,
  .cierre-navy::after { animation: none; }
}

/* ── Motion: una pieza viva; el resto entra sin teatro ─────────
   Solo se oculta si el JS marcó html.js-reveal (progressive
   enhancement) y un fallback temporal fuerza visibilidad: el
   contenido jamás puede quedar invisible. ── */
@media (prefers-reduced-motion: no-preference) {
  html.js-reveal .exp-reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  }
  html.js-reveal .exp-reveal.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* ── Asistente flotante: burbuja con los nodos del tridente ──── */
.asistente-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0A2B4C;
  border: 2px solid rgba(255, 255, 255, 0.18);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
}
.asistente-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 28px -8px rgba(10, 43, 76, 0.55);
}
html.dark .asistente-btn {
  background: #f5a623;
  border-color: rgba(7, 26, 43, 0.3);
}
html.dark .asistente-btn svg path { stroke: #071A2B; }
html.dark .asistente-btn svg circle { fill: #071A2B; }
@media (prefers-reduced-motion: no-preference) {
  .asistente-btn .nodo-2 { animation: nodo-late 2.4s ease-in-out infinite 0.2s; }
  .asistente-btn .nodo-3 { animation: nodo-late 2.4s ease-in-out infinite 0.4s; }
  .asistente-btn circle:first-of-type { animation: nodo-late 2.4s ease-in-out infinite; }
}
@keyframes nodo-late {
  0%, 60%, 100% { opacity: 1; }
  30% { opacity: 0.35; }
}
