/* ===================================
   FONTS SELF-HOSTED
   ===================================
   Inter (UI) + JetBrains Mono (code). Subset latín.
   font-display: swap → muestra el fallback inmediato, swap al cargar.
   Esto elimina 2 dependencias externas (Google Fonts) y reduce LCP
   en ~3 s según Lighthouse. */
@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('resources/fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('resources/fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('resources/fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: Inter;
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('resources/fonts/inter-700.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('resources/fonts/jetbrains-mono-400.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('resources/fonts/jetbrains-mono-500.woff2') format('woff2');
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('resources/fonts/jetbrains-mono-600.woff2') format('woff2');
}

/* ===================================
   VARIABLES Y RESET
   =================================== */
   :root {
    /* Colores principales */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;

    /* Paleta extendida — semantic tokens (eliminan 28 hardcoded colors en el CSS) */
    --color-indigo-200: #c7d2fe;
    --color-indigo-300: #a5b4fc;
    --color-emerald-300: #6ee7b7;
    --color-emerald-400: #34d399;
    --color-cyan-300: #67e8f9;
    --color-cyan-400: #22d3ee;
    --color-teal-300: #5eead4;
    --color-amber-300: #fcd34d;
    --color-amber-400: #fbbf24;
    --color-red-300: #fca5a5;
    --color-red-400: #f87171;
    --color-rose-200: #fecaca;
    --color-violet-deep: #1e1b4b;
    --color-sky-deep: #082f49;

    /* Colores de fondo */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;

    /* Colores de texto */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* Sombras */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    /* Tipografía */
    --font-primary: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;

    /* Transiciones */
    --transition: all 0.3s ease;

    /* Breakpoints (uso documental, las MQ se mantienen como px hasta que se adopten container queries) */
    --bp-sm: 480px;
    --bp-md: 768px;
    --bp-lg: 968px;
    --bp-xl: 1280px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem; 
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===================================
   NAVEGACIÓN
   =================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.navbar.scrolled {
    padding: 0.5rem 0;
    box-shadow: var(--shadow-md);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo i {
    font-size: 1.8rem;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Link externo al Lab — diferenciado del resto del nav */
.nav-link-external {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(34, 211, 238, 0.12));
    color: var(--primary-light);
    font-weight: 600;
}

.nav-link-external::after { display: none; } /* sin underline animado */

.nav-link-external:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.32), rgba(34, 211, 238, 0.22));
    border-color: var(--primary-color);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.nav-link-external .nav-external-icon {
    font-size: 0.72rem;
    opacity: 0.75;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 5px;
    transition: var(--transition);
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ===================================
   SELECTOR DE IDIOMAS
   =================================== */
.language-selector {
    position: relative;
    margin-left: 1rem;
}

.language-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 2px solid var(--primary-color);
    border-radius: 25px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
}

.language-btn:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.language-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: none;
    min-width: 150px;
    overflow: hidden;
    z-index: 1000;
}

.language-dropdown.active {
    display: block;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.lang-option:hover {
    background: var(--primary-color);
}

.lang-option img {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

/* ===================================
   HERO SECTION
   =================================== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding-top: 80px;
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    z-index: 1;
}

.hero-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
}

.code-rain {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0.05;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, var(--text-primary) 2px, var(--text-primary) 4px);
    animation: rain 20s linear infinite;
}

@keyframes rain {
    0% { transform: translateY(0); }
    100% { transform: translateY(20px); }
}

.hero-container {
    position: relative;
    z-index: 2;
}

.hero-content {
    text-align: center;
    animation: fadeInUp 1s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Contenedor del Avatar */
.hero-avatar-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto 2rem;
    animation: fadeInUp 1s ease backwards;
}

.hero-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--bg-secondary);
    box-shadow: var(--shadow-glow), 0 10px 25px rgba(0,0,0,0.3);
    transition: var(--transition);
}

.hero-avatar-img:hover {
    transform: scale(1.05) rotate(2deg);
    border-color: var(--primary-color);
}

.status-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background-color: var(--secondary-color);
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--secondary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.hero-tag {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: 50px;
    color: var(--primary-light);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    animation: fadeInUp 1s ease 0.2s backwards;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    animation: fadeInUp 1s ease 0.4s backwards;
}

