/* Reset and base styles */
* {
    box-sizing: border-box;
}

html {
    color-scheme: light dark;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
}

/* CSS Custom Properties for theming */
:root {
    /* Light theme colors (inspired by astro-theme-cactus) */
    --color-global-bg: oklch(98.48% 0 0);
    --color-global-text: oklch(26.99% 0.0096 235.05);
    --color-link: oklch(55.44% 0.0431 185.69);
    --color-accent: #af67ff;
    --color-accent-2: oklch(18.15% 0 0);
    --color-quote: #af67ff;
    --color-border: #e5e7eb;
    --color-card-bg: rgba(255, 255, 255, 0.8);
    --color-shadow: rgba(0, 0, 0, 0.1);
}

/* Dark theme colors */
[data-theme="dark"] {
    --color-global-bg: oklch(23.64% 0.0045 248);
    --color-global-text: oklch(83.54% 0 264);
    --color-link: oklch(70.44% 0.1133 349);
    --color-accent: #5ff26b;
    --color-accent-2: oklch(94.66% 0 0);
    --color-quote: oklch(94.8% 0.106 136.49);
    --color-border: #374151;
    --color-card-bg: rgba(31, 41, 55, 0.8);
    --color-shadow: rgba(0, 0, 0, 0.3);
}

/* Base typography */
body {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--color-global-bg);
    color: var(--color-global-text);
    transition: opacity 0.2s ease;
    padding-top: 8rem; /* Increased to account for fixed header */
}

/* Responsive body padding */
@media (max-width: 640px) {
    body {
        padding-top: 7rem !important; /* Reduced padding on mobile */
    }
    h1.prose, .title {
        margin-top: 1rem !important;
        line-height: 1.2; /* Evita que las letras altas se corten */
    }
}

/* Utility classes matching astro-theme-cactus */
.bg-global-bg { background-color: var(--color-global-bg); }
.text-global-text { color: var(--color-global-text); }
.text-accent { color: var(--color-accent); }
.text-accent-2 { color: var(--color-accent-2); }

