/* ===================================================================
   RESEARCH BLOG SPECIFIC STYLES — blog.html
   =================================================================== */

body {
    font-family: "Inter Tight", "Neue Haas Grotesk", "Sarabun", sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

.container {
    display: flex;
    height: 100vh;
    max-width: 100%;
    position: relative;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 30%;
    min-width: 320px;
    max-width: 400px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 20;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    border: none;
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    position: relative;
}

.header-actions {
    position: absolute;
    top: 20px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
}

.icon-btn:hover {
    background: var(--bg-paper-list);
    color: var(--text-main);
}

.sidebar-open-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 30;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
}

.container.sidebar-hidden .sidebar-open-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

/* --- MAIN CONTENT READING VIEW --- */
.main-content {
    flex: 1;
    padding: clamp(24px, 5vw, 40px) clamp(16px, 4vw, 32px) 48px;
    overflow-y: auto;
    background: var(--bg-body);
    position: relative;
    scroll-behavior: smooth;
}

.brand {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 20px;
    transition: color 0.2s;
    max-width: 60%;
}

.brand:hover {
    color: var(--primary);
}

/* --- SEARCH & FILTERS --- */
.search-container {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: "Inter Tight", sans-serif;
    font-size: 0.88rem;
    background: var(--bg-body);
    color: var(--text-main);
    outline: none;
    transition: all 0.2s ease;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--border-strong);
    background: var(--bg-card);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-muted);
}

.filter-tags-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
    font-weight: 700;
    font-family: 'Inter', monospace;
}

.filter-tags-wrapper {
    position: relative;
}

.filter-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-tag {
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-paper-list);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-weight: 500;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.filter-tag:hover {
    background: var(--border-color);
    color: var(--text-main);
}

.filter-tag.active {
    background: var(--text-main);
    color: var(--bg-card);
    border-color: var(--text-main);
}

.tag-count {
    font-size: 0.6rem;
    opacity: 0.7;
    font-weight: 600;
    font-family: "Inter Tight", monospace;
}

.filter-tag.more-btn {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
}

.filter-tag.more-btn:hover {
    border-style: solid;
    background: var(--bg-paper-list);
    color: var(--text-main);
}

.filter-tag.more-btn.open {
    border-style: solid;
    background: var(--bg-paper-list);
    color: var(--text-main);
}

.more-tags-dropdown {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px;
    margin-top: 8px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    animation: dropdownFade 0.2s ease;
}

.more-tags-dropdown.open {
    display: flex;
}

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

.active-filters-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    margin-left: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.active-filters-badge.visible {
    opacity: 1;
}

.clear-filters-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.clear-filters-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* --- ARTICLE LISTS --- */
.article-list-section {
    display: flex;
    flex-direction: column;
}

.articles-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 20px 24px 8px;
    font-weight: 700;
    font-family: 'Inter', monospace;
}

.article-list-item {
    display: block;
    padding: 14px 24px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    border-left: 3px solid transparent;
}

.article-list-item:hover {
    background-color: #49628d;
    color: #F0EDE5;
    border-left-color: #F0EDE5;
}

.article-list-item:hover .list-title {
    color: #F0EDE5;
}

.article-list-item:hover .list-meta {
    color: #cbd5e1;
}

.article-list-item.active {
    background: var(--bg-paper-list);
    border-left: 3px solid var(--text-main);
    font-weight: 600;
    color: var(--text-main);
}

.article-list-item.active:hover {
    background-color: #49628d;
    color: #F0EDE5;
    border-left-color: #F0EDE5;
}

.article-list-item.active:hover .list-title {
    color: #F0EDE5;
}

.article-list-item.active:hover .list-meta {
    color: #cbd5e1;
}

.list-title {
    font-size: 0.85rem;
    line-height: 1.4;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.list-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Inter', monospace;
}

.pagination-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 50px;
    text-align: center;
    font-family: 'Inter', monospace;
}

