/* ============================================================
   v2-enhancements.css
   Cambios v2 sobre el microsite TFM:
     1. Transiciones entre páginas (fade + slide-up)
     2. Watermark "esculpido" del agente de la sección en el fondo
     3. Contraste mejorado en tema claro
     4. Logo animado en home (gradient shift + glow + orbit)
   ============================================================ */


/* ============================================================
   1. PAGE TRANSITIONS
   ============================================================ */

/* View Transitions API (Chrome/Edge/Safari TP) */
@view-transition { navigation: auto; }

::view-transition-old(root) {
  animation: 320ms cubic-bezier(0.4, 0, 0.2, 1) both v2-page-out;
}
::view-transition-new(root) {
  animation: 420ms cubic-bezier(0.16, 1, 0.3, 1) both v2-page-in;
}

@keyframes v2-page-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-12px) scale(0.985); filter: blur(4px); }
}

@keyframes v2-page-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); filter: blur(6px); }
  to   { opacity: 1; transform: translateY(0) scale(1);          filter: blur(0); }
}

/* Fallback CSS-only transitions para navegadores sin View Transitions */
body { animation: v2-page-in-fallback 480ms cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes v2-page-in-fallback {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Clase añadida por el JS al hacer click en un enlace antes de navegar */
body.v2-leaving {
  animation: v2-page-out-fallback 280ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}
@keyframes v2-page-out-fallback {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}

/* Stagger de elementos del hero y story-grid al entrar */
.section-hero { animation: v2-fade-up 600ms cubic-bezier(0.16, 1, 0.3, 1) 80ms both; }
.section-hero .eyebrow { animation: v2-fade-up 500ms cubic-bezier(0.16, 1, 0.3, 1) 40ms both; }
.section-hero h1 { animation: v2-fade-up 600ms cubic-bezier(0.16, 1, 0.3, 1) 120ms both; }
.section-hero .lead { animation: v2-fade-up 600ms cubic-bezier(0.16, 1, 0.3, 1) 200ms both; }
.section-content .story-row { animation: v2-fade-up 600ms cubic-bezier(0.16, 1, 0.3, 1) 320ms both; }
.section-content .story-row:nth-of-type(2) { animation-delay: 420ms; }
.section-content .story-row:nth-of-type(3) { animation-delay: 520ms; }

@keyframes v2-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger de tiles en la home */
.tile-grid .tile { animation: v2-tile-in 520ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.tile-grid .tile:nth-child(1)  { animation-delay: 100ms; }
.tile-grid .tile:nth-child(2)  { animation-delay: 150ms; }
.tile-grid .tile:nth-child(3)  { animation-delay: 200ms; }
.tile-grid .tile:nth-child(4)  { animation-delay: 250ms; }
.tile-grid .tile:nth-child(5)  { animation-delay: 300ms; }
.tile-grid .tile:nth-child(6)  { animation-delay: 350ms; }
.tile-grid .tile:nth-child(7)  { animation-delay: 400ms; }
.tile-grid .tile:nth-child(8)  { animation-delay: 450ms; }
.tile-grid .tile:nth-child(9)  { animation-delay: 500ms; }
.tile-grid .tile:nth-child(10) { animation-delay: 550ms; }
.tile-grid .tile:nth-child(11) { animation-delay: 600ms; }
.tile-grid .tile:nth-child(12) { animation-delay: 650ms; }
.tile-grid .tile:nth-child(13) { animation-delay: 700ms; }
.tile-grid .tile:nth-child(14) { animation-delay: 750ms; }

@keyframes v2-tile-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Respeta usuarios con prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}


/* ============================================================
   2. SECTION WATERMARK · agente esculpido en el fondo
   ============================================================ */

/* Capa de watermark sobre el body (debajo del contenido) */
body[data-section-num]::before {
  content: '';
  position: fixed;
  top: 50%;
  right: -8%;
  width: 70vmin;
  height: 70vmin;
  transform: translateY(-50%);
  background-image: var(--watermark-url);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.045;
  pointer-events: none;
  z-index: 0;
  filter: blur(0.4px);
  animation: v2-watermark-breathe 14s ease-in-out infinite;
}

@keyframes v2-watermark-breathe {
  0%, 100% { transform: translateY(-50%) scale(1); opacity: 0.045; }
  50%      { transform: translateY(-50%) scale(1.04); opacity: 0.065; }
}

/* Asegurar que el contenido queda por encima del watermark */
body[data-section-num] > * { position: relative; z-index: 1; }

/* Tema claro: watermark más oscuro y un pelín más visible */
[data-theme="light"] body[data-section-num]::before,
body[data-theme="light"][data-section-num]::before {
  opacity: 0.06;
  filter: invert(1) blur(0.4px);
}

/* Mapeo de section-num → URL del icono del agente */
body[data-section-num="01"] { --watermark-url: url('../assets/icons/seccion_01_apertura.svg'); }
body[data-section-num="02"] { --watermark-url: url('../assets/icons/AG003_DemandForecaster.svg'); }
body[data-section-num="03"] { --watermark-url: url('../assets/icons/AG005_Estratega.svg'); }
body[data-section-num="04"] { --watermark-url: url('../assets/icons/AG018_GovernanceAdvisor.svg'); }
body[data-section-num="05"] { --watermark-url: url('../assets/icons/AG013_TaskDecomposer.svg'); }
body[data-section-num="06"] { --watermark-url: url('../assets/icons/AG002_ResourceManagerRUN.svg'); }
body[data-section-num="07"] { --watermark-url: url('../assets/icons/AG007_Planificador.svg'); }
body[data-section-num="08"] { --watermark-url: url('../assets/icons/AG014_RiskAnalyzer.svg'); }
body[data-section-num="09"] { --watermark-url: url('../assets/icons/AG017_QualityGate.svg'); }
body[data-section-num="10"] { --watermark-url: url('../assets/icons/AG016_CostAnalyzer.svg'); }
body[data-section-num="11"] { --watermark-url: url('../assets/icons/AG004_BufferGatekeeper.svg'); }
body[data-section-num="12"] { --watermark-url: url('../assets/icons/AG001_Dispatcher.svg'); }
body[data-section-num="13"] { --watermark-url: url('../assets/icons/AG012_TaskAdvisor.svg'); }
body[data-section-num="14"] { --watermark-url: url('../assets/icons/AG011_CAB.svg'); }


/* ============================================================
   3. CONTRASTE MEJORADO EN TEMA CLARO
   ============================================================ */

[data-theme="light"] {
  /* Texto secundario más oscuro (era #4a5568 → ahora #2d3748 para legibilidad) */
  --text-secondary: #2d3748;
  --text-muted: #4a5568;

  /* Bordes más definidos */
  --border: #cbd5e0;
  --border-active: #94a3b8;

  /* Fondo profundo con un toque más cálido para evitar gris plano */
  --bg-deep: #e8ecf2;
  --bg-elev: #ffffff;
  --bg-hover: #eaeef4;
}

/* En tema claro, los textos muted que antes eran ilegibles ahora pasan a slate-700 */
[data-theme="light"] .story-sub,
[data-theme="light"] .te-text,
[data-theme="light"] .ln-text,
[data-theme="light"] .fc-text,
[data-theme="light"] .tc-text,
[data-theme="light"] .panel-box p,
[data-theme="light"] .lead {
  color: #334155;
}

/* Eyebrows / labels en mayúsculas: más oscuros en claro */
[data-theme="light"] .eyebrow,
[data-theme="light"] .section-block-title,
[data-theme="light"] .story-title {
  color: #1e293b;
}

/* Cards en claro: sombra ligera para definir la jerarquía */
[data-theme="light"] .story-card,
[data-theme="light"] .lesson-card,
[data-theme="light"] .future-card,
[data-theme="light"] .panel-box,
[data-theme="light"] .leitmotiv-card,
[data-theme="light"] .closing-message,
[data-theme="light"] .thanks-card,
[data-theme="light"] .arch-diagram-wrap,
[data-theme="light"] .roadmap-track {
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
}


/* ============================================================
   4. LOGO ANIMADO HOME · "Cognitive PMO en movimiento"
   ============================================================ */

.v2-hero-logo {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  isolation: isolate;
}

/* Halo gradient (duotono índigo/violeta) que rota detrás del escudo */
.v2-hero-logo::before {
  content: '';
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #4f46e5 0%,
    #6366f1 25%,
    #8b5cf6 50%,
    #6366f1 75%,
    #4f46e5 100%
  );
  filter: blur(30px);
  opacity: 0.45;
  z-index: -2;
  animation: v2-halo-spin 16s linear infinite;
}

/* Halo interior más intenso */
.v2-hero-logo::after {
  content: '';
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%);
  z-index: -1;
  animation: v2-halo-pulse 3.2s ease-in-out infinite;
}

