:root {
    color-scheme: light;
    --bg: #f7f8fb;
    --surface: #ffffff;
    --ink: #1e1b3a;
    --muted: #4a4766;
    --line: #e1e4ee;
    --accent: #4f46a5;
    --accent-hover: #403890;
    --accent-soft: #e3e1f7;
    --code-bg: #1e1b3a;
    --code-ink: #cfcbf2;
    --code-key: #9d97d8;
    --code-ok: #7fd6a8;
    --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
    --font-display: "Bricolage Grotesque", "IBM Plex Sans", "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", Consolas, monospace;
    --container: 1120px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 84px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

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

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

h1, h2, h3, p {
    margin-top: 0;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.container {
    width: min(var(--container), calc(100% - 48px));
    margin-inline: auto;
}

.skip-link {
    position: fixed;
    z-index: 30;
    top: 12px;
    left: 12px;
    padding: 10px 16px;
    transform: translateY(-160%);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Cabecera */
.site-header {
    position: sticky;
    z-index: 10;
    top: 0;
    border-bottom: 1px solid var(--line);
    background: rgb(247 248 251 / 92%);
    backdrop-filter: blur(12px);
}

.header-inner {
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 28px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 500;
}

.site-nav a:not(.nav-contact):hover {
    color: var(--accent);
}

.nav-contact {
    padding: 8px 16px;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
}

.nav-contact:hover {
    background: var(--accent-hover);
}

.menu-toggle {
    display: none;
}

/* Botones y enlaces */
.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    transition: background .2s ease, color .2s ease;
}

.button-primary {
    background: var(--accent);
    color: #fff;
}

.button-primary:hover {
    background: var(--accent-hover);
}

.button-ghost {
    background: transparent;
    color: var(--accent);
}

.button-ghost:hover {
    background: var(--accent-soft);
}

.text-link {
    border-bottom: 1px solid var(--accent);
    color: var(--accent);
    font-weight: 600;
}

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

/* Hero */
.hero {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    align-items: center;
    gap: 56px;
    padding-block: 72px 80px;
}

.hero h1 {
    max-width: 14ch;
    margin-bottom: 20px;
    font-family: var(--font-display);
    font-size: clamp(36px, 5vw, 58px);
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.06;
}

.hero-lead {
    max-width: 52ch;
    margin-bottom: 28px;
    color: var(--muted);
    font-size: 18px;
}

.hero-lead strong {
    color: var(--ink);
    font-weight: 600;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Respuesta HTTP */
.response {
    overflow: hidden;
    border-radius: 10px;
    background: var(--code-bg);
    color: var(--code-ink);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.8;
}

.response-head {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
    border-bottom: 1px solid rgb(207 203 242 / 18%);
}

.response-head img {
    width: 84px;
    height: 84px;
    flex: none;
    border-radius: 8px;
    object-fit: cover;
}

.response-status {
    display: block;
    color: var(--code-ok);
}

.response-route {
    display: block;
    color: var(--code-key);
}

.response-body {
    margin: 0;
    padding: 16px 22px 20px;
    white-space: pre-wrap;
    font: inherit;
}

.response .k {
    color: var(--code-key);
}

.code-line {
    display: block;
    opacity: 0;
    animation: line-in .3s ease forwards;
    animation-delay: calc(var(--i) * 110ms + 250ms);
}

@keyframes line-in {
    to {
        opacity: 1;
    }
}

/* Secciones */
.section {
    padding-block: clamp(56px, 8vw, 96px);
}

.section-title {
    margin-bottom: 32px;
    font-family: var(--font-display);
    font-size: clamp(28px, 3.6vw, 40px);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.15;
}

.about-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 64px;
    align-items: start;
}

.about-copy p {
    max-width: 62ch;
    margin-bottom: 16px;
    color: var(--muted);
}

.about-copy .large-copy {
    color: var(--ink);
    font-size: 20px;
    line-height: 1.6;
}

.about-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-top: 24px;
}

.facts {
    margin: 0;
    border-top: 1px solid var(--line);
}

.fact {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-block: 16px;
    border-bottom: 1px solid var(--line);
}

.fact dt {
    color: var(--muted);
    font-size: 15px;
}

.fact dd {
    margin: 0;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
}

/* Tecnologías */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px 32px;
}

.skill {
    padding-top: 16px;
    border-top: 2px solid var(--ink);
}

.skill h3 {
    margin-bottom: 6px;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
}

