/* ========================================
   CSS Variables & Theme - Academic Style
   ======================================== */
:root {
    /* Colors - UCLM Institutional */
    --primary: #B30033;
    --primary-dark: #8a0028;
    --primary-light: #d4004a;
    --accent: #1e3a5f;

    /* Light theme */
    --text: #1f2937;
    --text-light: #6b7280;
    --text-inverse: #ffffff;
    --background: #ffffff;
    --surface: #f8f9fa;
    --surface-alt: #f1f3f5;
    --border: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.08);

    /* Publication colors */
    --color-journal: #B30033;
    --color-conference: #d97706;
    --color-national: #64748b;
    --color-workshop: #7e22ce;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Transitions */
    --transition: 200ms ease;

    /* Border radius */
    --radius: 6px;
    --radius-lg: 10px;
}



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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

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

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

/* ========================================
   Header - Compact Academic Style
   ======================================== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-inverse);
    padding: var(--space-xl) 0;
    position: relative;
}

/* Language Toggle */
.lang-toggle {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-lg);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    color: var(--text-inverse);
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    gap: 4px;
}

.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lang-toggle span {
    padding: 2px 6px;
    border-radius: 3px;
    opacity: 0.6;
}

.lang-toggle span.active {
    background: rgba(255, 255, 255, 0.3);
    opacity: 1;
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: var(--space-lg);
    align-items: center;
}

.header-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.header-info h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2px;
    letter-spacing: -0.02em;
}

.header-role {
    font-size: 1rem;
    opacity: 0.95;
    margin-bottom: var(--space-xs);
}

.header-affiliation {
    font-size: 0.85rem;
    opacity: 0.85;
    line-height: 1.4;
}

.header-affiliation a {
    color: var(--text-inverse);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.header-affiliation a:hover {
    opacity: 1;
}

.header-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    align-items: start;
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-inverse);
    font-size: 0.85rem;
    opacity: 0.9;
    transition: opacity var(--transition);
}

.header-link:hover {
    opacity: 1;
    color: var(--text-inverse);
}

.header-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.header-link-email {
    grid-column: 1 / -1;
    margin-bottom: 4px;
}


/* ========================================
   Navigation
   ======================================== */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: flex;
    gap: var(--space-xl);
}

.nav-link {
    display: block;
    padding: var(--space-md) 0;
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ========================================
   Main Content
   ======================================== */
.main {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg) var(--space-2xl);
}

.section {
    margin-bottom: var(--space-2xl);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--border);
}

/* ========================================
   About Section
   ======================================== */
.about-text {
    font-size: 1rem;
    color: var(--text);
    line-height: 1.75;
}

.about-text strong {
    color: var(--primary);
    font-weight: 600;
}

/* ========================================
   Publications
   ======================================== */
.pub-filters {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.pub-filter {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--background);
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.pub-filter:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pub-filter.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.pub-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Timeline Layout */
.timeline {
    position: relative;
    padding-left: 30px;
    /* Ensure container has height for lines if needed, but relative should suffice */
}

/* Year Markers */
.timeline-year-marker {
    position: relative;
    margin: var(--space-xl) 0 var(--space-md);
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.5s ease;
}

.timeline-year-marker:first-child {
    margin-top: 0;
}

.timeline-year-marker.visible {
    opacity: 1;
    transform: translateX(0);
}

.timeline-year-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-inverse);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 8px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(179, 0, 51, 0.3);
    position: relative;
    left: -8px;
}

/* Timeline Items */
.timeline-item {
    position: relative;
    margin-bottom: var(--space-md);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
    transition-delay: var(--delay, 0s);
}

.timeline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.timeline-dot {
    position: absolute;
    left: -26px;
    top: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--primary);
    transition: all 0.3s ease;
    z-index: 2;
}

/* Colored line segment for each item */
.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 32px;
    /* Connect to next item */
    height: calc(100% + var(--space-md));
    width: 4px;
    border-radius: 2px;
    background: var(--color-journal);
    opacity: 0.6;
    transition: opacity 0.3s ease;
    z-index: 0;
}

/* Last item before year marker: shorter line that ends cleanly */
.timeline-item.no-connect-down::before {
    height: 40px;
}

/* Absolute last child in timeline: hide the line */
.timeline-item:last-child::before {
    display: none;
}


.timeline-item:hover::before {
    opacity: 1;
}

/* Type specific line colors */
.timeline-item[data-category="conference"]::before {
    background: var(--color-conference);
}