/* --- READING VIEW --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.5;
    background: var(--bg-sidebar);
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-color);
}

.article-view {
    max-width: 900px;
    margin: 0 auto;
    display: none;
    position: relative;
}

.article-view.visible {
    display: block;
    animation: articleSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes articleSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-navigation {
    display: flex;
    gap: 6px;
}

.nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.nav-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Inter', monospace;
}

.citation-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    margin-left: auto;
    font-weight: 500;
}

.citation-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.article-title {
    font-family: 'Inter', 'Sarabun', sans-serif;
    font-size: clamp(1.35rem, 3.5vw, 1.65rem);
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 20px;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.tags-container {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

.tag-badge {
    display: inline-block;
    background: var(--bg-paper-list);
    color: var(--text-secondary);
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: "Inter Tight", sans-serif;
    border: 1px solid var(--border);
    transition: all 0.2s;
    cursor: pointer;
}

.tag-badge:hover {
    border-color: var(--border-strong);
    color: var(--text-main);
}

.research-section {
    margin-bottom: 32px;
}

.sec-header {
    font-family: "Inter Tight", sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sec-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.sec-content {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.75;
    text-align: justify;
}

.sec-content strong {
    color: var(--text-main);
    font-weight: 600;
}

/* --- TABLE OF CONTENTS (ToC) --- */
.toc-container {
    position: fixed;
    right: 24px;
    top: 96px;
    width: 180px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: none;
    z-index: 100;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.toc-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
    font-family: "Inter Tight", monospace;
}

.toc-link {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 0;
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 2px solid transparent;
}

.toc-link:hover {
    color: var(--primary);
    padding-left: 4px;
}

.toc-link.active {
    color: var(--text-main);
    font-weight: 700;
    border-left: 2px solid var(--text-main);
    padding-left: 6px;
}

/* --- RELATED PAPERS --- */
.related-papers-section {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.related-header {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.related-card {
    background: var(--bg-surface);
    padding: 16px 16px 16px 13px; /* offset padding for 3px left border sentinel */
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    border-left: 3px solid transparent;
}

.related-card:hover {
    background-color: #49628d;
    border-color: #49628d;
    border-left-color: #F0EDE5;
    color: #F0EDE5;
}

.related-card:hover .related-title,
.related-card:hover .related-date {
    color: #F0EDE5;
}

.related-title {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: "Inter Tight", monospace;
}

.pubmed-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 36px;
    color: var(--bg-card);
    background: var(--text-main);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.82rem;
    transition: all 0.2s ease;
    border: 1px solid var(--text-main);
}

.pubmed-link:hover {
    background: var(--text-secondary);
    border-color: var(--text-secondary);
}

/* --- MOBILE DRAWER LAYOUT --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 950;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 1024px) {
    .container {
        height: 100vh;
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 300px;
        max-width: 85%;
        height: 100%;
        max-height: none;
        z-index: 1000;
        border-right: 1px solid var(--border-color);
        transform: translateX(0);
        opacity: 1;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        opacity: 0;
    }

    .sidebar-open-btn {
        display: flex !important;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 900;
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateX(0) !important;
    }

    #sidebar-close-btn {
        display: flex !important;
    }

    .header-actions {
        position: static;
        display: flex;
        margin-left: auto;
    }

    .sidebar-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
    }

    .brand {
        margin-bottom: 8px;
        flex-shrink: 0;
        max-width: 70%;
    }

    .search-container {
        width: 100%;
        margin-bottom: 4px;
    }

    .filter-tags-label {
        margin-bottom: 6px;
    }

    .filter-tags-wrapper {
        margin-bottom: 4px;
    }

    .filter-tags {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 8px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filter-tags::-webkit-scrollbar {
        display: none;
    }

    .main-content {
        padding-top: 72px;
        height: 100vh;
        overflow-y: auto;
    }
}

@media (max-width: 640px) {
    .sidebar-header {
        padding: 16px;
    }

    .article-list-item {
        padding: 12px 16px;
    }
}
