/* No usamos @property para hue/sat/light, porque al interpolar un ángulo hue 
   (por ejemplo: de 150 a 350) se genera un "efecto arcoíris" pasando por amarillos, naranjas, etc.
   En su lugar, hacemos que interpolen mediante CSS transitions estándar. */
:root {
    /* Color de acento por defecto: azul (se sobreescribe con localStorage o el picker) */
    --primary-hue: 214;
    --primary-sat: 84%;
    --primary-light: 56%;
    --primary-color: hsl(var(--primary-hue), var(--primary-sat), var(--primary-light));
    --text-color: hsl(0, 0%, 90%);
    /* Light text for dark mode default */
    --text-muted: hsl(0, 0%, 70%);
    --bg-color: hsl(240, 10%, 10%);
    /* Deep dark background */
    --bg-card-color: rgba(255, 255, 255, 0.05);
    /* Glass effect */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-radius: 1rem;
    --transition: all 0.3s ease;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(12px);
}

/* Light Mode Variables (if needed, though design is dark-first) */
/* Light Mode Variables */
body:not(.dark) {
    --text-color: hsl(214, 20%, 20%);
    /* Dark blue-grey for better contrast */
    --text-muted: hsl(214, 10%, 45%);
    --bg-color: hsl(214, 30%, 96%);
    /* Very light cool grey/blue */
    --bg-card-color: rgba(255, 255, 255, 0.75);
    /* More opaque white for cards */
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 10px 30px -10px rgba(0, 50, 100, 0.1);
    /* Colored shadow for depth */
}




*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* Transición directa de las propiedades de color (sin interpolar el ángulo HSL)
       del antiguo al nuevo en 0.5s limpios */
    transition: background-color 0.5s ease,
        color 0.5s ease,
        border-color 0.5s ease,
        box-shadow 0.5s ease,
        fill 0.5s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    transition: var(--transition);
    line-height: 1.6;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, hsla(var(--primary-hue), 100%, 50%, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, hsla(270, 50%, 50%, 0.1) 0%, transparent 20%);
    background-attachment: fixed;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

img {
    max-width: 100%;
    display: block;
    border-radius: var(--border-radius);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    padding: 0 2em;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: var(--glass-blur);
    background-color: rgba(var(--bg-card-color), 0.5);
    /* Semi-transparent */
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

/* Switches & Controls */
.switches {
    display: flex;
    align-items: center;
    gap: 1.5em;
}

.toggle-theme {
    display: flex;
    align-items: center;
    gap: 0.5em;
    cursor: pointer;
    padding: 0.5em 1em;
    border-radius: 2em;
    background: var(--bg-card-color);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.toggle-theme:hover {
    background: rgba(255, 255, 255, 0.1);
}

.toggle-theme__icon {
    width: 20px;
    filter: invert(1) brightness(2);
    /* Adjust for dark icons */
}

body:not(.dark) .toggle-theme__icon {
    filter: none;
}

.toggle-theme__text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-color);
}

.flags {
    display: flex;
    gap: 0.8em;
}

.flags__item {
    width: 28px;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition);
}

.flags__item:hover {
    opacity: 1;
}

/* Colors Picker */
.colors {
    display: flex;
    gap: 0.8em;
}

