/* ==========================================================================
   Portafolio — blanco formal + azul navy, circuitos con energía
   Tema por defecto: claro (blanco). [data-theme="navy"] activa el modo oscuro.
   .on-navy: bloques con fondo navy dentro del tema claro (CTA, footer).
   ========================================================================== */

:root {
    --bg: #ffffff;
    --bg-alt: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f2f5fa;
    --border: #e2e8f1;
    --border-strong: #cbd5e3;
    --text: #0b1f3f;
    --muted: #53627c;
    --accent: #1d4ed8;
    --accent-strong: #1e3a8a;
    --primary: #0b1f3f;
    --primary-hover: #17325f;
    --primary-ink: #ffffff;
    --navy: #0b1f3f;
    --navy-2: #112a52;

    /* Circuitos */
    --circuit-trace: #dde5f0;
    --circuit-pin: #c3cfe0;
    --circuit-via: #ffffff;
    --circuit-chip: #ffffff;
    --energy: #3b82f6;
    --energy-core: #1d4ed8;
    --energy-glow: rgba(59, 130, 246, .25);
    --neon: #2f7bff;
    --neon-core: #0b5cff;
    --neon-glow: rgba(47, 123, 255, .6);
    --scroll-track: #eef2f8;
    --scroll-thumb-top: #2f7bff;
    --scroll-thumb-bottom: #0b1f3f;

    --success: #0f8a5f;
    --danger: #c62839;
    --radius: 14px;
    --shadow: 0 14px 34px -18px rgba(11, 31, 63, .3);
    --gutter: clamp(16px, 4vw, 32px);
    /* Aptos es de Microsoft: se usa si está instalada o si se aloja en public/assets/fonts/aptos/ (ver AGENTS.md).
       Si no, Inter (la alternativa libre más parecida a Aptos) y JetBrains Mono la reemplazan. */
    --font: 'Aptos', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Aptos Display', 'Aptos', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'Aptos Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    color-scheme: light;
}