.highlight {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto 2rem;
    animation: fadeInUp 1s ease 0.6s backwards;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 3rem;
    animation: fadeInUp 1s ease 0.8s backwards;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    /* WCAG 2.2 AA: white sobre --primary-color #6366f1 = 4.47 (falla).
       Sobre --primary-dark #4f46e5 = 6.29 (pasa con margen). */
    background: var(--primary-dark);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: #4338ca; /* indigo-700 — ratio 7.9 */
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.btn-accent {
    background: var(--secondary-color);
    color: var(--bg-primary);
    box-shadow: var(--shadow-sm);
}

.btn-accent:hover {
    background: #0c9a75;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Botón especial para abrir el Lab externo: degradado distintivo */
.btn-lab {
    background: linear-gradient(135deg, #0d9488, #06b6d4);
    color: white;
    border: 1px solid rgba(94, 234, 212, 0.4);
    box-shadow: 0 8px 24px -10px rgba(13, 148, 136, 0.55);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-lab:hover {
    background: linear-gradient(135deg, #14b8a6, var(--color-cyan-400));
    transform: translateY(-2px);
    box-shadow: 0 12px 28px -10px rgba(34, 211, 238, 0.6);
    color: white;
}

.btn-lab-primary {
    /* En el modal: la acción principal cuando hay lab disponible */
    padding-left: 1.3rem;
    padding-right: 1.3rem;
}

/* Icon-link variante "lab" en project-actions */
.icon-link.icon-link-lab {
    color: var(--color-teal-300);
}

.icon-link.icon-link-lab:hover {
    color: white;
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.35), rgba(6, 182, 212, 0.35));
}

.hero-stats {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(160px, 1fr);
    gap: 1.5rem;
    justify-content: center;
    align-items: stretch;
    max-width: 100%;
    margin: 0 auto;
    padding-bottom: 0.5rem;
    overflow-x: auto;
    animation: fadeInUp 1s ease 1s backwards;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.hero-stats::-webkit-scrollbar {
    height: 6px;
}

.hero-stats::-webkit-scrollbar-track {
    background: transparent;
}

.hero-stats::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 999px;
}

.stat-item {
    text-align: center;
    min-width: 160px;
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: var(--font-code);
}

.stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.scroll-indicator span {
    display: block;
    width: 24px;
    height: 40px;
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    position: relative;
}

.scroll-indicator span::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 2px;
    animation: scroll 2s infinite;
}

@keyframes scroll {
    0% { top: 8px; opacity: 1; }
    50% { top: 50%; opacity: 0.5; }
    100% { top: 8px; opacity: 1; }
}

/* ===================================
   SECCIONES GENERALES
   =================================== */
section {
    padding: 6rem 0;
}

.section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.section-tag {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 50px;
    color: var(--primary-light);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.section-description {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* ===================================
   SOBRE MÍ 
   =================================== */
.about {
    background: var(--bg-secondary);
}

.about-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 4rem;
    align-items: center;
}

.about-image {
    position: relative;
}

.image-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8rem;
    color: rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-lg);
}

.about-badge {
    position: absolute;
    bottom: -15px;
    right: -15px;
    background: var(--secondary-color);
    padding: 1rem 1.5rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

.about-text h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.about-text p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.about-highlights {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
}

.highlight-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.highlight-item i {
    font-size: 2rem;
    color: var(--primary-color);
    min-width: 50px;
}

.highlight-item h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.highlight-item p {
    color: var(--text-muted);
    margin: 0;
}

.about-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

.about-cta .btn {
    flex: 1;
    min-width: 180px;
    text-align: center;
}

/* ===================================
   PROYECTOS — Rediseño UX 2026
   =================================== */

/* Utility: solo para lectores de pantalla */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link — visible solo en foco por teclado (WCAG 2.4.1 Bypass Blocks) */
.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateY(-110%);
    background: var(--primary-dark);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 8px 0;
    z-index: 10000;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.15s ease;
}
.skip-link:focus {
    transform: translateY(0);
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* Focus visible mejorado para elementos interactivos sin foco propio explícito */
.hero-dot:focus-visible,
.hero-nav:focus-visible,
.filter-btn:focus-visible,
.modal-close:focus-visible,
.modal-gallery-dot:focus-visible,
.suggest-chip:focus-visible,
.active-chip:focus-visible,
.active-clear-all:focus-visible,
.search-clear:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 3px;
}

/* Reveal animation: la clase se añade por JS en initIntersectionObserver.
   Si JS está deshabilitado o tarda, el contenido permanece visible. */
.section-pre-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.section-revealed {
    opacity: 1;
    transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
    .section-pre-reveal,
    .section-revealed {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* --- HERO CAROUSEL --- */
.projects-hero {
    position: relative;
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 70%, #082f49 100%);
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(99, 102, 241, 0.25);
    box-shadow: 0 30px 80px -30px rgba(99, 102, 241, 0.4);
    margin-bottom: 3rem;
}

.projects-hero[hidden] { display: none; }

.hero-track {
    position: relative;
    min-height: 560px;
}

.hero-slide {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    pointer-events: none;
}

.hero-slide.is-active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.hero-slide-visual {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.18), transparent 60%),
        radial-gradient(circle at 70% 70%, rgba(34, 211, 238, 0.12), transparent 60%),
        rgba(15, 23, 42, 0.75);
    padding: 1.25rem;
}

.hero-slide-visual img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.hero-slide-visual i {
    font-size: 8rem;
    color: rgba(99, 102, 241, 0.45);
}

.hero-slide-content {
    padding: 2.25rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.85rem;
    min-width: 0; /* permitir que el contenido se contraiga si hace falta */
}

.hero-slide-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(99, 102, 241, 0.5);
    color: var(--color-indigo-200);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    width: fit-content;
}