.colors__item {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

/* Indicador visual del color de acento activo */
.colors__item--active {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    outline-offset: 2px;
}

body:not(.dark) .colors__item--active {
    outline: 2px solid rgba(0, 0, 0, 0.5);
    outline-offset: 2px;
}



/* Main Layout */
.main {
    max-width: 1200px;
    margin: 2em auto;
    padding: 0 1.5em;
    display: grid;
    gap: 2em;
}

@media screen and (min-width: 900px) {
    .main {
        grid-template-columns: 350px 1fr;
        align-items: start;
    }
}

/* Columns */
.column {
    display: flex;
    flex-direction: column;
    gap: 2em;
}

/* Cards (Glassmorphism) */
.card {
    background: var(--bg-card-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2em;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 50px -10px rgba(0, 0, 0, 0.6);
}

body:not(.dark) .card:hover {
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 15px 50px -10px rgba(0, 50, 100, 0.15);
}

/* Profile Card */
.card--profile {
    text-align: center;
}

.card__image-container {
    width: 150px;
    height: 150px;
    margin: 0 auto;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-color);
    padding: 3px;
    margin-bottom: 1.5em;
}

.card__image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.card__title {
    font-family: var(--font-heading);
    color: var(--text-color);
    font-size: 1.5rem;
    margin-bottom: 0.5em;
    font-weight: 700;
}

.card__subtitle {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1.5em;
    font-size: 1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    min-height: 3.2em; /* Evita saltos en móvil (2 líneas) */
}

@media screen and (min-width: 900px) {
    .card__subtitle {
        min-height: 1.6em; /* 1 línea en PC */
    }
}

/* Cursor parpadeante del efecto typewriter */
.typewriter-cursor {
    display: inline-block;
    color: var(--primary-color);
    font-weight: 300;
    animation: blink 0.75s step-end infinite;
    margin-left: 1px;
}

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

.card__link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8em;
    margin-bottom: 0.8em;
    color: var(--text-muted);
}

.card__link a {
    color: var(--text-muted);
}

.card__link a:hover {
    color: var(--primary-color);
}

.card__text {
    margin-top: 1.5em;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    text-align: left;
}

/* Experience Card */
.experience {
    display: flex;
    gap: 1.5em;
    padding-bottom: 1.5em;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5em;
}

.experience:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.experience__image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: white;
    padding: 5px;
    border-radius: 8px;
}

.experience__info {
    flex: 1;
}

.experience__time {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.3em;
}

.experience__job {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.3em;
    color: var(--text-color);
}

.experience__company {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.5em;
}

.experience__description {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Skills — cuadrícula de iconos por categoría */
.card--skills {
    display: flex;
    flex-direction: column;
    gap: 1.8em;
}

.skills-main-title {
    font-size: 1.3rem;
    margin-bottom: 0.2em;
    padding-bottom: 0.8em;
    border-bottom: 1px solid var(--border-color);
}

.skills-group {
    padding-bottom: 1.5em;
    border-bottom: 1px solid var(--border-color);
}

.skills-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.skills-group .card__title {
    font-size: 1rem;
    margin-bottom: 0.9em;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.78rem;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 0.75em;
}

.skill-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    padding: 0.9em 0.5em;
    border-radius: 0.75rem;
    background: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.05);
    border: 1px solid hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.15);
    cursor: default;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.skill-card:hover {
    background: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.12);
    border-color: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.4);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.15);
}

.skill-card__icon {
    font-size: 2rem;
    line-height: 1;
}

/* El icono de GitHub no tiene clase colored; lo adaptamos al tema */
.skill-card__icon--themed {
    color: var(--text-color);
}

.skill-card__name {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
}

/* Projects */
.card--project {
    padding: 0;
    /* Remove padding for image to bleed */
    display: flex;
    flex-direction: column;
}

.card--project .card__image-container {
    width: 100%;
    height: 250px;
    border-radius: 0;
    border: none;
    margin: 0;
    padding: 0;
}

.card--project .card__image-container img {
    border-radius: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}



.project {
    padding: 2em;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.project__tags {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    margin-bottom: 1em;
}

.project__tag {
    font-size: 0.75rem;
    padding: 0.2em 0.8em;
    border-radius: 2em;
    background: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.1);
    color: var(--primary-color);
    border: 1px solid hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.2);
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1em;
    margin-top: auto;
    padding-top: 1.5em;
}

.button--primary,
.button--code,
.button--cv {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6em 1.5em;
    border-radius: 2em;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    text-align: center;
    border: 1px solid transparent;
}

.button--primary:active,
.button--code:active,
.button--cv:active {
    transform: scale(0.95);
}

.button--primary {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 15px hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.3);
}

.button--primary:hover {
    box-shadow: 0 6px 20px hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.4);
}

.button--code {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.button--code:hover {
    background: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.1);
}