@keyframes v2-halo-spin {
  to { transform: rotate(360deg); }
}
@keyframes v2-halo-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50%      { transform: scale(1.12); opacity: 1; }
}

/* Escudo flotando suavemente */
.v2-hero-logo .v2-shield {
  width: 130px;
  height: auto;
  animation: v2-shield-float 4.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(99, 102, 241, 0.45));
}

@keyframes v2-shield-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-8px) rotate(1deg); }
}

/* Partículas orbitando — 3 puntitos en tonos brand (sin arcoíris) */
.v2-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.v2-orbit-dot {
  position: absolute;
  top: 50%; left: 50%;
  width: 7px; height: 7px;
  border-radius: 50%;
  transform-origin: 0 0;
  box-shadow: 0 0 14px currentColor;
}
.v2-orbit-dot:nth-child(1) {
  color: #818cf8;
  background: #818cf8;
  animation: v2-orbit-1 7s linear infinite;
}
.v2-orbit-dot:nth-child(2) {
  color: #c4b5fd;
  background: #c4b5fd;
  animation: v2-orbit-2 11s linear infinite;
}
.v2-orbit-dot:nth-child(3) {
  color: #a78bfa;
  background: #a78bfa;
  animation: v2-orbit-3 14s linear infinite;
}
@keyframes v2-orbit-1 {
  from { transform: rotate(0deg) translateX(95px) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(95px) rotate(-360deg); }
}
@keyframes v2-orbit-2 {
  from { transform: rotate(120deg) translateX(110px) rotate(-120deg); }
  to   { transform: rotate(480deg) translateX(110px) rotate(-480deg); }
}
@keyframes v2-orbit-3 {
  from { transform: rotate(240deg) translateX(85px) rotate(-240deg); }
  to   { transform: rotate(600deg) translateX(85px) rotate(-600deg); }
}

