:root {
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #0f172a;
    --color-text-secondary: #64748b;
    --color-accent: #2563eb;
    --color-accent-light: #eff6ff;
    --color-accent-dark: #1e40af;
    --color-border: #e2e8f0;
    --font-display: 'Cal Sans', 'Inter', sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.025;
    z-index: 1000;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
    text-decoration: none;
    transition: var(--transition);
}

.nav-logo:hover {
    color: var(--color-accent);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--color-accent);
}

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8rem 2rem 6rem;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #bae6fd 100%);
}

.hero-container {
    max-width: 900px;
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero-badge {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background: var(--color-accent-light);
    color: var(--color-accent);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 50px;
    margin-bottom: 2rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.hero-title-highlight {
    display: block;
    background: linear-gradient(135deg, var(--color-accent) 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1.25rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
    margin-bottom: 2.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--color-accent);
    color: white;
    text-decoration: none;
    font-weight: 600;
    border-radius: 12px;
    transition: var(--transition);
    font-size: 1rem;
    box-shadow: var(--shadow-lg);
}

.hero-cta:hover {
    background: var(--color-accent-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.hero-cta svg {
    transition: var(--transition);
}

.hero-cta:hover svg {
    transform: translateX(4px);
}

.hero-decoration {
    position: absolute;
    top: 20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-30px, 30px) scale(1.05); }
}

.projects {
    padding: 6rem 2rem;
    background: var(--color-surface);
}

.projects-container {
    max-width: 1400px;
    margin: 0 auto;
}

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

.section-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 2rem;
}

.project-card {
    background: var(--color-surface);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: var(--transition);
    opacity: 0;
    transform: translateY(20px);
}

.project-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-accent);
}

.project-visual {
    position: relative;
    width: 100%;
    height: 240px;
    overflow: hidden;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.project-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transition: var(--transition);
}

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

.project-logo {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 56px;
    height: 56px;
    background: var(--color-surface);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
}

.project-content {
    padding: 1.5rem;
}

.project-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.project-tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-accent);
}

.project-year {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.project-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.project-tagline {
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.project-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--color-accent);
    color: white;
    border: none;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
}

.project-cta:hover {
    background: var(--color-accent-dark);
    transform: translateX(2px);
}

.project-cta svg {
    transition: var(--transition);
}

.project-cta:hover svg {
    transform: translateX(2px);
}

.clients {
    padding: 6rem 2rem;
    background: var(--color-bg);
}

.clients-container {
    max-width: 1400px;
    margin: 0 auto;
}

.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.client-card {
    background: var(--color-surface);
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid var(--color-border);
    transition: var(--transition);
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
}

.client-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.client-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.client-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-accent-light);
    border-radius: 12px;
}

.client-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.client-logo-placeholder {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-accent);
}

.client-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.75rem;
}

.client-systems {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.system-badge {
    display: inline-block;
    background: var(--color-accent);
    color: white;
    padding: 0.375rem 0.875rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.system-badge:hover {
    background: var(--color-accent-dark);
}

.client-description {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.footer {
    padding: 4rem 2rem;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-logo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
}

.footer-tagline {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.footer-info {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.project-page {
    min-height: 100vh;
    padding-top: 5rem;
    background: var(--color-surface);
}

.project-page-header {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 1rem;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
}

.back-button:hover {
    background: var(--color-bg);
    border-color: var(--color-accent);
    transform: translateX(-2px);
}

.project-page-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.project-page-intro {
    text-align: center;
    margin-bottom: 4rem;
}

.project-page-logo {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 4rem;
}

.project-page-logo img {
    height: 5.5rem;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.project-page-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.project-page-subtitle {
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.project-page-meta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.project-page-description {
    margin-bottom: 4rem;
}

.project-page-description h2,
.project-page-tech h2,
.project-page-gallery h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.project-page-description p {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--color-text-secondary);
    max-width: 800px;
}

.project-page-tech {
    margin-bottom: 4rem;
}

.tech-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.tech-tag {
    padding: 0.75rem 1.5rem;
    background: var(--color-accent-light);
    color: var(--color-accent);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.project-page-gallery {
    margin-bottom: 4rem;
}

.gallery-container {
    background: var(--color-bg);
    border-radius: 16px;
    padding: 2rem;
}

.gallery-main {
    position: relative;
    width: 100%;
    height: 600px;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    margin-bottom: 1.5rem;
}

.gallery-slides {
    position: relative;
    width: 100%;
    height: 100%;
}

.gallery-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-slide.active {
    opacity: 1;
}

.gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.gallery-nav:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.gallery-prev {
    left: 1.5rem;
}

.gallery-next {
    right: 1.5rem;
}

.gallery-thumbs {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.gallery-thumb {
    flex-shrink: 0;
    width: 140px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    background: #f8fafc;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-thumb:hover {
    border-color: var(--color-accent);
}

.gallery-thumb.active {
    border-color: var(--color-accent);
}

@media (max-width: 768px) {
    .nav-container {
        padding: 1rem 1.5rem;
    }

    .hero {
        padding: 6rem 1.5rem 4rem;
    }

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

    .projects {
        padding: 4rem 1.5rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .clients {
        padding: 4rem 1.5rem;
    }

    .clients-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .footer-container {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }

    .project-page-header {
        padding: 1.5rem;
    }

    .project-page-content {
        padding: 1.5rem;
    }

    .project-page-title {
        font-size: 2.5rem;
    }

    .project-page-subtitle {
        font-size: 1.25rem;
    }

    .gallery-main {
        height: 400px;
    }

    .gallery-nav {
        width: 40px;
        height: 40px;
    }

    .gallery-prev {
        left: 1rem;
    }

    .gallery-next {
        right: 1rem;
    }

    .gallery-thumb {
        width: 100px;
        height: 65px;
    }
}

/* ── Proyectos relacionados ── */
.project-page-related {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--color-border, rgba(255,255,255,0.08));
}

.project-page-related h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.related-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.related-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--color-surface, rgba(255,255,255,0.04));
    border: 1px solid var(--color-border, rgba(255,255,255,0.08));
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    text-align: left;
    width: 100%;
    color: inherit;
}

.related-card:hover {
    background: var(--color-surface-hover, rgba(255,255,255,0.08));
    border-color: var(--color-accent, #6366f1);
    transform: translateX(4px);
}

.related-card-logo {
    font-size: 1.75rem;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.related-card-logo img {
    height: 2rem;
    width: auto;
    max-width: 2.5rem;
    object-fit: contain;
}

.related-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.related-card-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
}

.related-card-tagline {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.related-card-arrow {
    flex-shrink: 0;
    color: var(--color-text-secondary);
    transition: color 0.2s;
}

.related-card:hover .related-card-arrow {
    color: var(--color-accent, #6366f1);
}

/* ── Link inline a otro proyecto dentro de la descripción ── */
.inline-project-link {
    display: inline;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: inherit;
    color: var(--color-accent, #6366f1);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.15s;
}

.inline-project-link:hover {
    opacity: 0.75;
}