.timeline-item[data-category="national"]::before {
    background: var(--color-national);
}

.timeline-item[data-category="workshop"]::before {
    background: var(--color-workshop);
}

.timeline-item:hover .timeline-dot {
    background: var(--primary);
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(179, 0, 51, 0.5);
}

/* Type-specific dot colors */
.timeline-item[data-category="journal"] .timeline-dot {
    border-color: var(--color-journal);
}

.timeline-item[data-category="journal"]:hover .timeline-dot {
    background: var(--color-journal);
    box-shadow: 0 0 10px rgba(179, 0, 51, 0.5);
}

.timeline-item[data-category="conference"] .timeline-dot {
    border-color: var(--color-conference);
}

.timeline-item[data-category="conference"]:hover .timeline-dot {
    background: var(--color-conference);
    box-shadow: 0 0 10px rgba(217, 119, 6, 0.5);
}

.timeline-item[data-category="national"] .timeline-dot {
    border-color: var(--color-national);
}

.timeline-item[data-category="national"]:hover .timeline-dot {
    background: var(--color-national);
    box-shadow: 0 0 10px rgba(100, 116, 139, 0.5);
}

.timeline-item[data-category="workshop"] .timeline-dot {
    border-color: var(--color-workshop);
}

.timeline-item[data-category="workshop"]:hover .timeline-dot {
    background: var(--color-workshop);
    box-shadow: 0 0 10px rgba(126, 34, 206, 0.5);
}


.pub-card {
    display: grid;
    grid-template-columns: 4px 1fr;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.pub-card:hover {
    box-shadow: 0 2px 8px var(--shadow);
    border-color: var(--border);
}

/* Color stripe */
.pub-stripe {
    background: var(--border);
}

.pub-card[data-category*="journal"] .pub-stripe {
    background: var(--color-journal);
}

.pub-card[data-category*="conference"] .pub-stripe {
    background: var(--color-conference);
}

.pub-card[data-category*="national"] .pub-stripe {
    background: var(--color-national);
}

.pub-card[data-category*="workshop"] .pub-stripe {
    background: var(--color-workshop);
}

.pub-content {
    padding: var(--space-md);
}

.pub-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.pub-venue {
    font-weight: 600;
    font-size: 0.875rem;
}

.pub-card[data-category*="journal"] .pub-venue {
    color: var(--color-journal);
}

.pub-card[data-category*="conference"] .pub-venue {
    color: var(--color-conference);
}

.pub-card[data-category*="national"] .pub-venue {
    color: var(--color-national);
}

.pub-card[data-category*="workshop"] .pub-venue {
    color: var(--color-workshop);
}

.pub-year {
    color: var(--text-light);
    font-size: 0.8rem;
}

.pub-rank {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-light);
    background: var(--surface-alt);
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.pub-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.45;
    color: var(--text);
}

.pub-authors {
    color: var(--text-light);
    font-size: 0.8rem;
    line-height: 1.4;
}

.pub-authors strong {
    color: var(--text);
    font-weight: 600;
}

/* Year Dividers */
.year-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-xl) 0 var(--space-lg);
}

.year-divider:first-child {
    margin-top: 0;
}

.year-divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border), transparent);
}

.year-divider-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--background);
    padding: 0 var(--space-sm);
}

/* Shared Pub Link Styles */
.pub-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
    align-items: center;
    /* Align items vertically */
}

.pub-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    padding: 4px 8px;
    background: var(--surface-alt);
    /* Light gray background for buttons */
    border-radius: var(--radius);
    transition: background var(--transition);
    text-decoration: none;
    border: 1px solid var(--surface-alt);
    /* Add transparent border to match buttons */
    height: 24px;
    /* Fixed height for alignment */
    line-height: 1;
}

.pub-link:hover {
    background: var(--border);
    color: var(--primary-dark);
}

/* Publication Link Groups */
.pub-link-group {
    display: inline-flex;
    align-items: stretch;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid transparent;
    /* Match general border style or keep transparent */
    height: 24px;
    /* Keep border logic */
}

.pub-link-group:hover {
    border-color: var(--border);
}

.pub-link-group .pub-link {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin: 0;
    height: 100%;
    /* Fill container */
}

/* Ensure copy button matches height/style */
.pub-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--surface-alt);
    /* Match link bg */
    padding: 0 8px;
    /* Adjustment for height */
    cursor: pointer;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-light);
    font-size: 0.7rem;
    transition: all var(--transition);
    font-family: var(--font-sans);
    height: 100%;
    /* Fill container */
}

