/* 
 * StackBlog Plus - v7.0 Final
 * 修复：毛玻璃质感、代码高亮配色、灯箱层级
 */

:root {
    --primary-color: #0077cc;       
    --primary-hover: #005999;       
    --accent-color: #f48225;        
    
    --bg-body: #f0f2f5;             
    
    /* 🌟 核心修复：降低不透明度，让毛玻璃显现 */
    --bg-glass: rgba(255, 255, 255, 0.65); 
    --bg-glass-hover: rgba(255, 255, 255, 0.85);
    --backdrop-blur: blur(25px); /* 加强模糊 */
    
    --text-main: #24292e; 
    --text-sec: #586069;
    
    /* 增加边框高光，增强质感 */
    --border-glass: 1px solid rgba(255, 255, 255, 0.6);
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.03);
    --shadow-md: 0 12px 24px rgba(0,0,0,0.08);
    --radius-md: 12px;
}

[data-theme="dark"] {
    --bg-body: #0d1117;
    --bg-glass: rgba(22, 27, 34, 0.65);
    --bg-glass-hover: rgba(30, 36, 46, 0.8);
    --text-main: #c9d1d9;
    --text-sec: #8b949e;
    --border-glass: 1px solid rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.4);
}

body {
    background-color: var(--bg-body);
    /* 加强背景光斑对比度，让毛玻璃更明显 */
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 119, 204, 0.1) 0%, transparent 40%), 
        radial-gradient(circle at 90% 80%, rgba(244, 130, 37, 0.1) 0%, transparent 40%);
    background-attachment: fixed;
    margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}
a { text-decoration: none !important; transition: 0.2s; }

/* === 核心组件玻璃化 === */
.card, .so-question-summary, .so-sidebar, .widget, .so-question-detail, .so-comments-section, .so-toc-card, #vcomment .vwrap {
    backdrop-filter: var(--backdrop-blur) !important;
    -webkit-backdrop-filter: var(--backdrop-blur) !important;
    border: var(--border-glass) !important;
    box-shadow: var(--shadow-sm) !important;
    border-radius: var(--radius-md) !important;
    transition: all 0.3s ease;
}

/* === 顶部导航 === */
.so-header {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    height: 60px; display: flex; align-items: center;
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
}
[data-theme="dark"] .so-header { background: rgba(22, 27, 34, 0.8) !important; }

.so-header-content { display: flex; align-items: center; width: 96%; max-width: 1600px; margin: 0 auto; padding: 0 15px; }
.so-logo { font-weight: 700; color: var(--text-main) !important; font-size: 1.2rem; margin-right: 30px; white-space: nowrap; }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; color: var(--text-sec); cursor: pointer; margin-right: 15px; }

/* 导航链接 */
.so-nav-link, .so-sidebar-link {
    display: inline-flex; align-items: center; padding: 6px 14px !important;
    color: var(--text-sec) !important; font-weight: 500; border-radius: 20px !important;
    transition: all 0.2s ease; border: 1px solid transparent;
}
.so-nav-list { display: flex; gap: 5px; list-style: none; margin: 0; padding: 0; }
.so-nav-link.active, .so-nav-link:hover, .so-sidebar-link.active, .so-sidebar-link:hover {
    background-color: var(--primary-color) !important; color: #fff !important;
    box-shadow: 0 4px 10px rgba(0, 119, 204, 0.2); transform: translateY(-1px);
}

/* 搜索框 */
.so-search { margin-left: auto; }
.so-search-input {
    background: rgba(255,255,255,0.5) !important; 
    border: 1px solid rgba(0,0,0,0.1) !important;
    border-radius: 20px !important; padding: 6px 15px !important; height: 34px; width: 220px;
    color: var(--text-main); transition: width 0.3s ease;
}
.so-search-input:focus {
    background: #fff !important; border-color: var(--primary-color) !important; width: 280px;
    box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.1);
}

/* === 布局系统 Grid === */
.so-container {
    padding-top: 80px; width: 96%; max-width: 1600px; margin: 0 auto;
    display: grid; 
    grid-template-columns: 240px 1fr; 
    gap: 25px; align-items: start;
}

/* 侧边栏 */
.so-sidebar {
    position: sticky; top: 80px; height: calc(100vh - 100px);
    overflow-y: auto; padding: 20px !important; 
}
.so-sidebar-link { display: flex; align-items: center; width: 100%; margin-bottom: 5px; background: transparent !important; gap: 10px; padding: 8px 12px !important; }
.so-sidebar-link:hover { background: var(--primary-color) !important; }
.sort-icon { font-size: 18px; display: inline-flex; align-items: center; justify-content: center; min-width: 24px; }
.sort-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* === 文章详情布局 === */
.so-log-layout {
    display: grid;
    grid-template-columns: 1fr 280px; 
    gap: 25px; width: 100%; align-items: start;
}
.so-log-left {
    min-width: 0; width: 100%;
}
.so-log-right {
    position: sticky; top: 80px; z-index: 10;
}

/* 文章内容 */
.so-question-detail { padding: 20px !important; margin-bottom: 25px; }
.so-question-title {
    font-size: 1.8rem !important; font-weight: 600 !important; color: var(--text-main) !important;
    line-height: 1.4 !important; margin-bottom: 15px !important;
}
.so-post-content {
    font-size: 16px; line-height: 1.8; color: var(--text-main);
    word-wrap: break-word;
}
.so-post-content img { max-width: 100%; height: auto; border-radius: 8px; cursor: zoom-in; }