.mx-auto { margin-left: auto; margin-right: auto; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.min-h-screen { min-height: 100vh; }
.max-w-3xl { max-width: 57.6rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.pt-16 { padding-top: 4rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-16 { margin-bottom: 4rem; }
.mb-28 { margin-bottom: 7rem; }
.me-3 { margin-inline-end: 0.75rem; }
.me-4 { margin-inline-end: 1rem; }
.ms-auto { margin-inline-start: auto; }
.mt-auto { margin-top: auto; }
.h-4 { height: 1rem; }
.w-4 { width: 1rem; }
.h-7 { height: 1.75rem; }
.w-7 { width: 1.75rem; }
.h-10 { height: 2.5rem; }
.w-6 { width: 1.5rem; }
.text-sm { font-size: 0.875rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-normal { font-weight: 400; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'JetBrains Mono', 'Courier New', monospace; }
.antialiased { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.scroll-smooth { scroll-behavior: smooth; }
.relative { position: relative; }
.absolute { position: absolute; }
.hidden { display: none; }
.rounded-md { border-radius: 0.375rem; }
.shadow { box-shadow: 0 1px 3px 0 var(--color-shadow), 0 1px 2px -1px var(--color-shadow); }
.backdrop-blur-sm { backdrop-filter: blur(4px); }
.underline { text-decoration: underline; }
.underline-offset-2 { text-underline-offset: 2px; }
.grayscale { filter: grayscale(100%); }
.opacity-75 { opacity: 0.75; }
.text-center { text-align: center; }
.text-xs { font-size: 0.75rem; }

/* Responsive utilities */
@media (min-width: 640px) {
    .sm\:px-8 { padding-left: 2rem; padding-right: 2rem; }
    .sm\:flex { display: flex; }
    .sm\:flex-row { flex-direction: row; }
    .sm\:flex-col { flex-direction: column; }
    .sm\:items-center { align-items: center; }
    .sm\:invisible { visibility: hidden; }
    .sm\:hidden { display: none; }
    .sm\:static { position: static; }
    .sm\:relative { position: relative; }
    .sm\:absolute { position: absolute; }
    .sm\:z-auto { z-index: auto; }
    .sm\:mt-1 { margin-top: 0.25rem; }
    .sm\:me-0 { margin-inline-end: 0; }
    .sm\:py-0 { padding-top: 0; padding-bottom: 0; }
    .sm\:h-20 { height: 5rem; }
    .sm\:w-12 { width: 3rem; }
    .sm\:text-2xl { font-size: 1.5rem; }
    .sm\:ps-18 { padding-inline-start: 4.5rem; }
    .sm\:-ms-4 { margin-inline-start: -1rem; }
    .sm\:divide-accent > :not([hidden]) ~ :not([hidden]) { 
        border-inline-start-width: 1px; 
        border-color: var(--color-accent); 
    }
    .sm\:rounded-none { border-radius: 0; }
    .sm\:bg-transparent { background-color: transparent; }
    .sm\:shadow-none { box-shadow: none; }
    .sm\:backdrop-blur-none { backdrop-filter: none; }
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.focus\:not-sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Custom component styles */
.title {
    color: var(--color-accent-2);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

.cactus-link {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity 0.2s ease;
}

.cactus-link:hover {
    text-decoration-thickness: 2px;
}

/* Hover color for individual 'b'/'B' letters */
.hover-b {
    transition: color 0.15s ease;
}
.hover-b:hover {
    color: #ffd400; /* yellow */
}

/* Flying bee emoji created on clicking a 'b' */
.flying-bee {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    font-size: 1.2em;
    line-height: 1;
    will-change: transform, opacity;
    animation: bee-fly 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes bee-fly {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    20% {
        transform: translate(calc(var(--dx) * 0.2), calc(var(--dy) * 0.2)) rotate(90deg);
    }
    40% {
        transform: translate(calc(var(--dx) * 0.4 + 6px), calc(var(--dy) * 0.4 - 4px)) rotate(180deg);
    }
    60% {
        transform: translate(calc(var(--dx) * 0.6 - 4px), calc(var(--dy) * 0.6 + 6px)) rotate(270deg);
    }
    80% {
        transform: translate(calc(var(--dx) * 0.8 + 3px), calc(var(--dy) * 0.8 - 3px)) rotate(360deg);
    }
    100% {
        transform: translate(var(--dx), var(--dy)) rotate(450deg);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .flying-bee {
        animation: bee-fade 250ms ease-out forwards;
    }
    @keyframes bee-fade {
        to { opacity: 0; }
    }
}

/* Header styles */
#main-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 57.6rem; /* Same as max-w-3xl */
    width: 100%;
    background-color: color-mix(in srgb, var(--color-global-bg) 95%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--color-border) 50%, transparent);
    z-index: 100;
    padding: 1rem 1rem 0.5rem 1rem; /* Match main content px-4 */
}



/* Header grid layout */
.header-grid {
    display: grid;
    grid-template-columns: auto 1fr minmax(0, auto);
    grid-template-rows: auto auto;
    grid-template-areas:
        "logo title controls"
        "logo nav controls";
    align-items: center;
    column-gap: 1rem;
}

.header-logo { grid-area: logo; align-self: center; }
.header-title { grid-area: title; align-self: center; }
.header-nav { grid-area: nav; align-self: center; }
.header-controls { 
    grid-area: controls; 
    justify-self: end; 
    max-width: 100%; 
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Nav links now centered with title - no additional margin needed */

@media (min-width: 640px) {
    #main-header {
        padding: 1rem 2rem 0.5rem 2rem; /* Match main content sm:px-8 */
    }
}

.group:hover .grayscale {
    filter: none;
}

/* Make logo clickable with cursor pointer and subtle hover effect */
#main-header a[href="#"] {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

#main-header a[href="#"]:hover svg {
    transform: scale(1.05);
    transition: opacity 0.2s ease;
}

#main-header a[href="#"]:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Navigation styles - Desktop */
.mobile-nav-menu {
    /* Desktop styles */
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    position: static;
    background: transparent;
    margin-top: 0.25rem;
    margin-left: -1rem;
}

.mobile-nav-menu > a {
    padding: 0 1rem;
    border-left: 1px solid var(--color-accent);
    color: var(--color-accent);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.mobile-nav-menu > a:first-child {
    border-left: none;
}

.mobile-nav-menu > a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Mobile navigation - completely override everything */
@media (max-width: 640px) {
    .mobile-nav-menu {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background-color: color-mix(in srgb, var(--color-global-bg) 98%, transparent) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        z-index: 150 !important;
        display: none !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 2rem !important;
        padding: 2rem !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
        transform: none !important;
        inset: 0 !important;
    }
    
    .mobile-nav-menu > a {
        font-size: 1.5rem !important;
        padding: 1rem 2rem !important;
        border-radius: 0.5rem !important;
        transition: opacity 0.2s ease !important;
        text-align: center !important;
        min-width: 200px !important;
        background-color: color-mix(in srgb, var(--color-accent) 10%, transparent) !important;
        border: 1px solid var(--color-accent) !important;
        color: var(--color-accent) !important;
        text-decoration: none !important;
        display: block !important;
        margin: 0 !important;
    }
    
    .mobile-nav-menu > a:hover {
        background-color: var(--color-accent) !important;
        color: var(--color-global-bg) !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 12px color-mix(in srgb, var(--color-accent) 30%, transparent) !important;
        text-decoration: none !important;
    }
}

/* Show mobile menu when menu-open class is present */
.group.menu-open .mobile-nav-menu {
    display: flex !important;
    z-index: 150 !important;
}

/* Mobile menu button improvements */
#toggle-navigation-menu {
    z-index: 200; /* Highest z-index to stay above menu */
    position: relative;
    background-color: color-mix(in srgb, var(--color-accent-2) 10%, transparent);
    border-radius: 0.375rem;
    border: 1px solid color-mix(in srgb, var(--color-accent-2) 20%, transparent);
    transition: opacity 0.2s ease;
}

#toggle-navigation-menu:hover {
    background-color: color-mix(in srgb, var(--color-accent-2) 20%, transparent);
    transform: scale(1.05);
}

/* Hamburger icon sizing and toggling */
#toggle-navigation-menu svg {
    width: 24px;
    height: 24px;
    transition: opacity 0.2s ease;
}

#toggle-navigation-menu[aria-expanded="false"] svg:first-of-type { display: block; opacity: 1; }
#toggle-navigation-menu[aria-expanded="false"] svg:last-of-type  { display: none;  opacity: 0; }

#toggle-navigation-menu[aria-expanded="true"]  svg:first-of-type { display: none;  opacity: 0; }
#toggle-navigation-menu[aria-expanded="true"]  svg:last-of-type  { display: block; opacity: 1; }

/* Theme toggle styles */
#theme-toggle {
    background-color: color-mix(in srgb, var(--color-accent-2) 20%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-accent-2) 30%, transparent);
    transition: opacity 0.2s ease;
    z-index: 50;
    position: relative;
}

#theme-toggle:hover {
    background-color: color-mix(in srgb, var(--color-accent-2) 30%, transparent);
    transform: scale(1.05);
}

/* Theme icon visibility */
[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

:root .sun-icon {
    display: none;
}

:root .moon-icon {
    display: block;
}

/* Prose styles (typography) */
.prose {
    color: var(--color-global-text);
    max-width: none; /* Allow prose to use full container width */
}

/* Estilos base para encabezados con clase .prose o dentro de .prose */
.prose h1, h1.prose, 
.prose h2, h2.prose, 
.prose h3, h3.prose, 
.prose h4, h4.prose, 
.prose h5, h5.prose, 
.prose h6, h6.prose {
    color: var(--color-accent-2);
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 1rem;
    display: block; /* Asegura que ocupe su lugar en el layout */
}

/* Tamaños para Escritorio (Desktop) */
@media (min-width: 641px) {
    .prose h1, h1.prose { font-size: 2.25rem; margin-top: 2rem; }
    .prose h2, h2.prose { font-size: 1.875rem; margin-top: 2rem; }
    .prose h3, h3.prose { font-size: 1.5rem; margin-top: 1.5rem; }
    .prose h4, h4.prose { font-size: 1.25rem; margin-top: 1.5rem; }
}

/* Adaptación específica para Móvil (Mobile) */
@media (max-width: 640px) {
    /* Reducimos el tamaño para que títulos largos como "Publications (76)" no se corten */
    .prose h1, h1.prose { font-size: 1.75rem; }
    .prose h2, h2.prose { font-size: 1.5rem; }
    .prose h3, h3.prose { font-size: 1.25rem; }

    /* Forzamos un margen superior extra al primer título para que no lo tape el header */
    .prose h1:first-of-type, h1.prose:first-of-type, .title:first-of-type {
        margin-top: 2.5rem !important; 
    }
}

.prose p {
    margin-bottom: 1.25rem;
}

.prose ul, .prose ol {
    margin-bottom: 1.25rem;
    padding-left: 1.625rem;
}

.prose li {
    margin-bottom: 0.5rem;
}

.prose a {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.prose a:hover {
    text-decoration-thickness: 2px;
}

@media (max-width: 640px) {
    /* Fuerza a que el primer h1 de la página tenga aire suficiente */
    .prose h1:first-of-type, 
    h1.prose:first-of-type {
        margin-top: 3rem !important; 
        display: block !important;
        visibility: visible !important;
    }
}

/* About section layout */
.about-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: nowrap;
    margin-top: 0.25rem;
    margin-bottom: 1rem;
}

.about-avatar {
    width: 120px;
    height: 120px;
    border-radius: 9999px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--color-border);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--color-shadow) 50%, transparent);
    background-color: var(--color-border);
}

