@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@600;700;800&display=swap');

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

/* ── Design Tokens ──────────────────────────────────────────────────────── */
:root {
    --color-primary:       #7138DC;
    --color-primary-light: #8D68EA;
    --color-primary-dark:  #6D36CB;
    --color-accent:        #A994F1;
    --color-dark:          #2E175E;
    --color-light:         #F6F4FE;

    --bg-primary:     #F6F4FE;
    --bg-secondary:   #FFFFFF;
    --bg-tertiary:    #F9FAFB;
    --text-primary:   #2E175E;
    --text-secondary: #64748b;
    --text-tertiary:  #9CA3AF;
    --border-color:   #E5E7EB;
}

[data-theme="dark"] {
    --bg-primary:     #1a1a2e;
    --bg-secondary:   #16213e;
    --bg-tertiary:    #0f1419;
    --text-primary:   #F6F4FE;
    --text-secondary: #C6BBF7;
    --text-tertiary:  #A994F1;
    --border-color:   #2E175E;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.font-display { font-family: 'Playfair Display', serif; }

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

/* ── Utility ────────────────────────────────────────────────────────────── */
.primary-color  { color: var(--color-primary); }
.accent-color   { color: var(--color-accent); }
.text-secondary { color: var(--text-secondary); }

.icon-bg-light  { background-color: #EEEBFC; }
.icon-bg-medium { background-color: #DED9FB; }

.tag-primary { background-color: #EEEBFC; color: var(--color-primary); }
.tag-accent  { background-color: #DED9FB; color: var(--color-primary-dark); }

.btn-primary { background-color: var(--color-primary); }
.btn-outline { border: 2px solid var(--color-primary); color: var(--color-primary); }

.project-link { color: var(--color-primary); }
.nav-link     { color: var(--text-secondary); }

.hero-gradient-bg {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
}

.blob-1 { background-color: #DED9FB; }
.blob-2 { background-color: #C6BBF7; animation-delay: 1s; }

.skill-track       { background-color: var(--border-color); }
.skill-bar-primary { background: linear-gradient(90deg, var(--color-primary), var(--color-accent)); }
.skill-bar-accent  { background: linear-gradient(90deg, var(--color-accent), var(--color-primary-light)); }

.footer-bg     { background-color: #1A1735; }
.footer-social { background: rgba(255, 255, 255, 0.1); }
.footer-social:hover { background-color: var(--color-primary); }

.recommendation-card {
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .recommendation-card {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.social-icon:hover { background-color: var(--color-primary); color: white; }

/* ── Custom Cursor — solo desktop con puntero fino ──────────────────────── */
.cursor,
.cursor-follower { display: none; }

@media (pointer: fine) and (min-width: 769px) {
    .cursor,
    .cursor-follower {
        display: block;
        position: fixed;
        border-radius: 50%;
        pointer-events: none;
        transform: translate(-50%, -50%);
    }
    .cursor {
        width: 20px; height: 20px;
        border: 2px solid var(--color-primary);
        z-index: 9999;
        transition: all 0.15s ease;
    }
    .cursor-follower {
        width: 40px; height: 40px;
        border: 1px solid var(--color-primary);
        z-index: 9998;
        opacity: 0.5;
        transition: all 0.3s ease;
    }
}

/* ── Blobs — nunca tapan contenido ─────────────────────────────────────── */
.blob {
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    animation: blob 8s ease-in-out infinite;
    pointer-events: none;
    user-select: none;
}

@media (max-width: 640px) {
    .blob-1, .blob-2 {
        width: 8rem !important;
        height: 8rem !important;
        opacity: 0.1 !important;
    }
}

/* ── Keyframes ──────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-20px); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes revealText {
    to { opacity: 1; transform: translateY(0); }
}
@keyframes blob {
    0%, 100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    25%       { border-radius: 58% 42% 75% 25% / 76% 46% 54% 24%; }
    50%       { border-radius: 50% 50% 33% 67% / 55% 27% 73% 45%; }
    75%       { border-radius: 33% 67% 58% 42% / 63% 68% 32% 37%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ── Animation Classes ──────────────────────────────────────────────────── */
.animate-fade-in-up { animation: fadeInUp 0.8s ease forwards; }
.animate-fade-in    { animation: fadeIn 1s ease forwards; }
.animate-float      { animation: float 3s ease-in-out infinite; }
.animate-scale-in   { animation: scaleIn 0.6s ease forwards; }

.gradient-text {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Progress Bar ───────────────────────────────────────────────────────── */
.progress-bar {
    position: fixed;
    top: 0; left: 0;
    height: 4px; width: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    z-index: 9999;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.1s linear;
    pointer-events: none;
}

/* ── Text Reveal ────────────────────────────────────────────────────────── */
.text-reveal { overflow: hidden; display: inline-block; }
.text-reveal span {
    display: inline-block;
    opacity: 0;
    transform: translateY(100%);
    animation: revealText 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Stagger Items ──────────────────────────────────────────────────────── */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}
.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ── Section Transitions ────────────────────────────────────────────────── */
section {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}
section.visible { opacity: 1; transform: translateY(0); }

/* ── Navigation ─────────────────────────────────────────────────────────── */
nav {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(246, 244, 254, 0.9);
    transition: background 0.3s ease, box-shadow 0.3s ease;
    min-height: 64px;
}
[data-theme="dark"] nav { background: rgba(26, 26, 46, 0.9); }
nav.scrolled { box-shadow: 0 4px 20px rgba(113, 56, 220, 0.15); }

/* ── Hero ───────────────────────────────────────────────────────────────── */
#hero {
    padding-top: 5rem;
    padding-bottom: 3rem;
    isolation: isolate;
}
#hero .blob-1,
#hero .blob-2 { z-index: 0; }
#hero > div.max-w-6xl {
    position: relative;
    z-index: 1;
}
#hero .parallax {
    aspect-ratio: 4 / 5;
    object-fit: cover;
    width: 100%;
}

/* ── Hero title ─────────────────────────────────────────────────────────── */
.hero-title {
    font-size: 2.25rem;
    line-height: 1.15;
}
@media (min-width: 640px)  { .hero-title { font-size: 3rem; } }
@media (min-width: 768px)  { .hero-title { font-size: 3.75rem; } }
@media (min-width: 1024px) { .hero-title { font-size: 4rem; } }

/* ── Section title ──────────────────────────────────────────────────────── */
.section-title {
    font-size: 1.875rem;
    line-height: 1.2;
}
@media (min-width: 640px)  { .section-title { font-size: 2.25rem; } }
@media (min-width: 768px)  { .section-title { font-size: 3rem; } }

/* ── Mobile Menu Overlay ────────────────────────────────────────────────── */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.3s ease;
}
.mobile-menu-overlay.active {
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

/* ── Mobile Menu — Lateral Drawer ──────────────────────────────────────── */
.mobile-menu {
    position: fixed;
    top: 0; right: 0;
    height: 100dvh;
    width: 75vw;
    max-width: 300px;
    z-index: 40;

    background: rgba(246, 244, 254, 0.72);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-left: 1px solid rgba(113, 56, 220, 0.18);
    box-shadow: -12px 0 48px rgba(113, 56, 220, 0.16);

    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-menu.active { transform: translateX(0); }

[data-theme="dark"] .mobile-menu {
    background: rgba(22, 22, 46, 0.82);
    border-left-color: rgba(113, 56, 220, 0.28);
    box-shadow: -12px 0 48px rgba(0, 0, 0, 0.55);
}

.mobile-menu__header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid rgba(113, 56, 220, 0.1);
    min-height: 64px;
}

.mobile-menu__close {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    touch-action: manipulation;
}
.mobile-menu__close:hover,
.mobile-menu__close:focus-visible {
    background: rgba(113, 56, 220, 0.1);
    color: var(--color-primary);
    border-color: var(--color-primary);
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.mobile-menu nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.25rem 1rem;
    flex: 1;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
}

.mobile-menu .nav-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-radius: 0.875rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
    touch-action: manipulation;
}
.mobile-menu .nav-link:hover,
.mobile-menu .nav-link:focus-visible {
    background: rgba(113, 56, 220, 0.1);
    color: var(--color-primary);
    transform: translateX(4px);
    outline: none;
}

.mobile-menu__cta {
    padding: 0.75rem 1rem 2rem;
    border-top: 1px solid rgba(113, 56, 220, 0.1);
}
.mobile-menu__cta a {
    display: block;
    text-align: center;
    min-height: 48px;
    padding: 0.875rem 1.5rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    background: var(--color-primary);
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
    touch-action: manipulation;
}
.mobile-menu__cta a:hover { background: var(--color-primary-dark); transform: scale(1.02); }

/* ── Theme Toggle ───────────────────────────────────────────────────────── */
.theme-toggle {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    flex-shrink: 0;
}
.theme-toggle:hover  { transform: scale(1.1); border-color: var(--color-primary); }
.theme-toggle svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
    color: var(--text-primary);
    transition: transform 0.3s ease;
}
.theme-toggle:hover svg { transform: rotate(20deg); }

/* ── Card Backgrounds ───────────────────────────────────────────────────── */
.card-bg           { background: var(--bg-tertiary);  transition: background-color 0.3s ease; }
.card-bg-secondary { background: var(--bg-secondary); transition: background-color 0.3s ease; }

/* ── Project Cards ──────────────────────────────────────────────────────── */
.card-reveal {
    opacity: 0;
    transform: translateY(48px);
    transition: opacity 0.65s ease, transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}
.card-reveal.card-visible {
    opacity: 1;
    transform: translateY(0);
}

.project-card {
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(113, 56, 220, 0.1), transparent);
    transition: left 0.5s;
    pointer-events: none;
}
.project-card:hover::before { left: 100%; }
.project-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(113, 56, 220, 0.2);
}
.project-card img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}
.project-card:hover img { transform: scale(1.06); }

/* ── Magnetic Button ────────────────────────────────────────────────────── */
.magnetic-btn {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 44px;
    touch-action: manipulation;
}
.magnetic-btn:hover { transform: scale(1.04); }

/* ── Parallax ───────────────────────────────────────────────────────────── */
.parallax { transition: transform 0.3s ease-out; }

/* ── Skill Bars ─────────────────────────────────────────────────────────── */
.skill-bar { width: 0; transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1); height: 100%; }
.skill-bar.animate { width: var(--skill-width); }

/* ── Logo ───────────────────────────────────────────────────────────────── */
.logo { height: 2rem; width: auto; display: block; }
.logo.dark-mode { display: none; }
html[data-theme="dark"] .logo.light-mode { display: none; }
html[data-theme="dark"] .logo.dark-mode  { display: block; }
@media (min-width: 640px) { .logo { height: 2.5rem; } }

/* ── Custom Scrollbar ───────────────────────────────────────────────────── */
.custom-scroll::-webkit-scrollbar        { height: 6px; }
.custom-scroll::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: 10px; }

/* ── Focus visible global ───────────────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ── Skip link ──────────────────────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.sr-only:focus {
    position: fixed;
    top: 1rem; left: 1rem;
    width: auto; height: auto;
    padding: 0.5rem 1rem;
    margin: 0; overflow: visible;
    clip: auto; white-space: normal;
    background: white; color: black;
    border-radius: 4px;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ── Responsive md+ ─────────────────────────────────────────────────────── */
@media (min-width: 768px) {
    .blob-1, .blob-2 {
        width: 18rem !important;
        height: 18rem !important;
        opacity: 0.2 !important;
    }
    .project-card:hover { transform: translateY(-10px); }
    .social-icon:hover  { background-color: var(--color-primary); color: white; }
    .theme-toggle { width: 48px; height: 48px; }
}