/* Texto debajo del logo */
.v2-hero-title {
  text-align: center;
  font-size: 14px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 8px;
  animation: v2-fade-up 700ms cubic-bezier(0.16, 1, 0.3, 1) 600ms both;
}
.v2-hero-title strong {
  color: var(--text-primary);
  background: linear-gradient(90deg, #6366f1, #a78bfa, #c4b5fd, #6366f1);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: v2-gradient-shift 8s linear infinite;
}
@keyframes v2-gradient-shift {
  to { background-position: 300% 0; }
}


/* ============================================================
   4-BIS. FONDO CINEMATOGRÁFICO DE LA HOME
   Solo para la página principal (body SIN data-section-num).
   Tres capas: halo que respira, escudos a la deriva, constelación.
   Mismo lenguaje visual en claro y oscuro vía variables.
   ============================================================ */

/* Variables por tema */
body[data-theme="dark"]:not([data-section-num]) {
  /* Tema oscuro: monocromo neutro · sin tinte azul.
     El halo desaparece (totalmente transparente), solo quedan
     escudos a la deriva, estrellas blancas tenues y el barrido. */
  --bg-glow-a: transparent;
  --bg-glow-b: transparent;
  --bg-glow-c: transparent;
  --bg-shield-url: url('logo_cognitive_pmo_dark.svg');
  --bg-shield-opacity: 0.055;
  --bg-star: rgba(230, 237, 243, 0.7);
  --bg-sweep: rgba(255, 255, 255, 0.025);
}
body[data-theme="light"]:not([data-section-num]) {
  --bg-glow-a: rgba(99, 102, 241, 0.14);
  --bg-glow-b: rgba(139, 92, 246, 0.12);
  --bg-glow-c: rgba(59, 130, 246, 0.07);
  --bg-shield-url: url('logo_cognitive_pmo_light.svg');
  --bg-shield-opacity: 0.07;
  --bg-star: rgba(67, 56, 202, 0.55);
  --bg-sweep: rgba(99, 102, 241, 0.05);
}

/* Container fijo, sin interacción, detrás de todo */
.v2-home-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Todo el contenido de la home queda por encima del fondo */
body:not([data-section-num]) > *:not(.v2-home-bg) {
  position: relative;
  z-index: 1;
}

/* === Capa 1 · halo gradient que respira === */
.v2-bg-glow {
  position: absolute;
  inset: -25%;
  background:
    radial-gradient(circle at 22% 28%, var(--bg-glow-a) 0%, transparent 45%),
    radial-gradient(circle at 78% 72%, var(--bg-glow-b) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, var(--bg-glow-c) 0%, transparent 55%);
  filter: blur(50px);
  animation: v2-glow-shift 28s ease-in-out infinite;
}
@keyframes v2-glow-shift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(-3%, 2%) scale(1.06); }
  66%      { transform: translate(2%, -3%) scale(0.96); }
}

