/* =========================================================
   INICIO - pantalla de carga, hero animado y scroll
   ========================================================= */

/* ---------- 1. PANTALLA DE CARGA: el logo se arma solo ---------- */
.mc-loader {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 50%, #24408a 0%, #1f3477 35%, #0d1a45 100%);
    /* Si el JavaScript falla, la pantalla se oculta sola a los 7 s */
    animation: mc-loader-fallback .6s ease 7s forwards;
}
html.sin-loader .mc-loader { display: none; }
html.cargado .mc-loader {
    animation: none;
    clip-path: circle(0% at 50% 50%);
    transition: clip-path 1.1s cubic-bezier(.76, 0, .24, 1);
}
.mc-loader { clip-path: circle(150% at 50% 50%); --logo: clamp(190px, 19vw, 280px); }
/* El logo queda en el centro exacto de la pantalla; el nombre va debajo */
.mc-loader-centro { position: relative; z-index: 2; width: var(--logo); height: var(--logo); }
.mc-loader-centro .mc-logo-svg { width: 100%; height: 100%; display: block; }
.mc-loader-centro .mc-loader-nombre {
    position: absolute;
    top: calc(100% + 18px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.mc-logo-svg { overflow: visible; animation: mc-logo-respira 1.4s ease-in-out 3.6s infinite alternate; }

/* Trazos: se dibujan de un extremo al otro */
.mc-trazo {
    fill: none;
    stroke-width: 15;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}
.mc-trazo-t { stroke: #0e9aa7; animation: mc-dibuja 2s cubic-bezier(.6, 0, .3, 1) .9s forwards; }
.mc-trazo-b { stroke: #ffffff; animation: mc-dibuja 2s cubic-bezier(.6, 0, .3, 1) .6s forwards; }

/* Nodos: aparecen de un "pop" al inicio y al final de cada trazo */
.mc-nodo { transform-box: fill-box; transform-origin: center; transform: scale(0); }
.mc-nodo-b1 { fill: #fff;    animation: mc-pop .6s cubic-bezier(.3, 1.6, .5, 1) .25s forwards; }
.mc-nodo-t1 { fill: #0e9aa7; animation: mc-pop .6s cubic-bezier(.3, 1.6, .5, 1) .5s forwards; }
.mc-nodo-b2 { fill: #fff;    animation: mc-pop .6s cubic-bezier(.3, 1.6, .5, 1) 2.55s forwards; }
.mc-nodo-t2 { fill: #0e9aa7; animation: mc-pop .6s cubic-bezier(.3, 1.6, .5, 1) 2.85s forwards; }

/* Nombre: aparece cuando el logo ya está armado */
.mc-loader-nombre {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-weight: 600;
    letter-spacing: .28em;
    color: #19b3bf;
    font-size: clamp(1rem, 1.5vw, 1.45rem);
}
.mc-loader-nombre span {
    opacity: 0;
    transform: translateY(10px);
    letter-spacing: .6em;
    animation: mc-nombre 1s cubic-bezier(.2, .8, .2, 1) forwards;
}
.mc-n1 { animation-delay: 3.05s !important; }
.mc-n2 { animation-delay: 3.3s !important; color: #fff; }

@keyframes mc-dibuja { to { stroke-dashoffset: 0; } }
@keyframes mc-pop { to { transform: scale(1); } }
@keyframes mc-nombre { to { opacity: 1; transform: none; letter-spacing: .28em; } }
@keyframes mc-logo-respira { to { transform: scale(1.04); } }
@keyframes mc-loader-fallback { to { opacity: 0; visibility: hidden; } }

/* Decoración del fondo de la pantalla de carga */
.mc-fondo-deco { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.mc-fondo-deco::before {   /* cuadrícula de puntos que se desvanece hacia el centro */
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(148, 197, 255, .35) 1.2px, transparent 1.3px);
    background-size: 28px 28px;
    -webkit-mask: radial-gradient(circle at 50% 50%, transparent 0 22%, #000 70%);
    mask: radial-gradient(circle at 50% 50%, transparent 0 22%, #000 70%);
    opacity: 0;
    animation: mc-aparece 1.5s ease .2s forwards, mc-desliza 20s linear infinite;
}
.mc-mancha {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0;
    animation: mc-aparece 2s ease forwards, mc-flota 9s ease-in-out infinite alternate;
}
.mc-m1 { width: 420px; height: 420px; left: -120px; top: 10%; background: rgba(14, 154, 167, .45); }
.mc-m2 { width: 460px; height: 460px; right: -140px; bottom: 0; background: rgba(56, 189, 248, .35); animation-delay: .3s, 1s; }
.mc-m3 { width: 300px; height: 300px; right: 12%; top: -100px; background: rgba(99, 102, 241, .3); animation-delay: .6s, 2s; }

/* Símbolos de código flotando */
.mc-cod {
    position: absolute;
    left: var(--x);
    top: var(--y);
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: 700;
    font-size: clamp(14px, 1.6vw, 24px);
    color: rgba(148, 210, 255, .38);
    opacity: 0;
    animation: mc-cod-entra 1.2s ease var(--d) forwards, mc-cod-flota var(--t) ease-in-out var(--d) infinite alternate;
}

/* Anillos alrededor del logo */
.mc-anillos {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(var(--logo) * 2.9);
    height: calc(var(--logo) * 2.9);
    transform: translate(-50%, -50%);
}
.mc-anillo {
    fill: none;
    stroke: rgba(148, 210, 255, .22);
    stroke-width: 1.5;
    transform-origin: 300px 300px;
    opacity: 0;
}
.mc-a1 { stroke-dasharray: 4 10; animation: mc-aparece 1s ease .3s forwards, mc-gira 30s linear infinite; }
.mc-a2 { stroke-dasharray: 60 20 6 20; stroke: rgba(14, 154, 167, .35); animation: mc-aparece 1s ease .6s forwards, mc-gira-inv 40s linear infinite; }
.mc-a3 { stroke-dasharray: 2 14; animation: mc-aparece 1s ease .9s forwards, mc-gira 55s linear infinite; }
.mc-orbita { transform-origin: 300px 300px; opacity: 0; }
.mc-o1 { fill: #38bdf8; animation: mc-aparece 1s ease 1s forwards, mc-gira 8s linear infinite; }
.mc-o2 { fill: #19b3bf; animation: mc-aparece 1s ease 1.3s forwards, mc-gira-inv 12s linear infinite; }

@keyframes mc-aparece { to { opacity: 1; } }
@keyframes mc-desliza { to { background-position: 28px 56px; } }
@keyframes mc-flota { to { transform: translate(40px, -30px) scale(1.1); } }
@keyframes mc-cod-entra { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes mc-cod-flota { to { translate: 0 -26px; rotate: 6deg; } }
@keyframes mc-gira { to { transform: rotate(360deg); } }
@keyframes mc-gira-inv { to { transform: rotate(-360deg); } }

@media (max-width: 600px) {
    .mc-cod:nth-of-type(n+9) { display: none; }
    .mc-m1, .mc-m2 { width: 260px; height: 260px; }
}


/* ---------- 2. HERO ANIMADO ---------- */
.particles-canvas {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}
.hero .container { position: relative; z-index: 1; }
.hero::after {   /* manchas de color que se mueven lento */
    content: "";
    position: absolute;
    width: 620px;
    height: 620px;
    left: -180px;
    bottom: -260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, .22), transparent 65%);
    animation: mc-mancha 14s ease-in-out infinite alternate;
    z-index: 0;
    pointer-events: none;
}
@keyframes mc-mancha { to { transform: translate(140px, -120px) scale(1.15); } }

.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px 8px 10px;
    margin-bottom: 1.25rem;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(37, 99, 235, .12);
    font-weight: 700;
    color: #1e3a8a;
    font-size: .95rem;
}
.hero-tag-icono {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    font-size: .8rem;
}
.hero-typing { min-width: 1ch; }
.hero-typing::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 3px;
    vertical-align: -0.15em;
    background: #2563eb;
    animation: mc-cursor .8s steps(1) infinite;
}
@keyframes mc-cursor { 50% { opacity: 0; } }

/* Palabras del título que suben una por una */
.hero-title .w { display: inline-block; }
html.anim .hero-title .w,
html.anim .hero-tag,
html.anim .hero-description,
html.anim .hero-buttons {
    opacity: 0;
    transform: translateY(28px);
    filter: blur(6px);
}
html.anim.cargado .hero-title .w,
html.anim.cargado .hero-tag,
html.anim.cargado .hero-description,
html.anim.cargado .hero-buttons {
    opacity: 1;
    transform: none;
    filter: none;
    transition: opacity .7s ease, transform .8s cubic-bezier(.2, .8, .2, 1), filter .7s ease;
}
html.anim.cargado .hero-tag { transition-delay: .25s; }
html.anim.cargado .hero-title .w:nth-child(1) { transition-delay: .35s; }
html.anim.cargado .hero-title .w:nth-child(2) { transition-delay: .45s; }
html.anim.cargado .hero-title .w:nth-child(3) { transition-delay: .55s; }
html.anim.cargado .hero-title .w:nth-child(4) { transition-delay: .65s; }
html.anim.cargado .hero-title .w:nth-child(5) { transition-delay: .75s; }
html.anim.cargado .hero-title .w:nth-child(6) { transition-delay: .85s; }
html.anim.cargado .hero-description { transition-delay: 1s; }
html.anim.cargado .hero-buttons { transition-delay: 1.15s; }

/* La ilustración entra después del loader */
html.anim .hero-image { animation: none; opacity: 0; transform: translateX(40px) scale(.95); }
html.anim.cargado .hero-image {
    opacity: 1;
    transform: none;
    transition: opacity .9s ease .5s, transform 1s cubic-bezier(.2, .8, .2, 1) .5s;
}
.hero-image { perspective: 900px; }
.hero-visual { transition: transform .25s ease-out; transform-style: preserve-3d; }

/* Brillo que recorre el botón principal */
.hero-buttons .btn-primary { position: relative; overflow: hidden; }
.hero-buttons .btn-primary::after {
    content: "";
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(110deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: skewX(-20deg);
    animation: mc-brillo 3.5s ease-in-out 2.5s infinite;
}
@keyframes mc-brillo { 0% { left: -60%; } 40%, 100% { left: 130%; } }

/* ---------- 3. ANIMACIONES AL HACER SCROLL ---------- */
html.anim [data-reveal] {
    opacity: 0;
    transition: opacity .8s ease, transform .9s cubic-bezier(.2, .8, .2, 1), filter .8s ease;
}
html.anim [data-reveal="up"] { transform: translateY(40px); }
html.anim [data-reveal="zoom"] { transform: scale(.92); filter: blur(4px); }
html.anim [data-reveal].revelado { opacity: 1; transform: none; filter: none; }

/* Imágenes de servicios con zoom suave al pasar el mouse */
.service-image { overflow: hidden; }
.service-image img { transition: transform .6s ease; }
.service-card:hover .service-image img { transform: scale(1.07); }

/* Barra de progreso arriba */
.mc-progreso {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    background: linear-gradient(90deg, #2563eb, #38bdf8);
    transform: scaleX(0);
    transform-origin: left;
    pointer-events: none;
}

/* ---------- Movimiento reducido (accesibilidad) ---------- */
@media (prefers-reduced-motion: reduce) {
    .mc-loader { display: none; }
    html.anim .hero-title .w, html.anim .hero-tag, html.anim .hero-description,
    html.anim .hero-buttons, html.anim .hero-image, html.anim [data-reveal] {
        opacity: 1 !important; transform: none !important; filter: none !important;
    }
    .hero::after, .hero-buttons .btn-primary::after { animation: none; }
}

@media (max-width: 768px) {
    .hero-tag { font-size: .85rem; }
    .mc-loader-nombre { font-size: .95rem; }
    .mc-loader { --logo: 170px; }
}

/* Celular: la ilustración pasa debajo del texto para que no lo tape */
@media (max-width: 768px) {
    .hero-content { grid-template-columns: 1fr; gap: 1rem; }
    .hero-image { order: 2; }
    .hero-visual { height: 230px; max-width: 320px; margin: 0 auto; }
    .hero-circle { width: 170px; height: 170px; }
}
