/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1a0a2e;
    --bg-secondary: #0a0515;
    --text-primary: #ffffff;
    --text-secondary: #c4b0e6;
    --text-muted: #8888aa;
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: rgba(155, 127, 212, 0.2);
    --purple-glow: #9b7fd4;
    --purple-soft: #7c5cbf;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f0ecf5;
    --bg-secondary: #e8e3f0;
    --text-primary: #1a0a2e;
    --text-secondary: #2d1b4e;
    --text-muted: #666680;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: rgba(74, 44, 122, 0.08);
    --purple-glow: #7c5cbf;
    --purple-soft: #4a2c7a;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
    line-height: 1.6;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--purple-soft);
    border-radius: 3px;
}

/* ===== GLASS ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    transition: background var(--transition), border var(--transition), transform 0.2s;
}

.glass:hover {
    transform: translateY(-2px);
}

/* ===== CONTAINER ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 24px 80px;
}

/* ===== HEADER ===== */
.header {
    margin-bottom: 32px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 4px;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--text-primary), var(--purple-glow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(155, 127, 212, 0.15);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 8px 16px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), border var(--transition), transform 0.2s;
    user-select: none;
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--purple-glow);
}

.theme-toggle:active {
    transform: scale(0.95);
}

#themeIcon {
    font-size: 16px;
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== PROFILE ===== */
.profile {
    margin-bottom: 32px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
}

.profile-avatar {
    font-size: 48px;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border-radius: 50%;
    border: 2px solid var(--glass-border);
    flex-shrink: 0;
}

.profile-info h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-title {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
}

.profile-description {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
}

/* ===== SECTION TITLE ===== */
.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* ===== PROJECTS - PIRAMIDE/DINAMICO CORREGIDO ===== */
.projects {
    margin-bottom: 40px;
}

.projects-grid {
    display: grid;
    gap: 16px;
    justify-content: center;
    width: 100%;
}

/* ========== 1 PROYECTO ========== */
.projects-grid:has(.project-card:only-child) {
    grid-template-columns: 1fr;
    max-width: 300px;
    margin: 0 auto;
}

/* ========== 2 PROYECTOS ========== */
.projects-grid:has(.project-card:nth-child(2):last-child) {
    grid-template-columns: repeat(2, 1fr);
    max-width: 600px;
    margin: 0 auto;
}

/* ========== 3 PROYECTOS ========== */
.projects-grid:has(.project-card:nth-child(3):last-child) {
    grid-template-columns: repeat(3, 1fr);
}

/* ========== 4 PROYECTOS (3 arriba, 1 abajo centrado) ========== */
.projects-grid:has(.project-card:nth-child(4):last-child) {
    grid-template-columns: repeat(3, 1fr);
    max-width: 900px;
    margin: 0 auto;
}

.projects-grid:has(.project-card:nth-child(4):last-child) .project-card:nth-child(4) {
    grid-column: 2 / 3;
    max-width: 300px;
    width: 100%;
    justify-self: center;
}

/* ========== 5 PROYECTOS (3 arriba, 2 abajo) ========== */
.projects-grid:has(.project-card:nth-child(5):last-child) {
    grid-template-columns: repeat(3, 1fr);
    max-width: 900px;
    margin: 0 auto;
}

.projects-grid:has(.project-card:nth-child(5):last-child) .project-card:nth-child(4),
.projects-grid:has(.project-card:nth-child(5):last-child) .project-card:nth-child(5) {
    grid-column: span 1;
    max-width: 280px;
    width: 100%;
    justify-self: center;
}

/* ========== 6 PROYECTOS (3-2-1) ========== */
.projects-grid:has(.project-card:nth-child(6):last-child) {
    grid-template-columns: repeat(3, 1fr);
    max-width: 900px;
    margin: 0 auto;
}

.projects-grid:has(.project-card:nth-child(6):last-child) .project-card:nth-child(4),
.projects-grid:has(.project-card:nth-child(6):last-child) .project-card:nth-child(5) {
    grid-column: span 1;
    max-width: 280px;
    width: 100%;
    justify-self: center;
}