.about-header-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Reduce default heading top margin inside about header to better center with avatar */
.about-header .title {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
    .about-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .about-avatar {
        width: 88px;
        height: 88px;
        margin-top: 1.5rem; /* Add padding above the avatar on mobile */
    }
    .about-header-content {
        align-items: center;
    }
}

.prose strong {
    color: var(--color-accent-2);
    font-weight: 600;
}

.prose code {
    background-color: color-mix(in srgb, var(--color-accent-2) 10%, transparent);
    border: 1px dotted #666;
    border-radius: 2px;
    padding: 0.125rem 0.25rem;
    font-size: 0.875rem;
}

.prose blockquote {
    border-left: 4px solid var(--color-accent);
    padding-left: 1rem;
    margin-left: 0;
    font-style: italic;
    color: var(--color-quote);
}

/* Project grid */
.project-grid {
    display: grid;
    gap: 2rem;
    margin-top: 2rem;
}

@media (min-width: 768px) {
    .project-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

.project-card {
    background-color: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    backdrop-filter: blur(8px);
    transition: opacity 0.2s ease;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--color-shadow);
}

.project-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--color-accent-2);
}

.project-card p {
    margin-bottom: 1.5rem;
    color: var(--color-global-text);
}

.project-links {
    display: flex;
    gap: 1rem;
}

