/* Force update - version 2.9 - Fix publication titles with HTML strong tags */
body {
    --emergency-fix-version: 2.9;
}

/* ===== DARK/LIGHT THEME SYSTEM ===== */

/* Light Theme (Default) */
:root,
[data-theme="light"] {
    --primary-color: #16a34a;
    --primary-color-light: rgba(22, 163, 74, 0.1);
    --primary-color-hover: rgba(22, 163, 74, 0.2);
    --background-color: #fafafa;
    --surface-color: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: rgba(22, 163, 74, 0.3);
    --shadow-color: rgba(22, 163, 74, 0.15);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(22, 163, 74, 0.3);
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #22c55e;
    --primary-color-light: rgba(34, 197, 94, 0.15);
    --primary-color-hover: rgba(34, 197, 94, 0.25);
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: rgba(34, 197, 94, 0.4);
    --shadow-color: rgba(34, 197, 94, 0.2);
    --glass-bg: rgba(30, 41, 59, 0.85);
    --glass-border: rgba(34, 197, 94, 0.4);
}

/* Apply theme colors to body */
body {
    background-color: var(--background-color) !important;
    color: var(--text-primary) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Surface elements */
.page,
.archive,
.page__content,
#main,
.sidebar {
    background-color: var(--background-color) !important;
    color: var(--text-primary) !important;
}

/* Text color overrides */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
}

/* Page headings should be green */
.page__title,
.archive .page__title,
h1.page__title,
.page__content h1,
.page__content h2,
.archive h1,
.archive h2,
.archive h3,
.archive h4 {
    color: var(--primary-color) !important;
}

p, li, span, div {
    color: var(--text-primary) !important;
}

/* Links */
a {
    color: var(--primary-color) !important;
}

a:hover {
    color: var(--primary-color) !important;
    opacity: 0.8;
}

/* Secondary text */
.author__bio,
.page__meta,
.archive__subtitle {
    color: var(--text-secondary) !important;
}

/* Ensure navbar appears above all content */
html, body {
    position: relative !important;
}

/* Glass Top Navigation Bar - Enhanced visibility with theme support */
nav.top-navbar,
.top-navbar {
    position: fixed !important;
    top: 15px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 99999 !important;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-radius: 30px !important;
    padding: 8px 20px !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 4px 20px var(--shadow-color) !important;
    display: flex !important;
    align-items: center !important;
    gap: 20px !important;
    max-width: 90vw !important;
    width: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    white-space: nowrap !important;
    transition: all 0.3s ease !important;
}

.top-navbar .logo {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    color: var(--primary-color) !important;
    text-decoration: none !important;
    white-space: nowrap !important;
}

.top-navbar .logo-icon {
    width: 20px !important;
    height: 20px !important;
    background: var(--primary-color) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    font-weight: bold !important;
    font-size: 0.8rem !important;
}

.top-navbar .nav-links {
    display: flex !important;
    gap: 15px !important;
    align-items: center !important;
}

.top-navbar .nav-links a {
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    font-size: 0.85rem !important;
    padding: 6px 12px !important;
    border-radius: 15px !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    white-space: nowrap !important;
}

.top-navbar .nav-links a:hover,
.top-navbar .nav-links a.active {
    color: var(--primary-color) !important;
    background: var(--primary-color-light) !important;
}

.top-navbar .nav-links a.active::after {
    content: '' !important;
    position: absolute !important;
    bottom: -2px !important;
    left: 12px !important;
    right: 12px !important;
    height: 2px !important;
    background: var(--primary-color) !important;
    border-radius: 2px !important;
}

/* Theme toggle button */
.theme-toggle {
    background: var(--primary-color-light) !important;
    border: none !important;
    border-radius: 15px !important;
    padding: 6px 10px !important;
    cursor: pointer !important;
    color: var(--primary-color) !important;
    font-size: 0.9rem !important;
    transition: all 0.3s ease !important;
}

.theme-toggle:hover {
    background: var(--primary-color-hover) !important;
    transform: scale(1.05);
}

/* Adjust body padding to accommodate fixed navbar - reduced since no masthead */
body {
    padding-top: 70px !important; /* Less space needed for smaller navbar */
}