/* === 代码高亮 (One Dark 风格 + 自动换行) === */
/* 核心修复：恢复高亮颜色，同时保持布局稳定 */
pre {
    display: block;
    color: #abb2bf !important;
    padding: 40px 15px 15px 15px !important; 
    border-radius: 8px !important;
    font-family: 'Consolas', 'Monaco', monospace !important;
    font-size: 14px;
    line-height: 1.5;
    margin: 20px 0 !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
    position: relative !important;
    
    /* 🌟 既换行又保留高亮结构 */
    white-space: pre-wrap !important; 
    word-wrap: break-word !important;
    max-width: 100% !important; 
}

/* Mac 风格圆点 */
pre::before {
    content: ''; position: absolute; top: 15px; left: 15px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #fc625d; box-shadow: 18px 0 0 #fdbc40, 36px 0 0 #35cd4b;
}

/* Token 颜色 (找回丢失的高亮) */
.token.comment { color: #5c6370 !important; font-style: italic; }
.token.keyword { color: #c678dd !important; }
.token.string { color: #98c379 !important; }
.token.number { color: #d19a66 !important; }
.token.function { color: #61afef !important; }
.token.tag { color: #e06c75 !important; }
.token.operator { color: #56b6c2 !important; }
.token.punctuation { color: #abb2bf !important; }
.token.attr-name { color: #d19a66 !important; }

.copy-code-btn {
    position: absolute; top: 10px; right: 10px;
    background: rgba(255,255,255,0.1); color: #999;
    border: 1px solid rgba(255,255,255,0.1); border-radius: 4px;
    padding: 2px 8px; font-size: 12px; cursor: pointer; z-index: 10;
}
.copy-code-btn:hover { background: var(--primary-color); color: #fff; }

/* === 目录美化 === */
.so-toc-card { padding: 0 !important; overflow: hidden; max-height: 80vh; }
.so-toc-header { padding: 12px 15px; background: rgba(0,0,0,0.02); border-bottom: 1px solid var(--border-glass); }
.so-toc-header h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-main); }
.so-toc-list { list-style: none; padding: 10px 0; margin: 0; overflow-y: auto; max-height: 65vh; }
.so-toc-link {
    display: block; padding: 6px 15px; color: var(--text-sec); font-size: 13px;
    border-left: 3px solid transparent; transition: all 0.2s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.so-toc-link:hover, .so-toc-link.active {
    color: var(--primary-color); background: rgba(0, 119, 204, 0.05);
    border-left-color: var(--primary-color);
}
.so-toc-item.level-3 .so-toc-link { padding-left: 25px; }

/* === 表情面板 (修复：位置和层级) === */
.comment-editor { position: relative; z-index: 20; }
.emoji-panel {
    display: none; position: fixed; bottom: auto; left: auto; top: 50%; right: 50%;
    transform: translate(50%, -50%);
    width: 340px; max-height: 280px; overflow-y: auto;
    background: var(--bg-main); border: 1px solid var(--border-color); border-radius: 12px;
    padding: 15px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 99999; flex-wrap: wrap; gap: 10px; margin-bottom: 0;
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
    from { opacity: 0; transform: translate(50%, -40%); }
    to { opacity: 1; transform: translate(50%, -50%); }
}
.emoji-panel.show { display: flex; }
.emoji-item {
    font-size: 28px; cursor: pointer; padding: 8px;
    user-select: none; border-radius: 6px;
    transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
}
.emoji-item:hover {
    transform: scale(1.15) rotate(5deg);
    background: var(--bg-hover);
}

/* === 浮动按钮 === */
.so-floating-buttons {
    position: fixed; right: 20px; bottom: 40px; z-index: 99999;
    display: flex; flex-direction: column !important; 
    align-items: flex-end; gap: 12px !important; pointer-events: none;
}
.so-back-to-top, .tools-floating-icon {
    width: 44px; height: 44px; background: var(--bg-glass); backdrop-filter: blur(10px);
    border: var(--border-glass); color: var(--text-main); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: var(--shadow-md); transition: all 0.3s; pointer-events: auto;
    position: static !important;
}
.tools-floating-icon { background: var(--primary-color); color: #fff; opacity: 1; visibility: visible; }
.so-back-to-top { opacity: 0; visibility: hidden; }
.so-back-to-top.show { opacity: 1; visibility: visible; }
.so-back-to-top:hover { background: var(--primary-color); color: #fff; transform: translateY(-5px); }

/* === 灯箱层级 (最高) === */
.so-lightbox-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95); z-index: 2147483647;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; visibility: hidden; transition: all 0.3s; cursor: zoom-out;
}
.so-lightbox-overlay.active { opacity: 1; visibility: visible; }
.so-lightbox-img { max-width: 95%; max-height: 95%; box-shadow: 0 0 30px rgba(0,0,0,0.5); transform: scale(0.9); transition: transform 0.3s; }
.so-lightbox-overlay.active .so-lightbox-img { transform: scale(1); }

/* === 移动端适配 === */
@media (max-width: 1024px) {
    .so-container { grid-template-columns: 1fr; width: 100%; padding: 70px 10px 10px; }
    .so-sidebar { display: none; } 
    .so-log-layout { grid-template-columns: 1fr; }
    .so-log-right { display: none !important; }
    .mobile-menu-btn { display: block; }
    
    .so-sidebar.active {
        display: block; position: fixed; top: 0; left: 0;
        width: 260px; height: 100vh; z-index: 2147483647;
        box-shadow: 2px 0 20px rgba(0,0,0,0.1);
        /* 移动端侧边栏背景必须不透明，否则看不清 */
        background: var(--bg-body) !important; 
    }
}
@media (max-width: 768px) {
    .so-question-summary { flex-direction: column; }
    .so-image-container { width: 100%; height: 160px; margin-bottom: 10px; }
    .so-vote-cell { display: none; }
    pre { padding: 40px 10px 10px 10px !important; font-size: 13px; }
}