.hero-slide-title {
    font-size: clamp(1.65rem, 2.8vw, 2.25rem);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.hero-slide-desc {
    color: var(--text-secondary);
    font-size: 0.98rem;
    line-height: 1.55;
    max-width: 56ch;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-slide-impact {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.45);
    color: var(--color-emerald-300);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    width: fit-content;
}

.hero-slide-impact i { color: var(--accent-color); }

.hero-slide-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.hero-slide-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.5rem;
}

.hero-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    transition: var(--transition);
    z-index: 3;
}

.hero-nav:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-50%) scale(1.05);
}

.hero-nav-prev { left: 16px; }
.hero-nav-next { right: 16px; }

.hero-dots {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 3;
}

.hero-dot {
    width: 26px;
    height: 6px;
    border-radius: 3px;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: var(--transition);
}

.hero-dot.is-active {
    background: var(--primary-light);
    width: 38px;
}

.hero-dot:hover { background: rgba(255, 255, 255, 0.45); }

/* --- FILTROS --- */
.project-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.65rem 1.1rem 0.65rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn i { font-size: 0.95rem; color: inherit; }

.filter-count {
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: var(--transition);
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-light);
    transform: translateY(-2px);
}

.filter-btn:hover .filter-count {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-color: transparent;
    color: white;
    box-shadow: var(--shadow-glow);
}

.filter-btn.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

/* --- TOOLBAR (search + sort) --- */
.projects-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.search-box {
    flex: 1 1 320px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.1rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.search-box i { color: var(--text-muted); font-size: 1rem; }

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
}

.search-box input::placeholder { color: var(--text-muted); }

.search-clear {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.search-clear:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.08); }
.search-clear[hidden] { display: none; }

.projects-sort {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.sort-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.sort-select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 0.55rem 2.2rem 0.55rem 0.85rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23cbd5e1'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 18px;
    transition: var(--transition);
}

.sort-select:hover, .sort-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* --- ACTIVE FILTERS BAR --- */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px dashed rgba(99, 102, 241, 0.35);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.active-filters[hidden] { display: none; }

.active-filters-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 0.25rem;
}

.active-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--color-indigo-200);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.active-chip:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.55);
    color: var(--color-rose-200);
}

.active-clear-all {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.active-clear-all:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* --- RESULTS COUNT --- */
.projects-results-count {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    margin: 0.75rem 0 1.25rem;
}

/* --- GRID --- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 1.75rem;
    margin-bottom: 2.5rem;
}

/* --- TARJETA BASE --- */
.project-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s ease,
                box-shadow 0.3s ease;
    position: relative;
    height: 100%;
    cursor: pointer;
    outline: none;
}

.project-card:hover {
    transform: translateY(-6px);
    border-color: var(--primary-color);
    box-shadow: 0 20px 50px -20px rgba(99, 102, 241, 0.4);
}

.project-card:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 4px;
    border-color: var(--primary-color);
}