/* Mobile responsive - Enhanced */
@media (max-width: 768px) {
    .top-navbar {
        padding: 6px 15px;
        gap: 12px;
        border-radius: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .top-navbar .nav-links {
        gap: 10px;
        /* Mobile menu styles handled by mobile-responsive.css */
    }
    
    .top-navbar .nav-links a {
        padding: 4px 8px;
        font-size: 0.8rem;
        /* Enhanced touch targets handled by mobile-responsive.css */
    }
    
    .top-navbar .logo {
        font-size: 0.9rem;
        flex: 1;
    }
    
    body {
        padding-top: 60px !important; /* Adjusted for mobile */
    }
    
    /* Ensure sidebar stacks properly on mobile */
    .sidebar {
        position: relative !important;
        width: 100% !important;
        margin-bottom: 1rem;
    }
    
    /* Improve content readability on mobile */
    .page__content {
        padding: 1rem !important;
        margin: 0.5rem !important;
        font-size: 1rem;
        line-height: 1.6;
    }
}

/* Emergency sidebar centering fix - ONLY for text centering, preserve everything else */
.sidebar {
    background-color: var(--surface-color) !important;
    padding: 1rem !important;
    transition: background-color 0.3s ease;
}

.sidebar .author__name,
.sidebar h3.author__name,
.sidebar .author__bio,
.sidebar p.author__bio {
    text-align: center !important;
    color: var(--text-primary) !important;
}

.sidebar .author__bio {
    color: var(--text-secondary) !important;
}

/* Center the profile picture - More aggressive */
.author__avatar {
    text-align: center !important;
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
}

.author__avatar img {
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    float: none !important;
    clear: both !important;
}

.sidebar .author__avatar {
    text-align: center !important;
    margin: 0 auto !important;
}

.sidebar .author__avatar img {
    margin: 0 auto !important;
    display: block !important;
}

/* Reduce gap between photo and name - More aggressive */
.author__avatar {
    margin-bottom: 0.2rem !important;
    margin-top: 0 !important;
}

.author__content {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.author__name {
    margin-top: 0 !important;
    padding-top: 0 !important;
    margin-bottom: 0.3rem !important;
}

.author__bio {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Remove any spacing from the entire author profile container */
div[itemscope] {
    padding: 0 !important;
    margin: 0 !important;
}

div[itemscope] > div {
    margin: 0.2rem 0 !important;
    padding: 0 !important;
}

/* Reduce gap */
#main {
    gap: 0.5rem !important;
    padding: 1rem !important;
}

/* Force center align with flexbox if needed */
.author__content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
}

/* Ultra compact sidebar */
.sidebar {
    padding: 1rem !important;
}

.sidebar > div {
    margin: 0.1rem 0 !important;
}

/* Make the entire sidebar more compact */
.sidebar .author__avatar img {
    margin: 0 !important;
    padding: 0 !important;
}

.sidebar h3, .sidebar p {
    margin: 0.2rem 0 !important;
    padding: 0 !important;
    line-height: 1.2 !important;
}

/* Keep main content left-aligned - ONLY target main content, not sidebar */
.page__content {
    text-align: left !important;
}

.page__content h1,
.page__content h2,
.page__content h3,
.page__content p,
.page__content ul,
.page__content li {
    text-align: left !important;
    margin-left: 0 !important;
}

/* Specifically target only the archive content (main content area) */
.archive__item,
.archive__item h1,
.archive__item h2,
.archive__item h3,
.archive__item p,
.archive__item ul,
.archive__item li {
    text-align: left !important;
}

/* Target the main content wrapper but NOT the sidebar */
#main .page__content,
#main .archive:not(.sidebar),
.layout--archive .page__content {
    text-align: left !important;
}

/* Override any remaining old theme elements - BE MORE SELECTIVE */
.page,
.archive,
.page__content,
#main {
    background-color: var(--background-color) !important;
    color: var(--text-primary) !important;
}

/* Ensure experience page uses our theme - but preserve formatting */
.archive h1.page__title,
.archive h2,
.archive h3,
.archive h4 {
    color: var(--primary-color) !important;
}

/* Make sure publication page headings are also green */
.publications h1,
.publications h2,
.publications h3,
.publications h4,
.page__content h1,
.page__content h2,
.page__content h3,
.page__content h4 {
    color: var(--primary-color) !important;
}

/* Publication titles should be bold */
.page__content strong,
.page__content b,
.archive strong,
.archive b,
.publications strong,
.publications b,
.page__content li strong,
.archive li strong {
    font-weight: 700 !important;
    color: var(--primary-color) !important;
}

/* Publication paper titles (wrapped in ** **) */
.page__content p strong,
.archive p strong,
.page__content li strong,
.archive li strong {
    font-weight: bold !important;
    color: var(--primary-color) !important;
    font-size: 1.1em !important;
    display: inline-block !important;
    margin-bottom: 0.25rem !important;
}

/* Force bold for any text between ** ** in publications */
.page__content li,
.archive li {
    font-weight: normal !important;
}

/* Target text that should be bold in publication list items */
.page__content ol li:before {
    content: none !important;
}

.page__content ol li {
    margin-bottom: 1.5rem !important;
    line-height: 1.6 !important;
}

/* Publication section formatting */
.page__content p {
    margin-bottom: 1.5rem !important;
}

/* Make publication section headings more prominent */
.page__content h2,
.archive h2 {
    font-weight: 700 !important;
    font-size: 1.8em !important;
    margin-top: 2rem !important;
    margin-bottom: 1rem !important;
    border-bottom: 2px solid var(--primary-color) !important;
    padding-bottom: 0.5rem !important;
}

/* Footer theming */
.page__footer,
.page__footer footer {
    background-color: var(--surface-color) !important;
    color: var(--text-secondary) !important;
    border-top: 1px solid var(--border-color) !important;
}

/* Content area theming */
.page__content,
.archive__item {
    background-color: var(--surface-color) !important;
    color: var(--text-primary) !important;
    padding: 1.5rem !important;
    border-radius: 10px !important;
    margin-bottom: 1rem !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s ease;
}

/* Dark theme specific adjustments */
[data-theme="dark"] .page__content,
[data-theme="dark"] .archive__item {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

/* REMOVE aggressive font override - let pages use their natural fonts */
