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

:root {
    --bg-light: #f5f8fe;
    --surface: #ffffff;
    --card-white: #ffffff;
    --border-soft: #e9edf2;
    --text-primary: #1a2634;
    --text-secondary: #546574;
    --text-muted: #7a8799;
    --accent-1: #1f8a7c;
    /* teal profesional */
    --accent-2: #5b6cae;
    /* slate azulado */
    --accent-3: #cf6f5e;
    /* terracota */
    --accent-4: #daa34a;
    /* ámbar sobrio */
    --accent-5: #9b59b6;
    /* púrpura multimedia */
    --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.02), 0 2px 6px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 20px 35px -12px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 24px 42px -16px rgba(0, 0, 0, 0.12);
    --transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
}

body {
    background: var(--bg-light);
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    line-height: 1.5;
    scroll-behavior: smooth;
}

/* suave patrón de fondo */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle at 20% 40%, rgba(31, 138, 124, 0.02) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    z-index: 0;
}

/* elementos decorativos sutiles */
.soft-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
}

.blob-left {
    width: 500px;
    height: 500px;
    background: #bee0da;
    top: -180px;
    left: -180px;
}

.blob-right {
    width: 520px;
    height: 520px;
    background: #dfe6f5;
    bottom: -200px;
    right: -150px;
}

/* header profesional */
header {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 70px 24px 60px;
    max-width: 880px;
    margin: 0 auto;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(31, 138, 124, 0.08);
    backdrop-filter: blur(2px);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 6px 14px;
    border-radius: 40px;
    color: var(--accent-1);
    border: 0.5px solid rgba(31, 138, 124, 0.25);
    margin-bottom: 28px;
    font-family: 'Inter', monospace;
}

.badge i {
    font-size: 14px;
}

h1 {
    font-family: 'Syne', sans-serif;
    font-size: clamp(2.6rem, 6vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: #17212b;
}

.gradient-text {
    background: linear-gradient(135deg, #1f8a7c 0%, #5b6cae 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    margin-top: 18px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

/* GRID: adaptable para 5 proyectos */
.grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 3 columnas en desktop para acomodar 5 proyectos */
    gap: 28px;
    max-width: 1280px;
    margin: 20px auto 80px;
    padding: 0 28px;
}

/* Último elemento centrado cuando hay 5 proyectos */
.grid .card:last-child:nth-child(3n-2) {
    grid-column: 2 / 3;
}

/* En pantallas grandes mostramos 4 columnas si caben bien */
@media (min-width: 1200px) {
    .grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .grid .card:last-child:nth-child(3n-2) {
        grid-column: auto;
    }
}

/* En pantallas medianas (tablet) -> 2 columnas */
@media (max-width: 800px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    .grid .card:last-child:nth-child(3n-2) {
        grid-column: auto;
    }
}

/* En móviles -> 1 columna */
@media (max-width: 540px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 24px;
        padding: 0 20px;
    }
    .grid .card:last-child:nth-child(3n-2) {
        grid-column: auto;
    }
}

/* cards */
.card {
    background: var(--card-white);
    border-radius: 24px;
    border: 1px solid var(--border-soft);
    overflow: hidden;
    text-decoration: none;
    display: block;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    animation: fadeUp 0.4s ease backwards;
    animation-delay: calc(var(--d, 0) * 0.08s);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
    border-color: var(--c);
}

/* imagen / placeholder */
.card-img {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #f8fafd 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.card-img svg {
    width: 52px;
    height: 52px;
    stroke: var(--c);
    stroke-width: 1.2;
    fill: none;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
}

.card:hover .card-img svg {
    opacity: 0.8;
    transform: scale(1.02);
}

.card-num {
    position: absolute;
    top: 16px;
    right: 18px;
    font-family: 'Inter', monospace;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    padding: 4px 12px;
    border-radius: 40px;
    color: var(--c);
    border: 0.5px solid var(--c);
    letter-spacing: 0.3px;
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.card-body {
    padding: 24px 24px 28px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-tag {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--c);
    display: inline-block;
    margin-bottom: 12px;
    background: rgba(0, 0, 0, 0.02);
    padding: 0 2px;
}

.card-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.32rem;
    font-weight: 700;
    color: #1f2c38;
    line-height: 1.3;
    margin-bottom: 12px;
    transition: color 0.2s;
}

.card:hover .card-title {
    color: var(--c);
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    font-weight: 400;
    flex: 1;
}

.card-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 22px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: var(--c);
    transition: var(--transition);
    opacity: 0.7;
    transform: translateX(0);
}

.card:hover .card-cta {
    opacity: 1;
    transform: translateX(4px);
}

.cta-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 30px;
    border: 1px solid var(--c);
    font-size: 12px;
    transition: 0.2s;
}

.card:hover .cta-arrow {
    background: var(--c);
    color: white;
}

/* Modal refinado */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(29, 38, 48, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--surface);
    border-radius: 32px;
    max-width: 640px;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 30px 50px -20px rgba(0, 0, 0, 0.3);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-overlay.open .modal {
    transform: translateY(0) scale(1);
}

.modal-banner {
    width: 100%;
    aspect-ratio: 16 / 6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    background: #f5fafc;
    border-bottom: 1px solid var(--border-soft);
}

.modal-banner i {
    transition: transform 0.3s ease;
}

.modal-overlay.open .modal-banner i {
    animation: iconPop 0.5s cubic-bezier(0.2, 0.9, 0.4, 1.1) 0.2s both;
}

.modal-content {
    padding: 32px 34px 36px;
}

.modal-tag {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 12px;
    display: inline-block;
}

.modal-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
    color: #1f2937;
}

.modal-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    font-weight: 400;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
}

.modal-close {
    background: transparent;
    border: 1px solid #d4dce4;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 24px;
    border-radius: 60px;
    color: #4a5b6e;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
}

.modal-close:hover {
    border-color: #8f9eb0;
    background: #f9fcff;
    color: #1f2c38;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    border-radius: 60px;
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    letter-spacing: 0.3px;
}

.modal-btn:hover {
    filter: brightness(0.95);
    transform: scale(1.02);
}

footer {
    text-align: center;
    padding: 32px 20px 48px;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: transparent;
    position: relative;
    z-index: 2;
}

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

@keyframes iconPop {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 0.9;
    }
}

@media (max-width: 680px) {
    .modal-content {
        padding: 28px 24px 32px;
    }

    .modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-close,
    .modal-btn {
        justify-content: center;
        text-align: center;
    }

    header {
        padding: 48px 20px 40px;
    }
}

/* ajuste de links, botón accesible */
.card:focus-visible {
    outline: 2px solid var(--c);
    outline-offset: 2px;
}