.project-links a {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-accent);
    border-radius: 0.25rem;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.project-links a:hover {
    background-color: var(--color-accent);
    color: var(--color-global-bg);
}

/* Contact links */
.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
}

.contact-links a {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.contact-links a:hover {
    background-color: var(--color-accent);
    color: var(--color-global-bg);
    transform: translateY(-1px);
}

/* Smooth transitions */
* {
    transition: opacity 0.2s ease;
}

/* Focus styles for accessibility: only show on keyboard navigation */
a:focus,
button:focus {
    outline: none;
}
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Scroll margin for anchor links */
:target {
    scroll-margin-top: 8rem; /* Increased to account for fixed header */
}

@media (max-width: 640px) {
    :target {
        scroll-margin-top: 5rem; /* Reduced for mobile */
    }
}

/* Responsive typography */
@media (max-width: 640px) {
    .title {
        font-size: 1.25rem;
    }
    
    .prose h1 { font-size: 1.875rem; }
    .prose h2 { font-size: 1.5rem; }
    .prose h3 { font-size: 1.25rem; }
    
    .contact-links {
        flex-direction: column;
    }
    
    .project-links {
        flex-direction: column;
    }
    
    /* Mobile header adjustments */
    #main-header {
        /* Keep fixed position on mobile - removed position: relative override */
        z-index: 100; /* Ensure proper z-index on mobile */
    }
    
    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden;
        height: 100vh;
    }
    
    /* Logo and title spacing on mobile */
    #main-header .text-xl {
        font-size: 1.125rem;
    }
    
    /* Mobile menu animation */
    .mobile-nav-menu {
        animation: fadeInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .group.menu-open .mobile-nav-menu {
        animation: fadeInScale 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* Menu animation keyframes */
@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Touch-friendly improvements */
@media (max-width: 640px) {
    /* Collapse grid to a simple row on mobile; keep existing overlay menu */
    .header-grid {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        flex-wrap: nowrap;
    }

    .header-title { display: flex; align-items: center; flex: 1; min-width: 0; }
    .header-nav { display: none; }

    /* Adjust controls spacing on mobile */
    .header-controls {
        gap: 0.5rem;
        white-space: nowrap;
    }

    /* Add spacing after logo on mobile */
    .header-logo { margin-right: 0.5rem; }

    /* Enlarge hamburger icon visuals on mobile */
    #toggle-navigation-menu svg {
        width: 24px;
        height: 24px;
    }

    /* Larger touch targets */
    #theme-toggle,
    #toggle-navigation-menu {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }
    
    /* Better touch feedback */
    #toggle-navigation-menu:active,
    #theme-toggle:active {
        transform: scale(0.95);
    }
    
    /* Improved header spacing on mobile */
    #main-header {
        /* Keep fixed positioning - only adjust padding */
        padding-bottom: 1rem;
        /* Remove margin-bottom since fixed headers don't need margin */
    }

    /* Reduce first section top padding to avoid excessive gap under fixed header */
    #about {
        padding-top: 1rem !important;
    }
    
    /* Better logo visibility and size */
    #main-header svg {
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
        height: 4rem !important; /* Increase from 3.5rem to 4rem */
        width: 2.4rem !important;  /* Increase from 2.1rem to 2.4rem, maintaining aspect ratio */
    }
}