[data-theme="navy"] {
    --bg: #061229;
    --bg-alt: #081937;
    --surface: #0b1d3d;
    --surface-2: #0f2750;
    --border: #1a3464;
    --border-strong: #274a86;
    --text: #e6eefb;
    --muted: #9aaecf;
    --accent: #4cc2ff;
    --accent-strong: #8fd9ff;
    --primary: #4cc2ff;
    --primary-hover: #8fd9ff;
    --primary-ink: #03111f;
    --navy: #030b1c;
    --navy-2: #0a1a38;

    --circuit-trace: #183361;
    --circuit-pin: #274a86;
    --circuit-via: #061229;
    --circuit-chip: #0a1a38;
    --energy: #4cc2ff;
    --energy-core: #e4f6ff;
    --energy-glow: rgba(76, 194, 255, .45);
    --neon: #4cc2ff;
    --neon-core: #eaf8ff;
    --neon-glow: rgba(76, 194, 255, .8);
    --scroll-track: #040d1f;
    --scroll-thumb-top: #4cc2ff;
    --scroll-thumb-bottom: #1d4ed8;

    --success: #3ddc97;
    --danger: #ff7a8a;
    --shadow: 0 14px 34px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

.on-navy {
    --text: #eef3fb;
    --muted: #a9b9d3;
    --accent: #7cc4ff;
    --accent-strong: #b5ddff;
    --border: rgba(255, 255, 255, .12);
    --border-strong: rgba(255, 255, 255, .24);
    --primary: #ffffff;
    --primary-hover: #e3ecfa;
    --primary-ink: #0b1f3f;
    --circuit-trace: #1b3663;
    --circuit-pin: #2a4a80;
    --circuit-via: var(--navy);
    --circuit-chip: var(--navy-2);
    --energy: #4cc2ff;
    --energy-core: #e4f6ff;
    --energy-glow: rgba(76, 194, 255, .4);
    --neon: #4cc2ff;
    --neon-core: #eaf8ff;
    --neon-glow: rgba(76, 194, 255, .8);
    background: var(--navy);
    color: var(--text);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-optical-sizing: auto; /* Inter ajusta su diseño al tamaño, como Aptos / Aptos Display */
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-strong); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .6em; }
h1 { font-size: clamp(2.2rem, 5.2vw, 3.5rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 650; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0 0 1em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.container { width: min(1160px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.narrow { max-width: 680px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.mt { margin-top: 2.25rem; }
.eyebrow {
    font-family: var(--mono);
    font-size: .76rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 1rem;
}
.lead { font-size: clamp(1.1rem, 2vw, 1.28rem); color: var(--muted); max-width: 60ch; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 12px; z-index: 100; padding: .5rem .8rem; border-radius: 8px; background: var(--primary); color: var(--primary-ink); }

/* ---------- Barra de desplazamiento: píldora con degradado neón → navy ----------
   Chrome, Edge y Safari usan ::-webkit-scrollbar. Firefox no lo soporta: recibe solo los colores
   (en Chrome, scrollbar-color desactivaría estos estilos, por eso va dentro de @supports). */
::-webkit-scrollbar { width: 12px; height: 10px; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--scroll-thumb-top), var(--scroll-thumb-bottom)) padding-box;
    box-shadow: inset 0 0 4px var(--neon-glow);
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #7cc4ff, var(--scroll-thumb-top)) padding-box;
    box-shadow: inset 0 0 8px var(--neon-glow);
}
::-webkit-scrollbar-thumb:active { background: var(--scroll-thumb-top) padding-box; }
::-webkit-scrollbar-corner { background: var(--scroll-track); }
@supports not selector(::-webkit-scrollbar) {
    html { scrollbar-color: var(--scroll-thumb-top) var(--scroll-track); }
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: .8rem; color: var(--text); text-decoration: none; font-weight: 600; }
.brand:hover { color: var(--text); }

/* Logo con forma de chip: pines a los lados */
.brand-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: var(--navy);
    border: 1px solid var(--navy-2);
    font: 600 .75rem/1 var(--mono);
    color: #ffffff;
}
.brand-mark::before, .brand-mark::after {
    content: '';
    position: absolute;
    top: 7px;
    bottom: 7px;
    width: 4px;
    background: repeating-linear-gradient(180deg, var(--circuit-pin) 0 3px, transparent 3px 7px);
}
.brand-mark::before { left: -5px; }
.brand-mark::after { right: -5px; }

.site-nav { display: flex; align-items: center; gap: .5rem; }
.nav-links { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.nav-links a {
    display: block;
    padding: .45rem .8rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: .95rem;
    font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }

.theme-toggle, .nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.theme-toggle:hover, .nav-toggle:hover { color: var(--accent); border-color: var(--accent); }
.nav-toggle { display: none; }
.icon-sun { display: none; }
[data-theme="navy"] .icon-sun { display: block; }
[data-theme="navy"] .icon-moon { display: none; }

@media (max-width: 760px) {
    .js .nav-toggle { display: inline-grid; }
    .js .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        flex-direction: column;
        padding: .75rem var(--gutter) 1rem;
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }
    .js .site-nav.is-open .nav-links { display: flex; }
    .nav-links a { padding: .7rem .8rem; }
    .nav-links a[aria-current="page"] { box-shadow: inset 2px 0 0 var(--accent); }
}

/* ---------- Botones ---------- */
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .8rem 1.3rem;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: 600 .95rem/1 var(--font);
    text-decoration: none;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.on-navy .btn { background: transparent; }
.btn:hover { color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.btn-primary, .on-navy .btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { color: var(--primary-ink); background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: 0 10px 24px -12px var(--energy-glow); }

/* ---------- Hero y cabeceras ---------- */
.hero, .page-head {
    position: relative;
    overflow-x: hidden;
    overflow-x: clip;
    background:
        radial-gradient(1000px 520px at 88% 12%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
        linear-gradient(180deg, var(--bg-alt), var(--bg));
}
.hero { padding: clamp(72px, 11vw, 136px) 0 clamp(64px, 9vw, 108px); }
.page-head { padding: clamp(56px, 8vw, 92px) 0 clamp(40px, 6vw, 60px); }
.hero .container, .page-head .container { position: relative; z-index: 1; }
.hero h1 { max-width: 20ch; }
.page-head h1 { max-width: 24ch; }

.areas { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 2.5rem 0 0; }
.areas li {
    font: .78rem/1 var(--mono);
    padding: .45rem .75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
}
.areas li::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: .5rem;
    border-radius: 50%;
    vertical-align: middle;
    background: var(--accent);
    box-shadow: 0 0 6px var(--energy-glow);
}
.back { display: inline-block; margin-bottom: 1.5rem; font-size: .95rem; text-decoration: none; }

/* ---------- Circuito (views/partials/circuit.php) ---------- */
.circuit {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 30%, rgba(0, 0, 0, .35) 52%, #000 80%);
            mask-image: linear-gradient(90deg, transparent 30%, rgba(0, 0, 0, .35) 52%, #000 80%);
}
.circuit .trace { fill: none; stroke: var(--circuit-trace); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }

/* Pulso de energía: un trazo corto (núcleo + halo) que recorre la pista y la ilumina.
   pathLength=100 normaliza la longitud; la cabeza avanza de 0 a 130 durante el 60 % del ciclo
   y luego la pista descansa. Valores en px explícitos para que el navegador interpole. */
.circuit .pulse {
    fill: none;
    stroke-linecap: round;
    animation-duration: var(--dur, 6s);
    animation-delay: var(--delay, 0s);
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
.circuit .pulse-glow {
    stroke: var(--energy);
    stroke-width: 5;
    opacity: .28;
    stroke-dasharray: 26px 400px;
    stroke-dashoffset: 26px;
    animation-name: flow-glow;
}
.circuit .pulse-core {
    stroke: var(--energy-core);
    stroke-width: 1.6;
    stroke-dasharray: 9px 400px;
    stroke-dashoffset: 9px;
    animation-name: flow-core;
}
@keyframes flow-glow {
    0%        { stroke-dashoffset: 26px; }
    60%, 100% { stroke-dashoffset: -104px; }
}
@keyframes flow-core {
    0%        { stroke-dashoffset: 9px; }
    60%, 100% { stroke-dashoffset: -121px; }
}

/* La vía final se enciende cuando llega el pulso (~46 % del ciclo) */
.circuit .via { fill: var(--circuit-via); stroke: var(--circuit-pin); stroke-width: 1.5; }
.circuit .via-glow { fill: var(--energy); opacity: 0; animation: via-flash var(--dur, 6s) ease-out var(--delay, 0s) infinite; }
@keyframes via-flash {
    0%, 42%   { opacity: 0; }
    47%       { opacity: .75; }
    64%, 100% { opacity: 0; }
}

.circuit.is-paused * { animation-play-state: paused; }

/* ---------- Nube de neuronas del inicio (canvas animado desde app.js) ----------
   Colores en tripletes RGB porque el canvas los combina con transparencia. */
.neuron-cloud {
    --cloud-rgb: 29, 78, 216;
    --cloud-glow-rgb: 59, 130, 246;
    position: absolute;
    top: 50%;
    right: max(var(--gutter), calc((100% - 1160px) / 2));
    z-index: 0;
    display: block;
    width: min(40%, 540px);
    aspect-ratio: 1.15;
    transform: translateY(-50%);
    -webkit-mask-image: radial-gradient(closest-side, #000 70%, transparent);
            mask-image: radial-gradient(closest-side, #000 70%, transparent);
}
[data-theme="navy"] .neuron-cloud { --cloud-rgb: 124, 196, 255; --cloud-glow-rgb: 76, 194, 255; }
/* Las zonas vacías del texto dejan pasar el cursor a la nube (que activa neuronas al pasar) */
.hero .container, .hero .actions, .hero .areas { pointer-events: none; }
.hero .container :is(a, button, p, h1, li) { pointer-events: auto; }

/* Escritorio: el párrafo del inicio termina antes de la nube de neuronas */
@media (min-width: 1101px) { .hero .lead { max-width: 46ch; } }
/* Pantallas medianas: el texto ocupa casi todo el ancho; pistas más tenues */
@media (max-width: 1100px) {
    .hero .circuit, .page-head .circuit { opacity: .7; }
    .neuron-cloud { width: min(50%, 460px); opacity: .45; }
}
/* Celular: la nube va arriba del texto, como lo primero que se ve */
@media (max-width: 760px) {
    .neuron-cloud {
        position: relative;
        top: auto;
        right: auto;
        width: calc(100% - 2 * var(--gutter));
        max-width: 440px;
        aspect-ratio: 1.5;
        margin: -48px auto 0;
        opacity: 1;
        transform: none;
    }
}
@media (max-width: 760px) {
    .circuit, .hero .circuit, .page-head .circuit {
        opacity: .45;
        -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .4) 50%, transparent 100%);
                mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .4) 50%, transparent 100%);
    }
}

/* ---------- Separadores neón con un destello que los recorre ----------
   ::before = línea base con resplandor · ::after = destello (solo se anima transform: lo mueve la GPU).
   Abajo en encabezados; arriba en la sección gris, la banda navy y el pie. Cada uno con su ritmo. */
.hero::before, .hero::after, .page-head::before, .page-head::after,
.section-alt::before, .section-alt::after, .cta-band::before, .cta-band::after,
.site-footer::before, .site-footer::after {
    content: '';
    position: absolute;
    left: 0;
    z-index: 2;
    pointer-events: none;
}
.hero::before, .hero::after, .page-head::before, .page-head::after { bottom: 0; }
.section-alt::before, .section-alt::after, .cta-band::before, .cta-band::after,
.site-footer::before, .site-footer::after { top: 0; }

.hero::before, .page-head::before, .section-alt::before, .cta-band::before, .site-footer::before {
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--neon) 18%, var(--neon) 82%, transparent);
    opacity: .65;
    box-shadow: 0 0 12px 1px var(--neon-glow);
}
.hero::after, .page-head::after, .section-alt::after, .cta-band::after, .site-footer::after {
    width: 26%;
    height: 2px;
    margin-block: -.5px;
    background: linear-gradient(90deg, transparent, var(--neon) 30%, var(--neon-core) 50%, var(--neon) 70%, transparent);
    filter: drop-shadow(0 0 4px var(--neon)) drop-shadow(0 0 14px var(--neon-glow));
    transform: translateX(-110%);
    animation: neon-run 7s cubic-bezier(.55, 0, .45, 1) infinite;
    will-change: transform;
}
.section-alt::after { animation-duration: 8.5s; animation-delay: -3s; animation-direction: reverse; }
.cta-band::after    { animation-duration: 6.5s; animation-delay: -1.2s; }
.site-footer::after { animation-duration: 9.5s; animation-delay: -5s; animation-direction: reverse; }
@keyframes neon-run {
    0%        { transform: translateX(-110%); }
    60%, 100% { transform: translateX(400%); }
}

/* ---------- Secciones ---------- */
.section { padding: clamp(56px, 8vw, 96px) 0; }
.section-alt { position: relative; overflow-x: hidden; overflow-x: clip; background: var(--bg-alt); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.75rem; }
.section-head h2 { margin: 0; }
.link-arrow { font-weight: 500; text-decoration: none; }

/* ---------- Tarjetas de proyecto ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1.25rem; }
.project-grid--2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.project-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color .25s, transform .25s, box-shadow .25s;
}
/* Destello de energía que recorre el borde superior al pasar el cursor */
.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--energy), var(--energy-core), transparent);
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}
.project-card:hover, .project-card:focus-within {
    border-color: var(--border-strong);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}