.projects-grid:has(.project-card:nth-child(6):last-child) .project-card:nth-child(6) {
    grid-column: 2 / 3;
    max-width: 260px;
    width: 100%;
    justify-self: center;
}

/* ========== 7+ PROYECTOS (grid normal) ========== */
.projects-grid:has(.project-card:nth-child(7):last-child) {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    max-width: 900px;
    margin: 0 auto;
}

/* ===== RESPONSIVE PIRAMIDE ===== */
@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
        max-width: 100% !important;
    }

    .projects-grid:has(.project-card:only-child) {
        grid-template-columns: 1fr !important;
    }

    /* Resetear posicionamiento en móvil */
    .projects-grid .project-card:nth-child(4),
    .projects-grid .project-card:nth-child(5),
    .projects-grid .project-card:nth-child(6) {
        grid-column: auto !important;
        max-width: none !important;
        width: auto !important;
        justify-self: auto !important;
    }

    .projects-grid:has(.project-card:nth-child(3):last-child) {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 480px) {
    .projects-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .projects-grid:has(.project-card:nth-child(3):last-child) {
        grid-template-columns: 1fr !important;
    }

    .project-card {
        padding: 16px;
    }
}

/* ===== PROJECT CARD ===== */
.project-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    padding: 20px;
    transition: transform 0.2s, border-color 0.2s;
}

.project-card:hover {
    border-color: var(--purple-glow);
    transform: translateY(-4px);
}

.project-icon {
    font-size: 32px;
}

.project-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.project-card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    flex: 1;
}

.project-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 100px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    display: inline-block;
    align-self: flex-start;
    color: var(--text-secondary);
}

/* ===== EXPERIENCE ===== */
.experience {
    margin-bottom: 40px;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-item {
    padding: 20px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.timeline-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.timeline-role {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.timeline-details {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-details li {
    font-size: 13px;
    color: var(--text-muted);
    padding-left: 18px;
    position: relative;
    line-height: 1.5;
}

.timeline-details li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--purple-glow);
}

/* ===== SKILLS ===== */
.skills {
    margin-bottom: 40px;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.skill-category {
    padding: 16px 20px;
}

.skill-category h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.skill-tag {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 100px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    transition: border-color 0.2s, color 0.2s;
}

.skill-tag:hover {
    border-color: var(--purple-glow);
    color: var(--text-primary);
}

/* ===== CREATIVE ===== */
.creative {
    margin-bottom: 32px;
}

.creative-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.creative-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    transition: transform 0.2s, border-color 0.2s, background var(--transition);
}

.creative-card:hover {
    transform: translateY(-2px);
    border-color: var(--purple-glow);
}

.creative-icon {
    font-size: 20px;
}

.creative-card span:last-child {
    font-size: 14px;
    font-weight: 500;
}

/* ===== FOOTER ===== */
.footer {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    text-align: center;
}

.footer-text {
    font-size: 13px;
    color: var(--text-muted);
}

.footer-link {
    color: var(--purple-glow);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s, text-shadow 0.2s;
    position: relative;
}

.footer-link:hover {
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(155, 127, 212, 0.3);
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--purple-glow);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.footer-link:hover::after {
    transform: scaleX(1);
}

/* ===== AI SECTION ===== */
.ai-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-color: var(--purple-glow);
    border-width: 1px;
    border-style: solid;
}

.ai-icon {
    font-size: 32px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .ai-section {
        flex-direction: column;
        text-align: center;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .container {
        padding: 16px 16px 80px;
    }

    .logo {
        font-size: 22px;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .header-top {
        flex-direction: column;
        align-items: stretch;
    }

    .header-controls {
        justify-content: flex-start;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }

    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .creative-grid {
        flex-direction: column;
    }

    .creative-card {
        justify-content: center;
    }
}

@media (max-width: 400px) {
    .theme-toggle {
        font-size: 12px;
        padding: 6px 12px;
    }

    .profile-avatar {
        font-size: 36px;
        width: 60px;
        height: 60px;
    }

    .profile-info h2 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .project-card {
        padding: 20x 14px;
    }
    .project-card h3 {
        font-size: 15px;
    }
    .project-card p {
        font-size: 11px;
        line-height: 1.2;
    }
    .project-icon {
        font-size: 26px;
    }
}