/* --- ÁREA VISUAL --- */
.project-visual {
    position: relative;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.project-visual.has-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.project-visual.no-img i {
    font-size: 4rem;
    color: rgba(99, 102, 241, 0.5);
    transition: transform 0.3s ease;
}

.project-card:hover .project-visual.has-img img {
    transform: scale(1.04);
}

.project-card:hover .project-visual.no-img i {
    transform: scale(1.1) rotate(-5deg);
    color: var(--primary-color);
}

/* --- HOVER-SWAP --- */
.project-visual.has-img .project-img-primary,
.project-visual.has-img .project-img-hover {
    position: absolute;
    inset: 0;
    transition: opacity 0.45s ease, transform 0.6s ease;
}

.project-visual.has-img .project-img-hover { opacity: 0; }

.project-card:hover .project-visual.has-img .project-img-primary { opacity: 0; }
.project-card:hover .project-visual.has-img .project-img-hover { opacity: 1; }

/* Dots indicator (affordance) */
.project-img-dots {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 5px;
    padding: 5px 8px;
    background: rgba(15, 23, 42, 0.75);
    border-radius: 999px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.project-img-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    transition: background 0.3s ease;
}

.project-img-dots .dot:first-child { background: var(--primary-light); }

.project-card:hover .project-img-dots .dot:first-child { background: rgba(255, 255, 255, 0.45); }
.project-card:hover .project-img-dots .dot:last-child { background: var(--primary-light); }

/* --- BADGES superpuestos en la imagen --- */
.project-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 2;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    backdrop-filter: blur(6px);
}

.badge-featured {
    background: rgba(245, 158, 11, 0.92);
    color: #1e293b;
}

.badge-featured i { color: #1e293b; }

.badge-year {
    background: rgba(15, 23, 42, 0.85);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.3);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* --- CONTENIDO DE LA CARD --- */
.project-content {
    padding: 1.4rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 0.9rem;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.project-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.project-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-impact-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--color-emerald-300);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    width: fit-content;
}

.project-impact-inline i { color: var(--accent-color); }

.project-footer {
    margin-top: auto;
    padding-top: 0.25rem;
}

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* --- TAG SYSTEM CATEGORIZADO (3 familias) --- */
.tech-tag {
    font-size: 0.72rem;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid;
    transition: var(--transition);
}

.tag-lang {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.35);
    color: var(--color-indigo-300);
}

.tag-framework {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(148, 163, 184, 0.25);
    color: var(--text-secondary);
}

.tag-domain {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.35);
    color: var(--color-emerald-300);
}

.tag-more {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
    font-style: italic;
}

.project-card:hover .tag-lang { background: rgba(99, 102, 241, 0.2); }
.project-card:hover .tag-framework { border-color: rgba(99, 102, 241, 0.4); color: var(--text-primary); }
.project-card:hover .tag-domain { background: rgba(16, 185, 129, 0.18); }

/* Hero usa los mismos tags pero ligeramente mayores */
.hero-slide-tags .tech-tag {
    font-size: 0.8rem;
    padding: 0.3rem 0.85rem;
}

/* --- ACCIONES (icon-links) --- */
.project-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.icon-link {
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: var(--transition);
    padding: 6px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-link:hover {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.12);
    transform: scale(1.06);
}

.icon-link:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* --- GITHUB STATS (stars/forks fetched from GitHub API) --- */
.github-stats {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.15);
}

.github-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease;
}

.github-stat i { color: var(--accent-color); font-size: 0.72rem; }

.project-card:hover .github-stat { color: var(--primary-light); }

/* --- EMPTY STATE --- */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px dashed rgba(148, 163, 184, 0.2);
    border-radius: 16px;
}

.no-results > i {
    font-size: 3.5rem;
    color: var(--primary-light);
    margin-bottom: 1rem;
    opacity: 0.7;
}

.no-results h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.no-results p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.no-results-suggestions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.suggest-chip {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: var(--color-indigo-200);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.suggest-chip:hover {
    background: var(--primary-color);
    color: white;
    border-color: transparent;
}

/* --- LOAD MORE + CTA FINAL --- */
.load-more-container {
    text-align: center;
}

.projects-cta {
    text-align: center;
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px dashed rgba(148, 163, 184, 0.15);
}

.projects-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

/* --- MODAL DE DETALLE --- */
body.no-scroll { overflow: hidden; }

.project-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.project-modal[hidden] { display: none; }

.project-modal.is-open { opacity: 1; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 24, 0.78);
    backdrop-filter: blur(6px);
}