.skill p {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 16px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-list li {
    padding: 3px 10px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-size: 14px;
    font-weight: 500;
}

/* Proyectos */
.projects-band {
    border-block: 1px solid var(--line);
    background: var(--surface);
}

.section-heading-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 32px;
    margin-bottom: 12px;
}

.section-heading-row .section-title {
    margin-bottom: 0;
}

.portfolio-intro {
    max-width: 56ch;
    margin-bottom: 36px;
    color: var(--muted);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.project-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
}

.project-art {
    display: grid;
    height: 92px;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -.04em;
}

.project-details {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 18px 20px 20px;
}

.project-details h3 {
    margin-bottom: 8px;
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
}

.project-details > p {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 16px;
}

.project-details .tag-list {
    margin-bottom: 18px;
}

.project-links {
    display: flex;
    gap: 20px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 15px;
    font-weight: 600;
}

.project-links a {
    color: var(--accent);
}

.project-links a:hover {
    text-decoration: underline;
}

/* Formación */
.education-grid {
    display: grid;
    grid-template-columns: .9fr 1.1fr;
    gap: 64px;
}

.education-note {
    max-width: 38ch;
    color: var(--muted);
}

.education-list {
    border-top: 1px solid var(--line);
}

.education-item {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 18px;
    padding-block: 20px;
    border-bottom: 1px solid var(--line);
}

.education-period {
    color: var(--muted);
    font-size: 15px;
}

.education-item h3 {
    margin-bottom: 2px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}

.education-item p {
    margin: 0;
    color: var(--muted);
    font-size: 16px;
}

.languages li span {
    color: var(--muted);
}

/* Contacto */
.contact-section {
    padding-block: clamp(56px, 8vw, 88px) 32px;
    background: var(--ink);
    color: #fff;
}

.contact-content {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px 48px;
    padding-bottom: 56px;
}

.contact-content h2 {
    max-width: 16ch;
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(34px, 5vw, 56px);
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.08;
}

.contact-aside {
    max-width: 36ch;
}

.contact-aside p {
    margin-bottom: 20px;
    color: #cfcbf2;
}

.button-light {
    border-color: #fff;
    background: #fff;
    color: var(--ink);
}

.button-light:hover {
    background: var(--accent-soft);
}

.social-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 28px;
    padding-top: 22px;
    border-top: 1px solid rgb(255 255 255 / 20%);
    color: #cfcbf2;
    font-size: 15px;
}

.social-links a:hover {
    color: #fff;
    text-decoration: underline;
}

.contact-section a:focus-visible {
    outline-color: #cfcbf2;
}

/* Pie */
.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 15px;
}

.footer-inner {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.footer-inner p {
    margin: 0;
}

.back-to-top:hover {
    color: var(--accent);
}

/* Tablet */
@media (max-width: 900px) {
    .hero,
    .about-grid,
    .education-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero {
        padding-block: 48px 56px;
    }

    .skills-grid,
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Móvil */
@media (max-width: 640px) {
    html {
        scroll-padding-top: 72px;
    }

    .container {
        width: min(var(--container), calc(100% - 40px));
    }

    .header-inner {
        min-height: 64px;
    }

    .menu-toggle {
        display: flex;
        width: 42px;
        height: 42px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        border: 1px solid var(--line);
        border-radius: 4px;
        background: var(--surface);
        cursor: pointer;
    }

    .menu-toggle span {
        width: 18px;
        height: 2px;
        background: var(--ink);
        transition: transform .2s ease;
    }

    .menu-toggle[aria-expanded="true"] span:first-child {
        transform: translateY(4px) rotate(45deg);
    }

    .menu-toggle[aria-expanded="true"] span:last-child {
        transform: translateY(-4px) rotate(-45deg);
    }

    .site-nav {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        display: none;
        align-items: stretch;
        gap: 0;
        padding: 8px 20px 18px;
        border-bottom: 1px solid var(--line);
        background: var(--bg);
    }

    .site-nav.is-open {
        display: flex;
        flex-direction: column;
    }

    .site-nav a:not(.nav-contact) {
        padding: 12px 0;
        border-bottom: 1px solid var(--line);
    }

    .nav-contact {
        margin-top: 14px;
        text-align: center;
    }

    .hero-lead {
        font-size: 17px;
    }

    .response {
        font-size: 13px;
    }

    .response-head img {
        width: 68px;
        height: 68px;
    }

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

    .education-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .footer-inner {
        flex-wrap: wrap;
        padding-block: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .code-line {
        opacity: 1;
        animation: none;
    }

    * {
        transition-duration: .01ms !important;
    }
}