/* === Capa 2 · escudos a la deriva (logos repetidos como nubes) === */
.v2-bg-shield {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  background-image: var(--bg-shield-url);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: var(--bg-shield-opacity);
  animation: v2-shield-drift 36s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  transform-origin: center;
  will-change: transform;
}
@keyframes v2-shield-drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  25%      { transform: translate(-22px, 16px) rotate(2deg) scale(1.05); }
  50%      { transform: translate(18px, 24px) rotate(-2deg) scale(0.96); }
  75%      { transform: translate(14px, -20px) rotate(3deg) scale(1.03); }
}

/* === Capa 3 · canvas de la red neuronal viva === */
#v2-neural-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* === Capa 4 · anillos pulsantes desde el centro de la pantalla === */
.v2-pulse-rings {
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
}
.v2-pulse-rings .v2-ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 1px solid var(--bg-ring);
  opacity: 0;
  animation: v2-pulse-ring 5.4s ease-out infinite;
}
.v2-pulse-rings .v2-ring:nth-child(2) { animation-delay: 1.8s; }
.v2-pulse-rings .v2-ring:nth-child(3) { animation-delay: 3.6s; }

@keyframes v2-pulse-ring {
  0%   { opacity: 0; transform: scale(0.3); }
  10%  { opacity: 0.55; }
  100% { opacity: 0; transform: scale(4.2); }
}

/* Color de los anillos por tema (sin tinte azul en oscuro) */
body[data-theme="dark"]:not([data-section-num])  { --bg-ring: rgba(230, 237, 243, 0.20); }
body[data-theme="light"]:not([data-section-num]) { --bg-ring: rgba(67, 56, 202, 0.22); }