.modal-dialog {
    position: relative;
    background: linear-gradient(160deg, #1e293b, #0f172a);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    max-width: 880px;
    width: 100%;
    max-height: 92vh;
    overflow: hidden;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.project-modal.is-open .modal-dialog {
    transform: translateY(0) scale(1);
}

.modal-body {
    overflow-y: auto;
    padding: 2rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin-bottom: 0.6rem;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
}

.modal-meta-featured {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.45);
    color: var(--color-amber-300);
}

.modal-close {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--color-rose-200);
}

.modal-gallery {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    background: #0f172a;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.modal-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.modal-image.is-active { opacity: 1; }

.modal-gallery-controls {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 2;
}

.modal-gallery-dot {
    width: 30px;
    height: 6px;
    border-radius: 3px;
    border: none;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: var(--transition);
}

.modal-gallery-dot.is-active {
    background: var(--primary-light);
    width: 42px;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-light);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
}

.modal-section p {
    color: var(--text-secondary);
    line-height: 1.65;
    font-size: 0.98rem;
}

.modal-impact {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--color-emerald-300) !important;
    border-radius: 10px;
    font-weight: 600;
}

.modal-impact i { color: var(--accent-color); }

.modal-stack {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.modal-stack-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.75rem;
    align-items: start;
}

.modal-stack-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding-top: 0.3rem;
}

.modal-stack-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 1.5rem;
    border-top: 1px dashed rgba(148, 163, 184, 0.15);
    margin-top: 1rem;
}

/* --- REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
    .project-visual.has-img .project-img-primary,
    .project-visual.has-img .project-img-hover,
    .hero-slide,
    .modal-dialog,
    .project-modal,
    .modal-image,
    .cv-modal,
    .cv-dialog {
        transition-duration: 0.01ms !important;
    }
    .project-card:hover .project-visual.has-img img,
    .project-card:hover { transform: none; }
}

/* ===================================
   CV REQUEST MODAL (gated download)
   =================================== */
.cv-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.cv-modal[hidden] { display: none; }

.cv-modal.is-open { opacity: 1; }

.cv-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 24, 0.78);
    backdrop-filter: blur(6px);
}

.cv-dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    background: linear-gradient(160deg, #1e293b, #0f172a);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cv-modal.is-open .cv-dialog {
    transform: translateY(0) scale(1);
}

.cv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cv-tag {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--color-emerald-300);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.65rem;
}

#cvModalTitle {
    color: var(--text-primary);
    font-size: clamp(1.3rem, 2vw, 1.6rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem;
}

.cv-subtitle {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.55;
    margin: 0;
    max-width: 44ch;
}

.cv-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cv-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.cv-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.cv-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
}

.cv-required { color: var(--accent-color); }

.cv-field input,
.cv-field textarea {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
}

.cv-field input:focus,
.cv-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.cv-field textarea {
    resize: vertical;
    min-height: 84px;
    font-family: inherit;
}

.cv-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.cv-privacy {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0;
    padding: 0.7rem 0.9rem;
    background: rgba(99, 102, 241, 0.08);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
}

.cv-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.cv-submit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.cv-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.cv-feedback {
    margin-top: 0.5rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid;
}

.cv-feedback[hidden] { display: none; }

.cv-feedback-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.45);
    color: var(--color-emerald-300);
}

.cv-feedback-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.45);
    color: var(--color-rose-200);
}

@media (max-width: 640px) {
    .cv-dialog { padding: 1.5rem; }
    .cv-row { grid-template-columns: 1fr; }
    .cv-actions { justify-content: stretch; }
    .cv-actions .btn { flex: 1; justify-content: center; }
}

/* ===================================
   SKILLS — chip-based layout
   =================================== */
.skills {
    background: var(--bg-secondary);
}

/* Legend */
.skills-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    margin-bottom: 3rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
}

/* Grid */
.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.skill-category {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(148, 163, 184, 0.08);
}

.skill-category h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.3rem;
    margin-bottom: 1.25rem;
    color: var(--primary-color);
}

/* Chips container */
.skill-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Base chip */
.skill-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: default;
    white-space: nowrap;
}

.skill-chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Levels */
.skill-expert {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.45);
    color: var(--primary-light);
}

.skill-advanced {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--color-emerald-400);
}

.skill-proficient {
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.28);
    color: var(--text-secondary);
}

