@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,600&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* =========================================================
   Tokens
   ========================================================= */
:root {
    --rojo: #8B0000;
    --rojo-claro: #a51212;
    --rojo-texto: #c96a6a;

    --azul: #0047AB;
    --azul-claro: #1a5fc9;
    --azul-texto: #7ea9e8;

    --fondo-oscuro: #1a1a1a;
    --fondo: #2C2C2C;
    --superficie: #232323;

    --texto: #ececec;
    --texto-suave: #b3b3b3;
    --texto-tenue: #8c8c8c;

    --borde: #3a3a3a;
    --borde-fuerte: #4d4d4d;

    --sombra: 0 12px 32px rgba(0, 0, 0, 0.28);
    --radio: 6px;

    --ancho: 940px;
    --ancho-lectura: 68ch;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--fondo);
    color: var(--texto);
    font-family: "Montserrat", sans-serif;
    font-size: 16px;
    line-height: 1.7;
    text-align: left;

    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

img,
video {
    max-width: 100%;
    height: auto;
}

section {
    scroll-margin-top: 84px;
}

p {
    max-width: var(--ancho-lectura);
    margin-bottom: 1rem;
    color: var(--texto-suave);
}

p:last-child {
    margin-bottom: 0;
}

strong {
    color: var(--texto);
    font-weight: 600;
}

::selection {
    background-color: var(--azul);
    color: #fff;
}

/* =========================================================
   Tipografía
   ========================================================= */
h1,
h2,
h3,
h4 {
    margin: 0 0 0.6rem;
}

h1 {
    font-family: "Playfair Display", serif;
    font-style: italic;
    font-weight: 700;
    color: var(--texto);
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    line-height: 1.12;
    letter-spacing: -0.015em;
}

h2 {
    font-family: "Montserrat", sans-serif;
    color: var(--texto);
    font-weight: 600;
    font-size: 1.2rem;
    line-height: 1.35;
}

h3 {
    font-family: "Montserrat", sans-serif;
    color: var(--texto);
    font-weight: 600;
    font-size: 1.02rem;
    line-height: 1.45;
}

/* Título de sección: serif + regla corta (no degradado) */
section > h1,
section > h2 {
    display: inline-block;
    position: relative;
    font-family: "Playfair Display", serif;
    font-style: italic;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.015em;
    font-size: clamp(1.8rem, 3.6vw, 2.5rem);
    margin-bottom: 1.5rem;
    padding-bottom: 0.7rem;
}

section > h1::after,
section > h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 44px;
    height: 3px;
    background-color: var(--rojo);
}

a {
    color: var(--azul-texto);
    text-decoration: none;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--rojo-texto);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--azul-texto);
    outline-offset: 3px;
}

hr {
    width: calc(100% - 3rem);
    max-width: var(--ancho);
    height: 0;
    margin: 0 auto;
    border: 0;
    border-top: 1px solid var(--borde);
}

/* =========================================================
   Cabecera y navegación
   ========================================================= */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 5rem;
    background-color: rgba(22, 22, 22, 0.96);
    border-bottom: 1px solid var(--borde);
    backdrop-filter: blur(8px);
}

nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.1rem 0.8rem;
    max-width: 1080px;
}