/* Prevent text selection on interactive elements */
#toggle-navigation-menu,
#theme-toggle {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth transitions for better UX */
.mobile-nav-menu a {
    transition: opacity 0.2s ease;
}

/* Active navigation link styling */
@media (max-width: 640px) {
    .mobile-nav-menu a.active {
        background-color: var(--color-accent) !important;
        color: var(--color-global-bg) !important;
        border-color: var(--color-accent) !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 12px color-mix(in srgb, var(--color-accent) 30%, transparent) !important;
    }
}

@media (min-width: 640px) {
    .mobile-nav-menu a.active {
        background-color: transparent !important;
        color: var(--color-accent) !important;
        text-decoration: underline !important;
        text-underline-offset: 4px !important;
        /* Keep vertical dividers visible even when active */
        border-left: 1px solid var(--color-accent) !important;
    }
    .mobile-nav-menu a.active:first-child {
        border-left: none !important;
    }
}

/* Animation for theme transitions */
html {
    transition: opacity 0.2s ease;
}

/* Loading spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--color-accent);
    font-style: italic;
}

.loading-spinner::after {
    content: '';
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid var(--color-accent);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message styling */
.error-message {
    padding: 1rem;
    background-color: color-mix(in srgb, #ef4444 10%, transparent);
    border: 1px solid #ef4444;
    border-radius: 0.5rem;
    color: #ef4444;
    text-align: center;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-global-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent-2);
}

/* Publication card styles */
.publication-card {
    display: flex;
    background-color: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(8px);
    transition: opacity 0.2s ease;
    gap: 1.5rem;
}

.publication-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--color-shadow);
}

.publication-image {
    flex-shrink: 0;
    width: 120px;
    height: 90px;
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: var(--color-border);
}