.skill-exploring {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--color-amber-400);
}

/* ===================================
   CONTACTO
   =================================== */
.contact-content {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 3rem;
    max-width: 1100px;
    margin: 0 auto;
    align-items: stretch;
}

.contact-info {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.contact-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--secondary-color);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.contact-info h3 {
    font-size: 1.8rem;
    margin: 1.5rem 0 1rem;
}

.contact-summary {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.contact-highlights {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.contact-highlight {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.contact-highlight:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.contact-highlight i {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.contact-highlight-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.contact-location {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.contact-location i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: 12px;
    font-size: 1.2rem;
    transition: var(--transition);
    color: var(--text-primary);
}

.social-links a:hover {
    background: var(--primary-color);
    transform: translateY(-3px);
    color: #fff;
}

.contact-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    margin: 0;
    height: 100%;
    align-self: stretch;
}

.contact-card {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 1.4rem 1.6rem 1.25rem;
    border: 1px solid rgba(99, 102, 241, 0.15);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    position: relative;
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
    width: 100%;
}

.contact-card-main {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 1 1 auto;
    min-width: 0;
}

.contact-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(15, 23, 42, 0));
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}

.contact-card:hover::after {
    opacity: 1;
}

.contact-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--primary-color);
}

.contact-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1 1 auto;
}

.contact-card-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.contact-card-value {
    font-size: 1.1rem;
    margin: 0.05rem 0 0;
    font-weight: 600;
    font-family: 'JetBrains Mono', Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

.contact-card-action {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--primary-color);
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: auto;
}

.contact-card-action:hover {
    color: var(--secondary-color);
    transform: translateX(4px);
}

/* Reused across buttons: prevents accidental hover during submit/disabled */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ===================================
   FOOTER
   =================================== */
.footer {
    background: var(--bg-secondary);
    padding: 3rem 0;
    text-align: center;
    border-top: 1px solid var(--bg-tertiary);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.footer-logo i {
    font-size: 1.8rem;
}

.footer p {
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 0.88rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover,
.footer-links a:focus-visible {
    color: var(--primary-light);
}

/* Legal pages (aviso-legal, privacidad) */
.legal-page {
    padding: 6rem 0 4rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.legal-page .container {
    max-width: 800px;
}

.legal-header {
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.2);
}

.legal-back {
    color: var(--primary-light);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    display: inline-block;
}

.legal-back:hover { color: var(--text-primary); }

.legal-page h1 {
    color: var(--text-primary);
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.legal-updated {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0;
}

.legal-section {
    margin-bottom: 2.5rem;
}

.legal-section h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin: 0 0 0.85rem;
    letter-spacing: -0.01em;
}

.legal-section h3 {
    color: var(--text-primary);
    font-size: 1rem;
    margin: 1.25rem 0 0.6rem;
}

.legal-section p, .legal-section ul, .legal-section ol {
    margin: 0 0 1rem;
}

.legal-section ul, .legal-section ol {
    padding-left: 1.5rem;
}

.legal-section li {
    margin-bottom: 0.35rem;
}

.legal-section a {
    color: var(--primary-light);
    text-decoration: underline;
    text-decoration-color: rgba(129, 140, 248, 0.4);
    text-underline-offset: 3px;
}

.legal-section a:hover {
    color: var(--text-primary);
}

.legal-section code {
    background: rgba(99, 102, 241, 0.12);
    color: var(--color-indigo-200);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.9em;
}

.footer-tagline {
    font-style: italic;
}

/* ===================================
   SCROLL TO TOP
   =================================== */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 999;
    box-shadow: var(--shadow-md);
}

.scroll-top.active {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
}

/* ===================================
   TRUSTED COMPANIES (LOGOS)
   =================================== */
.trusted-by {
    margin-top: 3rem;
    animation: fadeInUp 1s ease 1.2s backwards;
}

.trusted-title {
    display: block;
    font-size: 0.85rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 2rem 0 1.5rem;
    text-align: center;
}

/* CONFIGURACIÓN GRID LOGOS (LA SOLUCIÓN) */
.trusted-logos {
    display: grid;
    /* 5 columnas exactas en escritorio = 2 filas para 10 items */
    grid-template-columns: repeat(5, 1fr); 
    gap: 1.5rem;
    justify-items: center;
    align-items: center;
    width: 100%;
    padding: 1rem 0;
}

.trusted-logo {
    width: 100%;
    max-width: 210px;
    aspect-ratio: 3.5 / 1.3;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.85));
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.trusted-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: none;
    opacity: 1;
    /* Transición suave para la animación de escala */
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.trusted-logo:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.trusted-logo:hover img {
    transform: scale(1.06);
}