/* CV Download Specifics */
.card--CV {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.pdf__icon {
    width: 60px;
    height: 60px;
    margin: 1em 0;
    opacity: 0.8;
}

.button--cv {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    margin-top: 1em;
}

/* Social Media */
.card--rs {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rs-img {
    display: flex;
    gap: 2em;
    margin-top: 1em;
    align-items: center; /* Evita que los enlaces se estiren verticalmente */
}

.rs-img a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rs-icon {
    font-size: 2.2rem;
    color: var(--text-color);
    opacity: 0.7;
    transition: var(--transition);
}

/* En modo claro los iconos resaltan más por defecto */
body:not(.dark) .rs-icon {
    opacity: 1;
}

/* Colores originales al pasar el ratón */
#linkedin-link:hover .rs-icon {
    color: #0e76a8;
    opacity: 1;
    transform: scale(1.1);
}

#github-link:hover .rs-icon {
    color: var(--primary-color);
    opacity: 1;
    transform: scale(1.1);
}

#instagram-link:hover .rs-icon {
    color: #E1306C;
    opacity: 1;
    transform: scale(1.1);
}

#whatsapp-link:hover .rs-icon {
    color: #25D366;
    opacity: 1;
    transform: scale(1.1);
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox__content {
    max-width: 90%;
    max-height: 90%;
}

.lightbox__image {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--border-radius);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.lightbox__close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}

/* Skill bar specifics for JS to hook into */
.skills__bar--10 {
    --skills-bar-length: 10%;
}

.skills__bar--20 {
    --skills-bar-length: 20%;
}

.skills__bar--30 {
    --skills-bar-length: 30%;
}

.skills__bar--40 {
    --skills-bar-length: 40%;
}

.skills__bar--50 {
    --skills-bar-length: 50%;
}

.skills__bar--60 {
    --skills-bar-length: 60%;
}

.skills__bar--70 {
    --skills-bar-length: 70%;
}

.skills__bar--80 {
    --skills-bar-length: 80%;
}

.skills__bar--90 {
    --skills-bar-length: 90%;
}

.skills__bar--100 {
    --skills-bar-length: 100%;
}

/* Color overrides for specific theme colors */
.colors__item--blue {
    background-color: hsl(214, 84%, 56%);
}

.colors__item--green {
    background-color: hsl(150, 60%, 45%);
}

.colors__item--purple {
    background-color: hsl(270, 60%, 55%);
}

.colors__item--wine {
    background-color: hsl(350, 85%, 40%);
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .header {
        padding: 0 1em;
        height: auto;
        flex-direction: column;
        padding-bottom: 1em;
    }

    .switches {
        margin-top: 1em;
        width: 100%;
        justify-content: space-between;
    }

    .colors {
        display: none;
        /* Hide distinct color picker on mobile if cluttered, or keep */
    }

    .card--project .card__image-container {
        height: 200px;
    }
}

/* ── Botón Volver Arriba ────────────────────────────────────────── */
.btn-scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, background-color 0.5s ease;
    z-index: 999;
}

.btn-scroll-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.btn-scroll-top:hover {
    background-color: hsla(var(--primary-hue), var(--primary-sat), calc(var(--primary-light) - 10%), 1);
    transform: translateY(-3px) scale(0.95);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* ── Footer ─────────────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 2em 1em;
    margin-top: 2em;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ── Filtro de proyectos ────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 0.6em;
    flex-wrap: wrap;
    margin-bottom: 1.5em;
}

.filter-btn {
    padding: 0.4em 1.1em;
    border-radius: 2em;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-body);
    border: 1.5px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.15s ease;
}

.filter-btn:hover {
    background: hsla(var(--primary-hue), var(--primary-sat), var(--primary-light), 0.12);
}

.filter-btn--active {
    background: var(--primary-color);
    color: #fff;
}

/* Tarjeta de proyecto oculta por filtro */
.card--project {
    transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.35s ease;
}

.card--hidden {
    opacity: 0;
    transform: scale(0.97);
    pointer-events: none;
    display: none;
}

/* ── Galería horizontal de proyectos ────────────────────────────── */
.project-gallery {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    scroll-snap-type: x mandatory;
}

.gallery__image {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    scroll-snap-align: start;
    border-radius: 0;
    cursor: zoom-in;
}

.gallery-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(4px);
    transition: background 0.2s ease;
}

.gallery-button:hover {
    background: rgba(0, 0, 0, 0.75);
}

.gallery-button--left {
    left: 8px;
}

.gallery-button--right {
    right: 8px;
}