.pub-copy:hover {
    background: var(--border);
    color: var(--text);
}

.pub-copy.copied {
    background-color: #dcfce7;
    color: #166534;
}

.pub-copy-id {
    max-width: none;
    /* Show full ID as requested */
    white-space: nowrap;
    vertical-align: middle;
    margin-left: 2px;
    font-size: 0.7rem;
    color: var(--text-light);
}

/* ========================================
   Stats
   ======================================== */
.stats {
    display: flex;
    gap: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-xl) 0 var(--space-lg);
    text-align: center;
}

.footer-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-md);
}

.footer-logo {
    height: 50px;
    width: auto;
    opacity: 0.8;
    transition: opacity var(--transition);
}

.footer-logo:hover {
    opacity: 1;
}

.footer-text {
    color: var(--text-light);
    font-size: 0.85rem;
    margin: 0;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .header-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-md);
    }

    .header-photo {
        margin: 0 auto;
        width: 90px;
        height: 90px;
    }

    .header-links {
        align-items: center;
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--space-md);
    }

    .header-info h1 {
        font-size: 1.5rem;
    }

    .nav-content {
        justify-content: center;
    }

    .stats {
        justify-content: center;
    }

    .pub-filters {
        justify-content: center;
    }
}

/* ========================================
   Utility
   ======================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ========================================
   Hidden Items (for filtering)
   ======================================== */

/* Force hidden items to be completely invisible */
.hidden-item,
.hidden-item.visible {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
}

/* Ensure ALL children of hidden items are also completely hidden */
.hidden-item *,
.hidden-item::before,
.hidden-item::after,
.hidden-item *::before,
.hidden-item *::after {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    content: none !important;
}

/* ========================================
   Interactive Publication Features
   ======================================== */
.pub-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    /* Matched to link color */
    background: var(--surface-alt);
    /* Matched to link bg */
    border: 1px solid var(--surface-alt);
    /* Matched border */
    padding: 0 8px;
    /* Adjustment for height */
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
    margin-right: 0;
    /* Align with gap in parent */
    height: 24px;
    /* Fixed height for alignment */
    line-height: 1;
}

.pub-action-btn:hover {
    border-color: var(--border);
    /* Matched border hover */
    color: var(--primary-dark);
    background: var(--border);
    /* Matched bg hover */
}

.pub-action-btn.active {
    background: rgba(179, 0, 51, 0.1);
    /* Very light primary color tint */
    border-color: rgba(179, 0, 51, 0.3);
    color: var(--primary-dark);
    /* Removed solid background to keep it looking like other badges */
}

.pub-action-btn svg {
    width: 12px;
    height: 12px;
}

.pub-expandable {
    display: none;
    margin-top: var(--space-sm);
    padding: var(--space-md);
    background: #fafafa;
    /* Slightly distinct background */
    border-radius: var(--radius);
    font-size: 0.9rem;
    border: 1px solid var(--border);
    animation: slideDown 0.2s ease-out;
    position: relative;
}

.pub-expandable.open {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pub-abstract-text {
    line-height: 1.6;
    color: var(--text);
    margin: 0;
    font-family: var(--font-sans);
}

/* LaTeX formatting helpers */
.latex-sc {
    font-variant: small-caps;
    letter-spacing: 0.5px;
}

.latex-sf {
    font-family: var(--font-sans);
}

.latex-it {
    font-style: italic;
}

.latex-bf {
    font-weight: bold;
}

.latex-tt {
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
}


.pub-bibtex-container {
    position: relative;
}

.pub-bibtex-code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Menlo', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    background: #ffffff;
    padding: var(--space-md);
    border-radius: 4px;
    border: 1px solid var(--border);
    color: #383a42;
    /* One Light base color */
    overflow-x: auto;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.02);
}

.pub-bibtex-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.7rem;
    padding: 4px 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-light);
    z-index: 2;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pub-bibtex-copy-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* BibTeX Syntax Highlighting - One Light optimized */
.bib-type {
    color: #a626a4;
    font-weight: bold;
}

/* @article - Purple */
.bib-key {
    color: #e45649;
    font-weight: bold;
}

/* Key - Red */
.bib-field {
    color: #986801;
}

/* author, title - Brown/Gold */
.bib-value {
    color: #50a14f;
}

/* "Title" - Green */
.bib-number {
    color: #d19a66;
}

/* 2026 - Orange */