/* ==========================================================
   1. VARIABLES & RESET
   ========================================================== */
:root {
  --bg: #050505; 
  --text: #EDEDED; 
  --muted: #A1A1AA; 
  --soft: #71717A;
  
  --line: rgba(255, 255, 255, 0.1); 
  --line-hover: rgba(255, 255, 255, 0.3); 
  --glass: rgba(20, 21, 23, 0.9);
  
  --accent-glow: #5E6AD2;
  
  --header-h: 64px;
  --radius: 12px;
  
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 60px; /* Espacio móvil */
}
@media (min-width: 900px) { body { padding-bottom: 0; } }

a { color: inherit; text-decoration: none; transition: 0.2s; }
button { font-family: inherit; }

/* ==========================================================
   2. FONDOS & AMBIENTE (Retículas Fijas y Visibles)
   ========================================================== */
.relative-section { 
  position: relative; 
  overflow: hidden; 
  z-index: 1; 
}

.bg-layer { position: fixed; inset: 0; pointer-events: none; }
.bg-noise { 
  z-index: -30; opacity: 0.05; 
  background: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noise"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noise)"/%3E%3C/svg%3E'); 
}
.bg-vignette { z-index: -20; background: radial-gradient(circle at center, transparent 0%, #000 120%); }

.bg-ambient {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: -5; pointer-events: none;
  background: radial-gradient(800px circle at 50% 10%, var(--ambient-color, rgba(94, 106, 210, 0.25)), transparent 80%);
  transition: background 1.5s ease-in-out;
  opacity: 1; mix-blend-mode: screen;
}

/* RETÍCULAS ESTÁTICAS (High Contrast) */
.bg-grid-static {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1; pointer-events: none;
  opacity: 0.12; /* Bien visible */
  mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
}

.grid-dots { background-image: radial-gradient(rgba(255,255,255,0.8) 1px, transparent 1px); background-size: 30px 30px; }
.grid-squares { background-image: linear-gradient(to right, rgba(255,255,255,0.4) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,0.4) 1px, transparent 1px); background-size: 50px 50px; }
.grid-lines-v { background-image: linear-gradient(90deg, rgba(255,255,255,0.4) 1px, transparent 1px); background-size: 60px 100%; }
.grid-lines-h { background-image: linear-gradient(0deg, rgba(255,255,255,0.4) 1px, transparent 1px); background-size: 100% 40px; }

/* ==========================================================
   3. HEADER & HERO
   ========================================================== */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 1000;
  background: rgba(5,5,5,0.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; }
.logo-img { height: 28px; width: auto; opacity: 0.95; }
.nav { display: none; gap: 32px; }
.nav a { font-size: 0.85rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.nav a:hover, .nav a.is-active { color: #fff; }
@media (min-width: 900px) { .nav { display: flex; } }

.hero {
  min-height: 90vh; display: flex; align-items: center; justify-content: center;
  text-align: center; position: relative; padding-top: var(--header-h); overflow: hidden;
}
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.relative-z { position: relative; z-index: 10; pointer-events: none; }
.hero-panel { pointer-events: auto; display: inline-block; max-width: 900px; padding: 0 24px; }

.h1 { font-weight: 800; line-height: 1.05; font-size: clamp(3rem, 7vw, 6rem); margin: 0 0 24px; letter-spacing: -0.04em; color: #fff; }
.h1 .accent { background: linear-gradient(135deg, #fff 40%, #777 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: block; }
.sub { font-size: 1.25rem; color: var(--muted); max-width: 800px; width: 90%; margin: 0 auto 40px; line-height: 1.6; text-wrap: balance; }

.btn-glow {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  background: #fff; color: #000; padding: 14px 28px; border-radius: 8px;
  font-weight: 600; cursor: pointer; overflow: hidden; transition: transform 0.2s;
  pointer-events: auto; /* Asegura click */
}
.btn-glow:hover { transform: scale(1.02); box-shadow: 0 0 30px rgba(255,255,255,0.3); }

/* ==========================================================
   4. ESTRUCTURA & TARJETAS
   ========================================================== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.section-pad { padding: 120px 0; border-top: 1px solid var(--line); }
.kicker { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--accent-glow); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 12px; }
.title { font-size: 2.5rem; color: #fff; margin: 0 0 16px; letter-spacing: -0.02em; }
.subtitle { color: var(--muted); font-size: 1.1rem; max-width: 600px; margin-bottom: 60px; line-height: 1.6; }

.cards3 { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid2 { display: grid; gap: 40px; margin-top: 60px; padding-top: 40px; border-top: 1px solid var(--line); }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 2fr; } }

.card, .mini, .file {
  position: relative; background: rgba(20,21,23,0.6);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; overflow: hidden; transition: border-color 0.3s;
  display: flex; flex-direction: column; height: 100%; z-index: 10;
}
.card:hover, .mini:hover, .file:hover { border-color: var(--line-hover); }

.card-icon {
    width: 44px; height: 44px;
    background: rgba(94, 106, 210, 0.1); 
    border-radius: 8px; border: 1px solid rgba(94, 106, 210, 0.2);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 20px; color: var(--accent-glow);
    transition: all 0.3s ease;
}
.card:hover .card-icon { background: var(--accent-glow); color: #fff; transform: scale(1.1); box-shadow: 0 0 20px rgba(94, 106, 210, 0.4); }
.card-icon svg { width: 24px; height: 24px; }
.loop-svg { width: 100%; height: 100%; overflow: visible; }
.path-loop { stroke-dasharray: 200; stroke-dashoffset: 200; animation: drawLoop 3s linear infinite; }
@keyframes drawLoop { to { stroke-dashoffset: 0; } }

/* ==========================================================
   5. ACORDEÓN (EXPEDIENTES)
   ========================================================== */
.block-wrapper { margin-top: 60px; padding-top: 40px; border-top: 1px solid var(--line); }
.block-title { font-size: 1.5rem; color: #fff; margin: 0 0 8px; }

.text-collapse { position: relative; border-left: 2px solid var(--line); padding-left: 24px; }
.collapse-content {
  max-height: 100px; overflow: hidden; transition: max-height 0.6s var(--ease-smooth);
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}
.collapse-content.expanded { max-height: 2000px; mask-image: none; -webkit-mask-image: none; }

.lead-text { font-size: 1.1rem; color: #fff; margin-bottom: 16px; font-weight: 500; }
.hidden-text p { font-size: 1rem; color: var(--muted); margin-bottom: 16px; line-height: 1.7; }

.btn-expand {
  margin-top: 16px; background: transparent; border: 1px solid var(--line);
  color: var(--accent-glow); padding: 8px 16px; border-radius: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 0.75rem;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; transition: all 0.2s;
  pointer-events: auto; /* IMPORTANTE */
  z-index: 20; position: relative;
}
.btn-expand:hover { border-color: var(--accent-glow); background: rgba(94, 106, 210, 0.1); }
.icon-pulse { width: 8px; height: 8px; background: var(--accent-glow); border-radius: 50%; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(94, 106, 210, 0.7); } 70% { box-shadow: 0 0 0 6px rgba(94, 106, 210, 0); } 100% { box-shadow: 0 0 0 0 rgba(94, 106, 210, 0); } }

/* SPLIT LAYOUT */
.grid-split { display: grid; gap: 40px; margin-top: 60px; }
@media (min-width: 900px) { .grid-split { grid-template-columns: 1fr 1fr; align-items: center; } }
.mini-stack { display: grid; gap: 16px; margin-top: 32px; }
.mini { background: rgba(255,255,255,0.03); border: 1px solid var(--line); padding: 20px; border-radius: 8px; }
.mini-title { color: #fff; font-weight: 600; margin-bottom: 4px; }
.canvas-container-router {
  width: 100%; height: 300px;
  background: radial-gradient(circle, rgba(94,106,210,0.05), transparent 70%);
  border-radius: 16px; padding: 10px; border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
#coordination-canvas { width: 100%; height: 100%; }

/* ==========================================================
   6. ANIMACIONES & HOLO CARDS
   ========================================================== */
.bg-chart { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0.6; }
.bg-chart svg { width: 100%; height: 100%; }
.holo-stack { gap: 24px; }
.holo-card {
  position: relative; background: var(--glass);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 32px; transition: transform 0.4s var(--ease-elastic), border-color 0.3s;
  transform-style: preserve-3d; perspective: 1000px;
  z-index: 10;
}
.holo-card:hover { transform: translateY(-5px) rotateX(2deg); border-color: rgba(255,255,255,0.3); border-top-color: rgba(255,255,255,0.6); }
.file-meta { display: flex; justify-content: space-between; font-family: 'JetBrains Mono'; font-size: 0.7rem; color: var(--soft); margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.badge { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; color: #fff; }
.file-title { font-size: 1.4rem; color: #fff; margin-bottom: 16px; }
.holo-card ul { padding-left: 20px; color: var(--muted); margin: 0; }
.holo-card li { margin-bottom: 8px; }
.shine {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.05) 50%, transparent 70%);
  background-size: 200% 100%; animation: shineMove 5s infinite linear; pointer-events: none;
}
@keyframes shineMove { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.reveal { opacity: 0; transform: translateY(20px); transition: all 0.8s var(--ease-smooth); }
.reveal.show { opacity: 1; transform: translateY(0); }
.reveal-right { opacity: 0; transform: translateX(50px); transition: all 0.6s var(--ease-smooth); transition-delay: var(--delay, 0s); }
.stagger-wrapper.show .reveal-right { opacity: 1; transform: translateX(0); }
.reveal-up { opacity: 0; transform: translateY(40px); transition: all 0.6s var(--ease-smooth); transition-delay: var(--delay, 0s); }
.stagger-wrapper.show .reveal-up { opacity: 1; transform: translateY(0); }

/* ==========================================================
   7. MARQUEE INFINITO (Casos y Logos)
   ========================================================== */
.overflow-hidden { overflow: hidden; }
.cases-marquee, .logo-marquee {
  width: 100%; overflow: hidden; position: relative;
  mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
  padding: 20px 0; z-index: 50;
}
.cases-track, .logo-track { display: flex; width: max-content; gap: 24px; animation-timing-function: linear; animation-iteration-count: infinite; pointer-events: auto; }
.cases-track:hover, .logo-track:hover { animation-play-state: paused; }

.cases-track { animation-name: scrollCases; animation-duration: 80s; }
.logo-track { animation-name: scrollLogos; animation-duration: 40s; gap: 80px; }

@keyframes scrollCases { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
@keyframes scrollLogos { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

.case-card {
  flex: 0 0 340px; background: rgba(20, 21, 23, 0.6); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; transition: all 0.3s ease; position: relative; z-index: 100; cursor: pointer; pointer-events: auto;
}
.case-card:hover { background: rgba(30, 30, 35, 0.8); border-color: var(--accent-glow); transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.case-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--muted); }
.case-icon { color: var(--accent-glow); font-size: 1.2rem; transition: transform 0.3s; }
.case-card:hover .case-icon { transform: translateX(5px); }
.case-title { font-size: 1.1rem; color: #fff; margin: 0 0 12px 0; line-height: 1.4; }
.case-hook { font-size: 0.9rem; color: var(--soft); margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* LOGOS: FIXED (Grandes y efecto escala) */
.logo-item { display: flex; align-items: center; justify-content: center; opacity: 0.7; transition: opacity 0.3s ease; padding: 0 20px; }
.logo-item img { height: 60px; width: auto; filter: grayscale(100%); transition: all 0.3s ease; }
.logo-item:hover { opacity: 1; }
.logo-item:hover img { filter: grayscale(0%); transform: scale(1.15); }

/* ==========================================================
   8. MODALES - EL FIX DEFINITIVO (Elegante Desktop + Full Móvil)
   ========================================================== */
.modal-overlay { 
  position: fixed; inset: 0; 
  background: rgba(0,0,0,0.85); backdrop-filter: blur(12px); 
  z-index: 9999; 
  display: none; align-items: center; justify-content: center; 
  padding: 20px; 
}

/* MODAL DE CASOS: ESTILO FLOTANTE ELEGANTE */
.case-modal-content {
  background: #080808; 
  border: 1px solid rgba(255,255,255,0.1); 
  border-radius: 20px; 
  padding: 0;
  width: 100%; 
  max-width: 850px; /* ANCHO DESKTOP */
  max-height: 85vh; /* ALTURA MAXIMA DESKTOP */
  display: flex; flex-direction: column; 
  position: relative; 
  box-shadow: 0 50px 120px rgba(0,0,0,1);
  animation: modalUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalUp { 
  from { opacity: 0; transform: translateY(40px) scale(0.98); } 
  to { opacity: 1; transform: translateY(0) scale(1); } 
}

.case-modal-header { 
  padding: 40px 50px 30px 50px; 
  border-bottom: 1px solid rgba(255,255,255,0.06); 
  background: linear-gradient(to bottom, rgba(30,30,30,0.4), rgba(10,10,10,0));
  flex-shrink: 0; 
}
.case-modal-header h2 { margin: 16px 0 24px; font-size: 2rem; color: #fff; letter-spacing: -0.03em; }

.case-modal-body { 
  padding: 40px 50px 60px 50px; 
  color: var(--text); 
  line-height: 1.8; 
  font-size: 1.1rem;
  overflow-y: auto; /* SCROLL INTERNO */
  scrollbar-width: thin; 
  scrollbar-color: var(--accent-glow) #111;
}
.case-modal-body::-webkit-scrollbar { width: 6px; }
.case-modal-body::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
.case-modal-body p { margin-bottom: 24px; }
.case-modal-body strong { color: #fff; font-weight: 600; }

.modal-meta { display: flex; gap: 40px; }
.meta-item { display: flex; flex-direction: column; }
.meta-item small { font-family: 'JetBrains Mono'; font-size: 0.7rem; color: var(--soft); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 6px; }
.meta-item span { color: #fff; font-weight: 500; font-size: 1rem; }

/* Botón cerrar flotante */
.modal-close-contact {
  position: absolute; top: 24px; right: 30px; 
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  color: #fff; width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.5rem; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; z-index: 10;
}
.modal-close-contact:hover { background: #fff; color: #000; border-color: #fff; }

/* MODAL MÓVIL (Override para que ocupe todo) */
@media (max-width: 650px) {
  .modal-overlay { padding: 0; }
  .case-modal-content { max-height: 100vh; height: 100%; border-radius: 0; border: none; }
  .case-modal-header { padding: 30px 24px; }
  .case-modal-body { padding: 30px 24px 100px 24px; }
  .case-modal-header h2 { font-size: 1.6rem; }
  .modal-meta { flex-direction: column; gap: 16px; }
  .modal-close-contact { top: 20px; right: 20px; }
}

/* MODAL CONTACTO */
.modal-content-contact { background: #0A0A0A; border: 1px solid var(--line); border-radius: 16px; padding: 40px; width: 100%; max-width: 480px; position: relative; box-shadow: 0 40px 80px rgba(0,0,0,0.8); }
.form-group-contact input, .form-group-contact textarea { width: 100%; background: #111; border: 1px solid var(--line); padding: 12px; color: #fff; border-radius: 8px; margin-bottom: 12px; font-family: inherit; }
.form-group-contact input:focus { border-color: var(--accent-glow); outline: none; }

/* --- FOOTER & NAV --- */
.footer { background: #000; padding: 80px 0; border-top: 1px solid var(--line); margin-top: 80px; }
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 32px; text-align: center; }
.footer-logo { height: 24px; opacity: 0.6; }
.quick {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; justify-content: space-between;
  width: 92%; max-width: 400px; padding: 6px; gap: 2px;
  background: rgba(20,20,20,0.85); border: 1px solid var(--line); border-radius: 100px;
  z-index: 2000; backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.quick a { flex: 1; text-align: center; padding: 10px 0; border-radius: 20px; font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: all 0.2s ease; }
.quick a.is-active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 600; }
@media (min-width: 900px) { .quick { display: none; } }
@media (max-width: 380px) { .quick a { font-size: 0.65rem; } }