.project-card:hover::before, .project-card:focus-within::before { opacity: 1; animation: sweep 1.6s ease-in-out infinite; }
@keyframes sweep {
    from { transform: translateX(-110%); }
    to   { transform: translateX(330%); }
}
.project-card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.project-card-body { display: flex; flex: 1; flex-direction: column; padding: 1.5rem; }
.project-card-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.project-card-link:hover { color: inherit; }
.project-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.project-card .eyebrow { margin: 0; font-size: .7rem; }
.project-card h3 { margin: .9rem 0 .5rem; font-size: 1.2rem; }
.project-card p { flex: 1; color: var(--muted); font-size: .98rem; }
.card-cta { margin-top: 1.25rem; font-size: .95rem; font-weight: 600; color: var(--accent); }
.card-cta span { display: inline-block; transition: transform .2s; }
.project-card:hover .card-cta span { transform: translateX(4px); }
.badge {
    font: .68rem/1 var(--mono);
    padding: .3rem .5rem;
    border-radius: 6px;
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    background: color-mix(in srgb, var(--accent) 7%, transparent);
}

/* ---------- Etiquetas y Tech Explorer ---------- */
.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 1rem 0 0; }
.tags li, .tags-links a {
    font: .74rem/1.2 var(--mono);
    padding: .3rem .55rem;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.tags-links li { padding: 0; border: 0; background: none; }
.tags-links a { display: inline-block; text-decoration: none; }
.tags-links a:hover { color: var(--text); border-color: var(--accent); }

.tech-explorer { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0 0 2rem; }
.tech-explorer a {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: border-color .2s, box-shadow .2s;
}
.tech-explorer a:hover { color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.tech-explorer a[aria-current] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.count { font: .7rem/1.4 var(--mono); padding: 0 .45rem; border-radius: 999px; color: var(--muted); background: var(--surface-2); }
.tech-explorer a[aria-current] .count { color: var(--primary-ink); background: color-mix(in srgb, var(--primary-ink) 18%, transparent); }

/* ---------- Banda CTA navy con circuito en los bordes ---------- */
.cta-band { position: relative; overflow-x: hidden; overflow-x: clip; padding: clamp(64px, 9vw, 104px) 0; text-align: center; }
.cta-band .circuit {
    -webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 50%, transparent 35%, #000 85%);
            mask-image: radial-gradient(ellipse 60% 70% at 50% 50%, transparent 35%, #000 85%);
}
.cta-inner { position: relative; z-index: 1; }
.cta-inner .muted { margin-bottom: 1.75rem; }

/* ---------- Sobre mí ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 72px); }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* Línea de tiempo como pista de circuito con energía bajando */
.timeline { position: relative; list-style: none; margin: 0; padding: 0 0 0 30px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 2px;
    background: linear-gradient(180deg, transparent, var(--energy-core), var(--energy), transparent) no-repeat 0 -140px / 100% 140px, var(--circuit-trace);
    animation: flow-down 7s linear infinite;
}
@keyframes flow-down { to { background-position: 0 calc(100% + 140px); } }
.timeline > li { position: relative; padding-bottom: 2.25rem; }
.timeline > li::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 5px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
.timeline-period { font-size: .76rem; letter-spacing: .04em; color: var(--accent); }
.timeline h3 { margin: .35rem 0 .6rem; }
.timeline ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.timeline ul li { margin-bottom: .35rem; }
.skill-group { margin: 1.5rem 0 .6rem; font: 500 .76rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
aside .tags { margin-top: 0; }
.education { display: grid; gap: .9rem; list-style: none; margin: 0; padding: 0; }

/* ---------- Caso de estudio ---------- */
.case-cover { margin: 0 0 clamp(32px, 5vw, 56px); overflow: hidden; border: 1px solid var(--border); border-radius: 16px; aspect-ratio: 16 / 9; background: var(--surface-2); box-shadow: var(--shadow); }
.case-cover img { width: 100%; height: 100%; object-fit: cover; }
.draft-banner { padding: .65rem var(--gutter); text-align: center; font-size: .92rem; color: #7a4d00; background: #fff4dc; border-bottom: 1px solid #f1d49a; }
[data-theme="navy"] .draft-banner { color: #ffd899; background: #3a2a0b; border-color: #5c4412; }
.case-study { max-width: 880px; padding-block: clamp(48px, 7vw, 80px); }
.case-block { margin-bottom: 2.5rem; padding-bottom: 2.5rem; border-bottom: 1px solid var(--border); }
.case-block h2 { display: flex; align-items: center; gap: .8rem; font-size: 1.4rem; }
.case-block p { max-width: 68ch; color: var(--muted); font-size: 1.05rem; }
.step {
    padding: .2rem .45rem;
    border-radius: 6px;
    font-size: .76rem;
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.results { display: grid; gap: .8rem; list-style: none; margin: 0; padding: 0; }
.results li { position: relative; padding: 1rem 1rem 1rem 3rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.results li::before {
    content: '';
    position: absolute;
    left: 1.15rem;
    top: 1.3rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Módulos del sistema: tarjetas con índice tipo chip y destello de energía al pasar el cursor */
.case-block h2 .count { font-size: .78rem; }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 1rem; margin-top: 1.25rem; }
.module-card {
    position: relative;
    overflow: hidden;
    padding: 1.1rem 1.2rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    transition: border-color .25s, box-shadow .25s;
}
.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--energy), var(--energy-core), transparent);
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}
.module-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.module-card:hover::before { opacity: 1; animation: sweep 1.6s ease-in-out infinite; }
.module-card header { display: flex; align-items: center; gap: .65rem; margin-bottom: .55rem; }
.module-index {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: .7rem;
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.module-card h3, .module-card h4 { margin: 0; font-size: 1rem; line-height: 1.3; }
.modules-group {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    gap: .75rem;
    margin: 1rem 0 -.25rem;
    font: 500 .76rem/1 var(--mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}
.modules-group:first-child { margin-top: 0; }
.modules-group::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.case-block .module-card p { margin: 0 0 .65rem; font-size: .93rem; }
.module-card ul { display: grid; gap: .3rem; margin: 0; padding: 0; list-style: none; }
.module-card li { position: relative; padding-left: 1rem; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.module-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: .55em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
}

/* Diagrama de arquitectura: nodos unidos por pistas; la energía viaja de nodo en nodo
   y cada nodo se ilumina al recibirla. --i (índice) viene del HTML. */
.architecture {
    --step: .9s;
    --cycle: 2.7s;
    --gap: 36px;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: var(--gap);
    list-style: none;
    margin: 1.5rem 0 0;
    padding: 0;
}
.architecture li { position: relative; }
.architecture .node {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 84px;
    padding: .8rem .6rem;
    text-align: center;
    overflow-wrap: anywhere;
    font: 500 .78rem/1.4 var(--mono);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    animation: node-glow var(--cycle) ease-out infinite;
    animation-delay: calc(var(--i, 0) * var(--step));
}
.architecture li:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    width: var(--gap);
    height: 2px;
    margin-top: -1px;
    background: linear-gradient(90deg, transparent, var(--energy-core), var(--energy), transparent) no-repeat -66.7% 0 / 40% 100%, var(--circuit-trace);
    animation: arch-flow-x var(--cycle) linear infinite;
    animation-delay: calc(var(--i, 0) * var(--step));
}
@keyframes arch-flow-x {
    0%        { background-position: -66.7% 0; }
    33%, 100% { background-position: 166.7% 0; }
}
@keyframes arch-flow-y {
    0%        { background-position: 0 -66.7%; }
    33%, 100% { background-position: 0 166.7%; }
}
@keyframes node-glow {
    0%, 30%, 100% { border-color: var(--border-strong); box-shadow: none; }
    6%            { border-color: var(--energy); box-shadow: 0 0 0 1px var(--energy), 0 0 20px -6px var(--energy-glow); }
}
@media (max-width: 860px) {
    .architecture { grid-auto-flow: row; --gap: 26px; }
    .architecture .node { min-height: 0; padding: .75rem 1rem; }
    .architecture li:not(:last-child)::after {
        top: 100%;
        left: 50%;
        width: 2px;
        height: var(--gap);
        margin: 0 0 0 -1px;
        background: linear-gradient(180deg, transparent, var(--energy-core), var(--energy), transparent) no-repeat 0 -66.7% / 100% 40%, var(--circuit-trace);
        animation-name: arch-flow-y;
    }
}

.case-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.case-nav a {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}
.case-nav a:hover { color: var(--text); border-color: var(--accent); }
.case-nav .next { grid-column: 2; text-align: right; }
.case-nav .muted { font-size: .85rem; font-weight: 500; }
@media (max-width: 600px) {
    .case-nav { grid-template-columns: 1fr; }
    .case-nav .next { grid-column: auto; text-align: left; }
}

/* ---------- Formulario ---------- */
.form { display: grid; gap: 1.1rem; }
.field label { display: block; margin-bottom: .4rem; font-size: .95rem; font-weight: 500; }
.field input, .field textarea {
    width: 100%;
    padding: .8rem .95rem;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
    transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 150px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field [aria-invalid="true"] { border-color: var(--danger); }
.field-error { margin: .35rem 0 0; color: var(--danger); font-size: .88rem; }
.form .btn { justify-self: start; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.alert { margin-bottom: 1.5rem; padding: 1rem 1.2rem; border-radius: 12px; border: 1px solid; }
.alert-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); background: color-mix(in srgb, var(--success) 8%, transparent); }
.alert-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); }

/* ---------- Footer (navy) ---------- */
.site-footer { position: relative; overflow-x: hidden; overflow-x: clip; padding: 2rem 0; font-size: .92rem; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.footer-inner p { margin: 0; color: var(--muted); }
.footer-links { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* ---------- Text Scramble en títulos (app.js) ----------
   Cada letra real queda transparente (reserva su espacio exacto, sin saltos de diseño)
   y encima se dibuja un glifo aleatorio hasta que la letra se "resuelve". */
@media (prefers-reduced-motion: no-preference) {
    /* Ocultos hasta que el script los decodifica; si el JS falla, aparecen solos a los 1.5 s */
    .js :is(main h1, main h2, [data-scramble]):not(.is-scrambling, .scramble-done) {
        visibility: hidden;
        animation: scramble-failsafe 0s linear 1.5s forwards;
    }
}
@keyframes scramble-failsafe { to { visibility: visible; } }
.sc { position: relative; color: transparent; }
.sc::after {
    content: attr(data-g);
    position: absolute;
    top: 0;
    left: 0;
    color: var(--accent);
    opacity: .9;
}
.sc-wait::after { content: none; }

/* ---------- IA aplicada (inicio) ---------- */
.ai-intro {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
    align-items: center;
    gap: clamp(28px, 5vw, 64px);
    margin-bottom: clamp(32px, 5vw, 56px);
}
@media (max-width: 900px) { .ai-intro { grid-template-columns: 1fr; } }
.ai-intro h2 { max-width: 18ch; }
.ai-uses { display: grid; gap: .55rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.ai-uses li { position: relative; padding-left: 1.6rem; }
.ai-uses li::before {
    content: '';
    position: absolute;
    left: 0;
    top: .5em;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--accent);
    box-shadow: 0 0 10px var(--neon-glow);
}

/* Consola con un prompt de ejemplo: se escribe línea por línea al aparecer (sin JS se ve completa) */
.prompt-card {
    margin: 0;
    overflow: hidden;
    border: 1px solid #1a3464;
    border-radius: 14px;
    background: #0b1f3f;
    color: #e6eefb;
    box-shadow: var(--shadow), 0 24px 44px -26px rgba(47, 123, 255, .6);
}
.prompt-card figcaption {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1rem;
    border-bottom: 1px solid #1a3464;
    background: #081937;
    color: #9aaecf;
    font: .75rem/1 var(--mono);
}
.prompt-card .dots { display: inline-flex; gap: 5px; }
.prompt-card .dots i { width: 9px; height: 9px; border-radius: 50%; background: #274a86; }
.prompt-body { padding: 1.1rem 1.2rem 1.3rem; font-size: .84rem; line-height: 1.75; }
.prompt-line { margin: 0; }
.prompt-key { color: #4cc2ff; }
.prompt-result { margin-top: .6rem; color: #3ddc97; }
.prompt-result::after { content: '▍'; margin-left: .2rem; color: #4cc2ff; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.js .prompt-card .prompt-line { clip-path: inset(0 100% 0 0); }
.js .prompt-card.is-visible .prompt-line { animation: type-line .7s steps(28, end) forwards; animation-delay: calc(.25s + var(--i) * .75s); }
@keyframes type-line { to { clip-path: inset(0 0 0 0); } }

.ai-skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.ai-skill {
    position: relative;
    overflow: hidden;
    padding: 1.3rem 1.35rem 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color .25s, box-shadow .25s;
}
.ai-skill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--energy), var(--energy-core), transparent);
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}
.ai-skill:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.ai-skill:hover::before { opacity: 1; animation: sweep 1.6s ease-in-out infinite; }
.ai-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin-bottom: .9rem;
    border-radius: 11px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 9%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.ai-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ai-skill h3 { margin: 0 0 .45rem; font-size: 1.05rem; }
.ai-skill p { margin: 0; color: var(--muted); font-size: .95rem; }
.ai-skill .link-arrow { display: inline-block; margin-top: .8rem; font-size: .92rem; }

/* ---------- Minijuego: huevos escondidos en los textos y manzana (app.js) ---------- */
.egg {
    display: inline-block;
    width: .8em;
    height: 1em;
    margin: 0 .15em;
    padding: 0;
    border: 0;
    background: none;
    vertical-align: -.15em;
    line-height: 0;
    cursor: pointer;
    transition: transform .2s ease;
}
.egg svg, .egg-counter svg { display: block; width: 100%; height: 100%; overflow: visible; }
.egg path, .egg-counter path {
    fill: color-mix(in srgb, var(--accent) 8%, var(--surface));
    stroke: color-mix(in srgb, var(--accent) 45%, var(--muted));
    stroke-width: 1.3;
}
.egg circle, .egg-counter circle { fill: color-mix(in srgb, var(--accent) 55%, transparent); }
.egg:hover { transform: rotate(-14deg) scale(1.3); }
.egg.is-found { pointer-events: none; animation: egg-found .6s ease-out forwards; }
@keyframes egg-found {
    35%  { transform: scale(1.9) rotate(16deg); }
    100% { transform: translateY(-1.2em) scale(.3); opacity: 0; }
}
.egg-counter {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .45rem .8rem .45rem .6rem;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: 600 .82rem/1 var(--mono);
    box-shadow: var(--shadow);
    cursor: pointer;
}
.egg-counter svg { width: 13px; height: 17px; }
.egg-counter img { width: 20px; height: 20px; }
.egg-toast {
    position: fixed;
    left: 50%;
    bottom: 72px;
    z-index: 61;
    max-width: min(420px, calc(100% - 32px));
    padding: .7rem 1rem;
    border-radius: 12px;
    background: #0b1f3f;
    color: #ffffff;
    font-size: .92rem;
    text-align: center;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
}
.egg-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.apple-pet {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 70;
    width: 56px;
    height: 56px;
    pointer-events: none;
    will-change: transform;
}
.apple-pet img {
    display: block;
    width: 100%;
    height: 100%;
    animation: apple-bob 2.6s ease-in-out infinite;
    filter: drop-shadow(0 8px 10px rgba(11, 31, 63, .28));
}
.apple-pet.is-new img { animation: apple-pop .7s cubic-bezier(.3, 1.6, .5, 1), apple-bob 2.6s ease-in-out .7s infinite; }
@keyframes apple-bob { 50% { transform: translateY(-6px); } }
@keyframes apple-pop {
    from { transform: scale(0) rotate(-40deg); }
    to   { transform: scale(1) rotate(0); }
}
.apple-pet--static { left: auto; top: auto; right: 16px; bottom: 16px; }
@media print { .egg, .egg-counter, .egg-toast, .apple-pet { display: none !important; } }

/* ---------- Aparición al hacer scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Movimiento reducido: circuitos estáticos ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
    .js .reveal { opacity: 1; transform: none; }
    .circuit .pulse, .circuit .via-glow { display: none; }
    .hero::after, .page-head::after, .section-alt::after, .cta-band::after, .site-footer::after { display: none; }
    .js .prompt-card .prompt-line { clip-path: none; }
}