/* === Capa 5 · línea de barrido diagonal (scan) sutil === */
.v2-bg-sweep {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg,
    transparent 0%,
    transparent 45%,
    var(--bg-sweep) 50%,
    transparent 55%,
    transparent 100%);
  background-size: 300% 300%;
  animation: v2-sweep-move 22s linear infinite;
}
@keyframes v2-sweep-move {
  from { background-position: 200% 0%; }
  to   { background-position: -100% 0%; }
}


/* ============================================================
   6. MODO DEFENSA
   Cuando body[data-mode="defensa"]: ocultar texto descriptivo,
   dejar visibles títulos, etiquetas, gráficos y elementos visuales.
   El presentador habla desde un guion externo.
   ============================================================ */

/* ---- Selectores GENÉRICOS de texto descriptivo ---- */
/* Nota: p.lead (no .lead) para no colisionar con div.lead usado en
   la sección 6 como contenedor del tier de Liderazgo. */
body[data-mode="defensa"] p.lead,
body[data-mode="defensa"] .story-sub,
body[data-mode="defensa"] .story-cta-row,
body[data-mode="defensa"] .stack-banner,
body[data-mode="defensa"] .arch-foot,
body[data-mode="defensa"] .roadmap-foot,
body[data-mode="defensa"] .footer-nav .nav-label,
body[data-mode="defensa"] .footer-nav .nav-title {
  display: none !important;
}

/* ---- Texto largo dentro de cards/paneles ---- */
body[data-mode="defensa"] .ln-text,      /* Sección 13 — cuerpo de lección */
body[data-mode="defensa"] .fc-text,      /* Sección 14 — cuerpo de línea futura */
body[data-mode="defensa"] .fc-tags,
body[data-mode="defensa"] .te-text,      /* Sección 13 — cuerpo de timeline */
body[data-mode="defensa"] .lm-text,      /* Sección 13 — cita leitmotiv */
body[data-mode="defensa"] .ps-detail,    /* Sección 12 — KPI detail */
body[data-mode="defensa"] .cm-text,      /* Sección 14 — mensaje cierre */
body[data-mode="defensa"] .hero-quote .hq-text,
body[data-mode="defensa"] .hero-quote .hq-source {
  display: none !important;
}

/* ---- Cita vertebradora (Sección 13): mantener el frame visual,
       quitar la cita; queda solo el indicador "—" como aire ---- */
body[data-mode="defensa"] .hero-quote {
  min-height: 60px;
  padding: 18px 44px;
}
body[data-mode="defensa"] .hero-quote::before {
  content: '— cita vertebradora —';
  display: block;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  text-align: center;
  padding-left: 0;
}

/* ---- Compactar tarjetas ---- */
body[data-mode="defensa"] .story-card {
  padding: 22px 26px;
}
body[data-mode="defensa"] .story-row {
  margin-bottom: 8px;
}
body[data-mode="defensa"] .story-title {
  margin-bottom: 14px;
  font-size: 17px;
}

/* ---- Footer-nav simplificado: solo flechas ---- */
body[data-mode="defensa"] .footer-nav {
  border-top: none;
  padding-top: 8px;
  padding-bottom: 12px;
}
body[data-mode="defensa"] .footer-nav-btn::before { content: ''; }
body[data-mode="defensa"] .footer-nav-btn {
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
body[data-mode="defensa"] .footer-nav-btn.next::after { content: '→  Siguiente'; }
body[data-mode="defensa"] .footer-nav-btn:not(.next)::after { content: '←  Anterior'; }

/* ---- Indicador discreto de modo activo ---- */
body[data-mode="defensa"]::after {
  content: '· MODO DEFENSA ·';
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 3px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: 999px;
  z-index: 50;
  pointer-events: none;
  opacity: 0.7;
}


/* ============================================================
   7. PEQUEÑOS DETALLES UI · cards con hover más vivo en v2
   ============================================================ */

.tile { transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 220ms; }
.tile:hover {
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 0 0 1px var(--tile-accent, #6366f1);
}
[data-theme="light"] .tile:hover {
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--tile-accent, #6366f1);
}