nav a {
    display: inline-block;
    padding: 0.35rem 0;
    color: var(--texto-suave);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

nav a:hover {
    color: var(--texto);
    border-bottom-color: var(--rojo);
}

nav a.active {
    color: var(--texto);
    border-bottom-color: var(--rojo);
}

/* ===== selector de idioma ===== */
.lang-switch {
    position: absolute;
    top: 50%;
    right: 1.25rem;
    transform: translateY(-50%);
    display: flex;
    gap: 0.3rem;
    z-index: 2;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--borde);
    border-radius: 4px;
    background-color: transparent;
    color: var(--texto-tenue);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.lang-btn:hover {
    color: var(--texto);
    border-color: var(--rojo);
}

.lang-btn.active {
    background-color: var(--azul);
    border-color: var(--azul);
    color: #fff;
}

/* =========================================================
   Secciones
   ========================================================= */
section {
    width: 100%;
    max-width: var(--ancho);
    margin: 0 auto;
    padding: 3.25rem 1.5rem;
}

/* =========================================================
   Hero
   ========================================================= */
.hero {
    max-width: 1040px;
    padding: 3.5rem 1.5rem 2.5rem;
    text-align: center;
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    line-height: 1.08;
    margin-bottom: 1rem;
}

.hero-kicker {
    color: var(--rojo-texto);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    margin-bottom: 0.9rem;
}

.hero-copy {
    max-width: 60ch;
    margin: 0 auto 1.5rem;
    font-size: 1.08rem;
}

/* Panel del hero: cuadrícula muy sutil, sin brillos */
.fondo-cuadriculado {
    position: relative;
    padding: clamp(2rem, 5vw, 3.25rem);
    background-color: var(--superficie);
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: 28px 28px;
    border: 1px solid var(--borde);
    border-top: 3px solid var(--rojo);
    border-radius: var(--radio);
    overflow: hidden;
    text-align: center;
}

.fondo-cuadriculado p {
    margin-left: auto;
    margin-right: auto;
}

.fondo-cuadriculado br,
.hero br {
    display: none;
}

/* =========================================================
   Botones
   ========================================================= */
.boton,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.68rem 1.35rem;
    border: 1px solid var(--rojo);
    border-radius: 4px;
    background-color: var(--rojo);
    color: #fff;
    font-family: "Montserrat", sans-serif;
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.015em;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.boton:hover,
button:hover {
    background-color: var(--rojo-claro);
    border-color: var(--rojo-claro);
    color: #fff;
}

.boton:focus-visible,
button:focus-visible {
    outline: 2px solid var(--azul-texto);
    outline-offset: 3px;
}

.boton.azul {
    background-color: var(--azul);
    border-color: var(--azul);
}

.boton.azul:hover {
    background-color: var(--azul-claro);
    border-color: var(--azul-claro);
}

.boton.contorno {
    background-color: transparent;
    border-color: var(--borde-fuerte);
    color: var(--texto);
}

.boton.contorno:hover {
    background-color: transparent;
    border-color: var(--azul-texto);
    color: var(--texto);
}

.cta-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 1.5rem;
}

.cta-buttons--start {
    justify-content: flex-start;
}

.cta-buttons--spaced {
    margin-top: 2rem;
}

.boton-rotado {
    display: inline-block;
    transform: rotate(90deg);
}

/* =========================================================
   Efecto terminal (máquina de escribir)
   ========================================================= */
.typing {
    max-width: 760px;
    margin: 1.25rem 0 0;
    padding: 1rem 1.25rem;
    background-color: #1f1f1f;
    border: 1px solid var(--borde);
    border-left: 3px solid var(--azul);
    border-radius: 4px;
    text-align: left;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--texto-suave);
    min-height: 3.2rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.typing::before {
    content: "> ";
    color: var(--rojo-texto);
    font-weight: 700;
}

.typing::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background-color: var(--azul-texto);
    animation: parpadeo 0.9s step-end infinite;
}

.typing.done::after {
    display: none;
}

@keyframes parpadeo {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.typing-titulo {
    display: inline-block;
    width: 0;
    max-width: 100%;
    overflow: hidden;
    margin: 0 auto 1.75rem;
    color: var(--texto-suave);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.95rem;
    line-height: 1.7;
    white-space: nowrap;
    animation: escribir 2.8s steps(42, end) forwards;
}

.typing-titulo::after {
    content: "|";
    display: inline-block;
    margin-left: 2px;
    color: var(--azul-texto);
    animation: cursor 0.8s step-end infinite;
}

@keyframes escribir {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes cursor {
    50% { opacity: 0; }
}

/* =========================================================
   Habilidades
   ========================================================= */
.habilidades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1.75rem;
}

.habilidad {
    padding: 1.35rem 1.4rem;
    background-color: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    text-align: left;
    transition: border-color 0.15s ease;
}

.habilidad:hover {
    border-color: var(--borde-fuerte);
}

.habilidad h2,
.habilidad h3 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.habilidad p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.65;
}

/* =========================================================
   Listas (proyectos y estudios)
   ========================================================= */
ul {
    list-style: none;
    max-width: 100%;
    margin: 1.5rem 0;
    padding: 0;
    text-align: left;
}

li {
    position: relative;
    margin: 0;
    padding: 0.7rem 0 0.7rem 1.4rem;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--borde);
    border-radius: 0;
    box-shadow: none;
    color: var(--texto-suave);
}

li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1.25rem;
    width: 5px;
    height: 5px;
    background-color: var(--rojo-texto);
}

li:last-child {
    border-bottom: 0;
}

/* =========================================================
   Línea del tiempo
   ========================================================= */
.timeline-card {
    position: relative;
    max-width: 760px;
    margin: 2rem auto 0;
    text-align: left;
}

.timeline-card::before {
    content: "";
    position: absolute;
    top: 0.4rem;
    bottom: 1rem;
    left: 5px;
    width: 2px;
    background-color: var(--borde-fuerte);
}

.timeline-item {
    position: relative;
    margin: 0 0 1.6rem 2.25rem;
    padding: 0 0 1.5rem;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--borde);
    border-radius: 0;
    box-shadow: none;
}