.publication-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.publication-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.publication-title {
    margin: 0 !important;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

/* Override prose heading margins for publication titles */
.prose .publication-title {
    margin-top: 0 !important;
    margin-bottom: 0.5rem;
}

.publication-link {
    color: var(--color-accent-2);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.publication-link:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.publication-venue {
    font-size: 0.875rem;
    color: var(--color-accent);
    font-weight: 500;
    background-color: color-mix(in srgb, var(--color-accent) 10%, transparent);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    display: inline-block;
    width: fit-content;
}

.publication-authors {
    font-size: 0.875rem;
    color: var(--color-global-text);
    opacity: 0.8;
}

.publication-year {
    font-size: 0.875rem;
    color: var(--color-global-text);
    opacity: 0.6;
    font-style: italic;
}

.publication-description {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-global-text);
    opacity: 0.9;
}

.publication-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid;
    transition: opacity 0.2s ease;
}

.tag-safety {
    background-color: color-mix(in srgb, #ef4444 15%, transparent);
    border-color: #ef4444;
    color: #ef4444;
}

.tag-interpretability {
    background-color: color-mix(in srgb, #af67ff 15%, transparent);
    border-color: #af67ff;
    color: #af67ff;
}

.tag-arxiv {
    background-color: color-mix(in srgb, #10b981 15%, transparent);
    border-color: #10b981;
    color: #10b981;
}

.tag-workshop {
    background-color: color-mix(in srgb, #f59e0b 15%, transparent);
    border-color: #f59e0b;
    color: #f59e0b;
}

.tag-conference {
    background-color: color-mix(in srgb, #3b82f6 15%, transparent);
    border-color: #3b82f6;
    color: #3b82f6;
}

.tag-bibtex {
    background-color: color-mix(in srgb, #6b7280 15%, transparent);
    border-color: #6b7280;
    color: #6b7280;
}

.tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--color-shadow);
}

.publication-citations {
    font-size: 0.75rem;
    color: var(--color-global-text);
    opacity: 0.6;
    font-style: italic;
    margin-top: 0.5rem;
}

/* Responsive publication cards */
@media (max-width: 768px) {
    .publication-card {
        flex-direction: column;
        gap: 1rem;
    }
    
    .publication-image {
        width: 100%;
        height: 120px;
    }
    
    .publication-tags {
        justify-content: center;
    }
}

/* Party Hat Explosion Animation Styles */
.party-hat {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    width: 40px;
    height: 40px;
    opacity: 1;
    transform-origin: center;
}

.party-hat svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes partyHatExplosion {
    0% {
        opacity: 1;
        transform: scale(0.5) rotate(0deg);
    }
    20% {
        opacity: 1;
        transform: scale(1.2) rotate(72deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) rotate(360deg);
    }
}

.party-hat.exploding {
    animation: partyHatExplosion 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Logo pulse animation for party mode */
.logo-party-pulse {
    animation: partyPulse 0.6s ease-out;
}

@keyframes partyPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Confetti-like sparkles */
.party-sparkle {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
    opacity: 1;
}

@keyframes sparkleExplosion {
    0% {
        opacity: 1;
        transform: scale(0) rotate(0deg);
    }
    20% {
        opacity: 1;
        transform: scale(1.5) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(720deg);
    }
}

.party-sparkle.exploding {
    animation: sparkleExplosion 1.5s ease-out forwards;
}

/* Smaller party hats on mobile */
@media (max-width: 768px) {
    .party-hat {
        width: 30px;
        height: 30px;
    }
}

/* ============================= */
/* Resume Timeline Component     */
/* ============================= */
.timeline {
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    left: var(--line-x);
    top: 0.25rem;
    bottom: 0.25rem;
    width: var(--line-w);
    background: color-mix(in srgb, var(--color-accent-2) 20%, transparent);
}

.timeline-item {
    position: relative;
    padding: 0 0 1.75rem 0;
    padding-left: 3rem; /* Espacio para la línea y la bola */
    border-left: 2px solid var(--color-border);
    margin-left: 2rem; 
    padding-bottom: 2rem;
}

.timeline-item.flex {
    display: flex;
    justify-content: space-between;
}

/* El contenido crece para ocupar el espacio */
.flex-grow {
    flex: 1;
}

.shrink-0 {
    flex-shrink: 0;
}

.timeline-image {
    flex: 0 0 250px;   /* ← CLAVE */
    width: 250px;
    max-width: 250px;
    align-self: flex-start;
}

.timeline-image img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;   /* ← rompe la regla global del tema */
    cursor: zoom-in;
}

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

.timeline-dot {
    position: absolute;
    left: -7px; /* Centrada sobre la línea de 2px (-7 + 1 = centro) */
    top: 0.5rem;
    width: 12px;
    height: 12px;
    background-color: var(--color-accent);
    border-radius: 50%;
    border: 2px solid var(--color-global-bg);
}

.timeline-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.timeline-org {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-accent-2);
}

.timeline-icon {
    font-weight: 700;
    font-size: 2rem;
    color: var(--color-accent-2);
}

.timeline-award {
    font-weight: 700;
    font-size: 1.5rem;
    font-style: italic;
    color: var(--color-accent-2);
}

.timeline-title {
    color: var(--color-global-text);
    font-size: 1rem;
    opacity: 0.9;
}

.timeline-dates {
    margin-left: auto;
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
    color: color-mix(in srgb, var(--color-accent-2) 65%, transparent);
}

.timeline-meta {
    margin-top: 0.25rem;
    font-size: 0.9rem;
    color: color-mix(in srgb, var(--color-accent-2) 75%, transparent);
}

.timeline-desc {
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: color-mix(in srgb, var(--color-accent-2) 75%, transparent);
}

/* Responsive: En móviles solemos querer el año a la izquierda */
@media (max-width: 640px) {
    .timeline-item {
        margin-left: 1rem;
    }
    .timeline-year-header {
        justify-content: flex-start;
        margin-left: 0.5rem;
    }
    .timeline-item.flex {
        flex-direction: column-reverse; /* La imagen sube o baja según prefieras */
    }
    .timeline-image {
        width: 100%;
        max-width: none;
    }
    .timeline-image img {
        max-width: 100%;
    }
}

/* En móviles muy pequeños, si quieres que la imagen pase abajo: */
@media (max-width: 480px) {
    .timeline-item.flex {
        flex-direction: column-reverse; /* La imagen sube o baja según prefieras */
    }
    .timeline-image {
        width: 100%;
        max-width: none;
    }
    .timeline-image img {
        max-width: 100%;
    }
}

/* Contenedor del año para centrarlo en la línea */
.timeline-year-header {
    position: relative;
    text-align: center;
    /*margin-left: -1rem;*/
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
    display: flex;
    justify-content: left;
    z-index: 10;
}

/* Estilo del año grande */
.timeline-year-label {
    background-color: var(--color-global-bg);
    color: var(--color-accent);
    font-size: 1.5rem; /* Más grande */
    font-weight: 800;
    padding: 0.2rem 1rem;
    border: 2px solid var(--color-accent);
    border-radius: 2rem;
    font-family: 'JetBrains Mono', monospace;
    box-shadow: 0 0 10px color-mix(in srgb, var(--color-accent) 20%, transparent);
}

.timeline-meta a {
    text-decoration: none !important;
    border-bottom: none !important; /* Por si tu tema usa borde en lugar de subrayado */
}

/* Estos colores SOLO funcionarán dentro de .publications-timeline */

  /* Rojo para Journals */
  .publications-timeline .timeline-item.journal .timeline-dot {
    background-color: #c32b72;
    border-color: #c32b72; /* Opcional: para que el borde combine */
  }

  /* Azul para International Conferences */
  .publications-timeline .timeline-item.international-conference .timeline-dot {
    background-color: #196ca3;
    border-color: #196ca3;
  }

  /* Verde para Workshops */
  .publications-timeline .timeline-item.workshop .timeline-dot {
    background-color: #2ecc71;
    border-color: #2ecc71;
  }

  /* Amarillo para Nationals */
  .publications-timeline .timeline-item.national-conference .timeline-dot {
    background-color: #e68019;
    border-color: #e68019;
  }

  /* Negro para Others (dentro de publicaciones) */
  .publications-timeline .timeline-item.other .timeline-dot {
    background-color: #ffd500;
    border-color: #ffd500;
  }

/*************************/
/* Timeline dialog modal */
/*************************/
.timeline-clickable {
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.timeline-clickable:hover {
    transform: scale(1.05);
}

.timeline-dialog {
    border: none;
    padding: 0;
    background: transparent;
}

.timeline-dialog::backdrop {
    background: rgba(0,0,0,0.75);
}

.timeline-dialog img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 1rem;
}

.timeline-dialog button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
}

/* ============================= */
/* Filter Switches Component    */
/* ============================= */
.filter-container {
    display: flex;         /* Activa flexbox */
    justify-content: center; /* Centra horizontalmente */
    width: 100%;           /* Asegura que ocupe todo el ancho */
    /* margin: 20px 0 40px 0; /* Espaciado arriba y abajo */
    padding: 5px 0;
    margin: 0;
  }

.filter-switch-group {
    display: inline-flex;  /* Mantiene los botones en línea */
    background: #f1f3f5;
    padding: 3px;
    border-radius: 12px;   /* Bordes más redondeados para look moderno */
    gap: 2px;
    border: 1px solid #e2e8f0;
  }
  .switch-label input { display: none; } /* Escondemos el radio button */
  
  .switch-text {
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.2s;
  }

  /* Color cuando está seleccionado */
  .switch-label input:checked + .switch-text {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: #007bff;
  }

  .badge {
    background: #e9ecef;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.8em;
    color: #666;
  }
  
  .switch-label input:checked + .switch-text .badge {
    background: #007bff;
    color: white;
  }

  .sub-group {
    background: #e9ecef; /* Un gris un poco más oscuro */
    transform: scale(0.95); /* Ligeramente más pequeños */
  }
  
  .switch-label.sub .switch-text {
    font-size: 0.8rem;
    padding: 4px 8px;
  }

.filter-wrapper {
    display: flex;
    flex-direction: column; /* Alinea los grupos uno debajo del otro */
    align-items: center;    /* Centra ambos grupos horizontalmente */
    gap: 0px;              /* Espacio entre la fila principal y la sub-fila */
    margin-bottom: 30px;
    width: 100%;
  }

  .filter-container {
    display: flex;
    justify-content: center;
    width: 100%;
  }

  /* Estilos específicos para que el subfiltro se vea como un "hijo" del principal */
  .sub-container {
    margin-top: -5px; /* Acerca un poco el subfiltro al principal */
    z-index: 1; /* Asegura que esté por encima del filtro principal */
    animation: slideDown 0.3s ease-out;
  }

  .sub-group {
    background: #e9ecef; /* Color ligeramente distinto para diferenciar jerarquía */
    padding: 2px;
    border-radius: 0 0 10px 10px;
    transform: scale(0.9);
    position: relative;
  }

  /* Opcional: Flecha que apunta al grupo principal
  .sub-group::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #e9ecef; 
}
*/

  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Ajuste para que no se vea gigante en escritorio */
  .switch-text {
    white-space: nowrap;
    font-size: 0.9rem;
  }

  /* TErcer nivel de subfiltros */
  .level-3 {
    margin-top: -8px; /* Pegado al nivel 2 */
  }

  .tracks-group {
    background: #f8f9fa; /* Más claro que el nivel 2 */
    border: 1px dashed #dee2e6; /* Borde sutil para indicar sub-categoría */
    transform: scale(0.85); /* Más pequeño aún */
  }

  .level-3 .switch-text {
    font-size: 0.75rem;
    color: #6c757d;
  }

  /* Ajuste para que los badges de nivel 3 no pesen visualmente */
  .level-3 .badge {
    background: transparent;
    border: 1px solid #dee2e6;
  }

  @media (max-width: 640px) {
    .filter-container {
        display: flex;
        flex-wrap: wrap; /* Permite que los filtros bajen si no caben */
        justify-content: center; /* Centra los filtros en móvil para que no se corten */
        gap: 0.5rem;
        padding: 0 10px; /* Da un poco de aire a los lados */
        width: 100%;
        overflow-x: visible; /* Evita que se recorte el contenido */
    }
}