/* ===================================
   ANIMACIONES Y UTILIDADES
   =================================== */
.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hidden {
    display: none !important;
}

/* Staggered fade-in-up for project cards (triggered via JS) */
.fade-in-up {
    animation: fadeInUp 0.5s ease both;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================================
   ACCESIBILIDAD: REDUCE MOTION
   =================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===================================
   RESPONSIVE (Consolidado)
   =================================== */
@media (max-width: 968px) {
    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        flex-direction: column;
        background: var(--bg-secondary);
        width: 100%;
        padding: 2rem;
        gap: 1.5rem;
        box-shadow: var(--shadow-md);
        transition: var(--transition);
        height: 100dvh; 
        overflow-y: auto;
        padding-bottom: 80px;
    }

    .nav-menu.active {
        left: 0;
    }

    .hamburger {
        display: flex;
    }

    .language-selector {
        margin-left: 0;
        margin-top: 1rem;
        width: 100%;
    }

    .language-btn {
        width: 100%;
        justify-content: center;
    }

    .language-dropdown {
        position: static;
        width: 100%;
        margin-top: 0.5rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }

    .hero-avatar-container {
        width: 120px;
        height: 120px;
        margin-bottom: 1.5rem;
    }

    /* Ajuste de Grids Principales */
    .about-content,
    .contact-content,
    .projects-grid,
    .skills-container {
        grid-template-columns: 1fr;
    }

    .skills-legend {
        gap: 0.4rem;
        padding: 0.75rem 1rem;
    }

    .contact-form-wrapper {
        padding: 1.75rem;
    }

    /* Hero carousel responsive: vertical en tablet/mobile */
    .hero-track { min-height: auto; }

    .hero-slide {
        position: relative;
        grid-template-columns: 1fr;
        grid-template-rows: 240px auto;
    }

    .hero-slide:not(.is-active) {
        display: none;
    }

    .hero-slide-content {
        padding: 1.75rem;
    }

    .hero-nav {
        width: 38px;
        height: 38px;
    }

    .hero-nav-prev { left: 8px; }
    .hero-nav-next { right: 8px; }

    /* Toolbar de filtros: scroll horizontal en mobile */
    .project-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        scrollbar-width: thin;
    }

    .filter-btn {
        flex-shrink: 0;
    }

    .projects-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        flex: 0 0 auto;
        width: 100%;
    }

    .projects-sort {
        justify-content: space-between;
        width: 100%;
    }

    .sort-select { flex: 1; }

    /* Modal: full-screen en mobile */
    .modal-dialog {
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 16px;
    }

    .modal-body { padding: 1.25rem; }

    .modal-stack-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .modal-stack-label { padding-top: 0; }

    .active-filters {
        padding: 0.6rem 0.75rem;
    }

    .active-clear-all {
        margin-left: 0;
        flex-basis: 100%;
        justify-content: center;
        margin-top: 0.4rem;
    }

    .about-content {
        text-align: center;
    }

    .about-highlights,
    .highlight-item {
        align-items: center;
    }

    .highlight-item {
        flex-direction: column;
        text-align: center;
    }

    .contact-info {
        padding: 2rem;
    }

    .contact-grid {
        grid-template-columns: 1fr;
        width: 100%;
    }
    
    .contact-card {
        width: 100%;
        box-sizing: border-box;
    }

    .contact-card-main {
        width: 100%;
    }

    .contact-card-action {
        width: 100%;
        justify-content: center;
    }

    .section-title {
        font-size: 2rem;
    }

    /* Logos: 3 columnas en tablet */
    .trusted-logos {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }

    .hero-title {
        font-size: 1.8rem;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .stat-number {
        font-size: 2rem;
    }

    .hero-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-auto-flow: row;
        gap: 1rem;
        overflow-x: visible;
    }

    .project-filters {
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .filter-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .contact-card {
        padding: 1.25rem;
    }

    /* Logos: 2 columnas en móvil */
    .trusted-logos {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .trusted-logo {
        max-width: 100%;
        padding: 0.75rem;
    }
}