.timeline-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.timeline-item::before {
    content: "";
    position: absolute;
    top: 0.55rem;
    left: -2.2rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--rojo);
    border: 0;
    box-shadow: 0 0 0 4px var(--fondo);
}

.timeline-item h3 {
    margin-bottom: 0.35rem;
    color: var(--rojo-texto);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.76rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: none;
    border: 0;
    padding: 0;
}

.timeline-item p {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.75;
}

.timeline-item a {
    color: var(--azul-texto);
    text-decoration: underline;
}

/* =========================================================
   Contacto
   ========================================================= */
.contact-card {
    max-width: 620px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    background-color: var(--superficie);
    border: 1px solid var(--borde);
    border-top: 3px solid var(--rojo);
    border-radius: var(--radio);
    text-align: center;
}

.contact-card h1,
.contact-card h2 {
    font-family: "Playfair Display", serif;
    font-style: italic;
    font-weight: 700;
    font-size: clamp(1.7rem, 4vw, 2.3rem);
}

.contact-card p {
    margin-left: auto;
    margin-right: auto;
}

.contact-actions {
    margin-top: 1.5rem;
}

/* =========================================================
   Pie de página
   ========================================================= */
.footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    width: 100%;
    margin-top: auto;
    padding: 2rem 1.5rem;
    background-color: var(--fondo-oscuro);
    border-top: 1px solid var(--borde);
    text-align: center;
}

.footer br {
    display: none;
}

.footer p {
    flex-basis: 100%;
    margin: 0;
    font-size: 0.85rem;
}

.footer-boton {
    display: inline-block;
    padding: 0.2rem 0;
    color: var(--texto-suave);
    font-size: 0.84rem;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.footer-boton:hover {
    color: var(--texto);
    border-bottom-color: var(--rojo);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.25rem;
}

.footer .boton {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.footer-top {
    margin-left: 0.25rem;
}

/* =========================================================
   Dropdown de navegación
   ========================================================= */
.dropdown-nav {
    display: inline-block;
    position: relative;
    padding: 0.35rem 0;
    color: var(--texto-suave);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
}

.dropdown-nav summary {
    list-style: none;
    display: inline-block;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    cursor: pointer;
}

.dropdown-nav summary::-webkit-details-marker {
    display: none;
}

.dropdown-nav summary::after {
    content: " ▾";
    font-size: 0.7em;
    color: var(--texto-tenue);
}

.dropdown-nav:hover {
    color: var(--texto);
}

.dropdown-nav .submenu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    min-width: 180px;
    padding: 0.35rem 0;
    margin: 0;
    list-style: none;
    text-align: left;
    background-color: var(--fondo-oscuro);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    z-index: 20;
}

.dropdown-nav[open] .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown-nav .submenu li {
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
}

.dropdown-nav .submenu li::before {
    display: none;
}

.dropdown-nav .submenu li a {
    display: block;
    padding: 0.5rem 1.1rem;
    color: var(--texto-suave);
    font-size: 0.82rem;
    border: 0;
}

.dropdown-nav .submenu li a:hover {
    background-color: rgba(0, 71, 171, 0.24);
    color: #fff;
}

/* =========================================================
   Animación al hacer scroll
   ========================================================= */
.reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
    opacity: 1;
    transform: none;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1100px) {
    header {
        flex-direction: column;
        padding: 0.75rem 1rem;
    }

    .lang-switch {
        position: static;
        transform: none;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 700px) {
    header {
        position: static;
    }

    section {
        padding: 2.5rem 1.1rem;
    }

    .hero {
        padding: 2.5rem 1.1rem 2rem;
    }

    .fondo-cuadriculado {
        padding: 1.75rem 1.15rem;
    }

    .typing-titulo {
        width: auto;
        white-space: normal;
        animation: none;
        overflow: visible;
        font-size: 0.88rem;
    }

    .typing-titulo::after {
        display: none;
    }

    section > h1,
    section > h2 {
        margin-bottom: 1.2rem;
    }

    nav {
        gap: 0.1rem 0.85rem;
    }

    nav a {
        font-size: 0.78rem;
    }

    .timeline-card::before {
        left: 4px;
    }

    .timeline-item {
        margin-left: 1.75rem;
    }

    .timeline-item::before {
        left: -1.7rem;
    }

    .contact-card {
        padding: 2rem 1.15rem;
    }

    .footer {
        padding: 1.6rem 1rem;
    }
}

@media (max-width: 420px) {
    .cta-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .cta-buttons .boton {
        width: 100%;
    }
}

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

    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .typing-titulo {
        width: auto;
        animation: none;
        overflow: visible;
    }

    .typing-titulo::after,
    .typing::after {
        animation: none;
    }
}
