/*
Theme Name: Minimal SEO Theme Masterpiece
Version: 1.0.0
Author: Gemini
Description: Optimized Layout, Performance, and UX.
*/

/* --- CSS 变量 --- */
:root {
    --bg-color: #ffffff; 
    --surface-color: #ffffff; 
    --text-main: #1a202c; 
    --text-muted: #4a5568; 
    --border-color: #eaecef; 
    --accent: #3eaf7c; 
    --accent-hover: #33a06f;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04); 
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.08);
    --radius: 8px; 
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-color: #1e1e20; 
    --surface-color: #1e1e20; 
    --text-main: #fffff5; 
    --text-muted: #ebebf599; 
    --border-color: #3a3a3c; 
    --accent: #10b981; 
}

/* --- 基础重置 --- */
html { scroll-behavior: smooth; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: var(--bg-color); color: var(--text-main); line-height: 1.7; -webkit-font-smoothing: antialiased; transition: background-color var(--transition), color var(--transition); overflow-x: hidden; }
a, button { outline: none; text-decoration: none; color: var(--text-main); transition: var(--transition); }
img, video, iframe { max-width: 100%; height: auto; border-radius: var(--radius); display: block; }
p, h1, h2, h3, h4, h5, h6, li { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; }

/* 无障碍 */
.screen-reader-text { border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute !important; width: 1px; word-wrap: normal !important; }
.skip-link { position: absolute; top: -100px; left: 0; padding: 8px 16px; background: var(--accent); color: #fff; z-index: 999; transition: top 0.3s; }
.skip-link:focus { top: 0; }

/* --- 布局容器 --- */
.container { max-width: 740px; margin: 0 auto; padding: 0 24px; }
.reading-progress-bar { position: fixed; top: 0; left: 0; height: 3px; background-color: var(--accent); z-index: 10000; width: 0%; transition: width 0.1s ease-out; }

/* --- 头部与导航 --- */
.site-header { padding: 30px 0; border-bottom: 1px solid var(--border-color); margin-bottom: 40px; position: relative; z-index: 100; }
.header-inner { display: flex; justify-content: space-between; align-items: center; position: relative; gap: 30px; }
.header-brand { flex-shrink: 0; }
.site-title { font-size: 1.5rem; font-weight: 700; }
.site-title a:hover { color: var(--accent); }

.site-nav { display: flex; align-items: center; flex: 1; justify-content: flex-end; }
.nav-list { list-style: none; display: flex; gap: 28px; margin: 0; padding: 0; }
.nav-list a { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); position: relative; padding: 5px 0; }
.nav-list a:hover, .nav-list .current-menu-item > a { color: var(--text-main); }
.nav-list a::after { content: ''; position: absolute; left: 0; bottom: 0; width: 0; height: 2px; background: var(--accent); transition: width 0.3s ease; }
.nav-list a:hover::after, .nav-list .current-menu-item > a::after { width: 100%; }

.header-actions { display: flex; align-items: center; gap: 15px; flex-shrink: 0; }
.search-toggle { background: none; border: none; cursor: pointer; color: var(--text-main); padding: 5px; display: flex; }
.search-toggle svg { width: 22px; height: 22px; transition: color 0.2s; }
.search-toggle:hover svg { color: var(--accent); }

/* --- 搜索组件 --- */
.search-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.96); z-index: 99999; display: flex; justify-content: center; align-items: flex-start; opacity: 0; visibility: hidden; transition: all 0.3s ease; backdrop-filter: blur(8px); padding-top: 20vh; }
[data-theme="dark"] .search-overlay { background: rgba(30,30,32,0.96); }
.search-overlay.active { opacity: 1; visibility: visible; }
.search-container { width: 100%; max-width: 680px; padding: 0 24px; transform: translateY(-20px); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.search-overlay.active .search-container { transform: translateY(0); }
.search-form { display: flex; align-items: center; border-bottom: 2px solid var(--border-color); padding-bottom: 12px; }
.search-form .search-icon { width: 28px; height: 28px; color: var(--text-muted); flex-shrink: 0; }
.search-field { flex: 1; background: transparent; border: none; font-size: 2rem; color: var(--text-main); padding: 0 20px; outline: none; font-weight: 700; width: 100%; -webkit-appearance: none; }
.search-field::placeholder { color: var(--text-muted); opacity: 0.5; }
.search-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 5px; flex-shrink: 0; transition: all 0.2s; }
.search-close:hover { color: var(--accent); transform: rotate(90deg); }
.search-close svg { width: 32px; height: 32px; }

/* --- 首页列表与分页 --- */
.breadcrumbs { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 18px; }
.post-list { display: flex; flex-direction: column; gap: 40px; }
.post-item { padding: 0 0 40px 0; border-bottom: 1px solid var(--border-color); }
.post-item:last-child { border-bottom: none; }
.post-meta { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; font-weight: 500; }
.post-item h2 { font-size: 1.6rem; margin-bottom: 12px; line-height: 1.4; font-weight: 700; }
.post-item h2 a:hover { color: var(--accent); }
.post-excerpt { color: var(--text-muted); font-size: 1rem; }

.modern-tags { display: flex; flex-wrap: wrap; gap: 10px; margin: 40px 0; }
.modern-tags a { background: rgba(0,0,0,0.03); color: var(--text-muted); padding: 4px 12px; border-radius: 4px; font-size: 0.85rem; }
[data-theme="dark"] .modern-tags a { background: rgba(255,255,255,0.05); }
.modern-tags a:hover { color: var(--accent); }

.pagination { margin: 60px 0; text-align: center; }
.pagination .nav-links { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; }
.pagination .page-numbers { display: flex; justify-content: center; align-items: center; width: 40px; height: 40px; border-radius: 4px; color: var(--text-muted); font-weight: 500; font-size: 0.95rem; }
.pagination a.page-numbers:hover { background-color: rgba(0,0,0,0.03); color: var(--text-main); }
[data-theme="dark"] .pagination a.page-numbers:hover { background: rgba(255,255,255,0.05); }
.pagination .current { background-color: var(--accent); color: #fff; }
.pagination .prev svg, .pagination .next svg { width: 20px; height: 20px; transition: transform 0.3s; }
.pagination a.prev:hover svg { transform: translateX(-4px); }
.pagination a.next:hover svg { transform: translateX(4px); }

/* --- 单页引擎 (Grid) --- */
.single-container { width: 100%; max-width: 100%; padding: 0; }
.single-layout-wrapper { display: grid; grid-template-columns: minmax(20px, 1fr) minmax(auto, 740px) minmax(20px, 1fr); width: 100%; margin: 0 auto; }
.single-spacer { grid-column: 1; }
.single-main-col { grid-column: 2; min-width: 0; width: 100%; padding: 0 24px; }
.single-sidebar { grid-column: 3; width: 260px; padding-left: 40px; position: sticky; top: 80px; height: max-content; z-index: 10; }
.sidebar-inner { max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 10px; }
.sidebar-inner::-webkit-scrollbar { width: 4px; }
.sidebar-inner::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
.sidebar-inner:hover::-webkit-scrollbar-thumb { background: var(--border-color); }

/* --- 正文排版 --- */
.single-header { margin-bottom: 40px; }
.single-header h1 { font-size: 2.2rem; line-height: 1.35; margin-bottom: 16px; font-weight: 800; letter-spacing: -0.01em; }
.single-header .post-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--text-muted); font-size: 0.85rem; }
.single-header .post-meta .meta-item { display: inline-flex; align-items: center; gap: 5px; }
.single-header .post-meta .meta-sep { opacity: 0.5; margin: 0 2px; }
.single-header .post-meta svg { width: 14px; height: 14px; }

.entry-content { font-size: 1.05rem; color: var(--text-main); }
.entry-content p { margin-bottom: 1.5em; }
.entry-content h2 { margin: 2.5em 0 1em; font-size: 1.6rem; font-weight: 700; padding-bottom: 0.3em; border-bottom: 1px solid var(--border-color); scroll-margin-top: 80px; }
.entry-content h3 { margin: 2em 0 1em; font-size: 1.3rem; font-weight: 600; scroll-margin-top: 80px; }
.entry-content table { width: 100%; border-collapse: collapse; margin: 2em 0; font-size: 0.95rem; overflow-x: auto; display: block; border: 1px solid var(--border-color); border-radius: 4px; }
.entry-content th, .entry-content td { padding: 12px 16px; border: 1px solid var(--border-color); }
.entry-content th { background-color: rgba(0,0,0,0.02); font-weight: 600; }
[data-theme="dark"] .entry-content th { background-color: rgba(255,255,255,0.02); }

.wp-block-button { margin: 2em 0; }
.wp-block-button__link { background-color: var(--accent) !important; color: #fff !important; border-radius: 4px !important; padding: 12px 24px !important; font-size: 1rem !important; font-weight: 500 !important; border: none !important; }
.wp-block-button__link:hover { background-color: var(--accent-hover) !important; }

/* --- 底部与声明 --- */
.custom-disclaimer { background-color: rgba(0,0,0,0.03); border-radius: var(--radius); padding: 20px 24px; margin: 40px 0; font-size: 0.95rem; border-left: 4px solid #3b82f6; }
[data-theme="dark"] .custom-disclaimer { background-color: rgba(255,255,255,0.04); }
.disclaimer-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; color: #3b82f6; font-size: 1rem; }
.disclaimer-title svg { width: 18px; height: 18px; }

.article-end-meta { text-align: right; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: 20px 0; margin-top: 40px; font-size: 0.85rem; color: var(--text-muted); }
.post-nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 40px; margin-bottom: 60px; }
.nav-card { border: 1px solid var(--border-color); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; }
.nav-card:hover { border-color: var(--accent); }
.nav-card.empty-card { border: none; pointer-events: none;}
.nav-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.nav-title { font-size: 1.05rem; font-weight: 600; color: var(--accent); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prev-card { text-align: left; }
.next-card { text-align: right; }

/* --- 目录指示 --- */
.minimal-toc { margin: 0; font-size: 0.9rem; }
.toc-title { font-weight: 700; margin-bottom: 12px; color: var(--text-main); font-size: 0.95rem; }
.minimal-toc .toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border-color); }
.minimal-toc .toc-list a { display: block; color: var(--text-muted); padding: 6px 16px; position: relative; border-left: 2px solid transparent; margin-left: -1px; }
.minimal-toc .toc-list a:hover { color: var(--text-main); }
.minimal-toc .toc-list a.active { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.minimal-toc .toc-h3 a { padding-left: 32px; font-size: 0.85rem; }

/* --- 悬浮组件 --- */
.floating-tools { position: fixed; bottom: 40px; right: 40px; display: flex; flex-direction: column; gap: 12px; z-index: 900; }
.floating-tools button { width: 44px; height: 44px; border-radius: 50%; background-color: var(--surface-color); border: 1px solid var(--border-color); color: var(--text-muted); cursor: pointer; display: flex; justify-content: center; align-items: center; box-shadow: var(--shadow-sm); transition: var(--transition); }
.floating-tools button:hover { color: var(--accent); box-shadow: var(--shadow-hover); }
.floating-tools button.hidden { opacity: 0; visibility: hidden; transform: translateY(15px); pointer-events: none; }
.floating-tools button svg { width: 20px; height: 20px; }
.mobile-only { display: none !important; } 

#theme-toggle svg { fill: currentColor; }
#theme-toggle .moon-icon { display: none; } 
[data-theme="dark"] #theme-toggle .sun-icon { display: none; } 
[data-theme="dark"] #theme-toggle .moon-icon { display: block; } 

.site-footer { text-align: center; padding: 40px 0 60px; font-size: 0.9rem; color: var(--text-muted); border-top: 1px solid var(--border-color); }

/* --- 灯箱 --- */
.lightbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 99999; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: opacity 0.3s ease; backdrop-filter: blur(5px); cursor: zoom-out; }
.lightbox-overlay.show { opacity: 1; visibility: visible; }
.lightbox-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,0.4); pointer-events: none; }
.lightbox-overlay.show img { transform: scale(1); }

/* --- 移动端抽屉 --- */
.unified-mobile-drawer { display: none; position: fixed; top: 0; right: -320px; width: 300px; height: 100vh; background-color: var(--surface-color); z-index: 1001; box-shadow: -4px 0 15px rgba(0,0,0,0.05); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); flex-direction: column; }
.drawer-inner { padding: 40px 24px; overflow-y: auto; height: 100%; }
.drawer-section { margin-bottom: 30px; padding-bottom: 30px; border-bottom: 1px dashed var(--border-color); }
.drawer-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.drawer-title { font-size: 0.95rem; font-weight: 700; color: var(--text-main); margin-bottom: 16px; text-transform: uppercase; }
.drawer-nav-list { list-style: none; margin: 0; padding: 0; }
.drawer-nav-list li { margin-bottom: 16px; }
.drawer-nav-list a { font-size: 1.1rem; font-weight: 600; color: var(--text-main); }
.drawer-nav-list a:hover { color: var(--accent); }
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.3s ease; backdrop-filter: blur(2px); }

/* --- 响应式适配 --- */
@media (max-width: 1250px) {
    .single-layout-wrapper { display: flex; padding: 0 24px; gap: 40px; }
    .single-spacer { display: none; }
    .single-main-col { flex: 1; padding: 0; }
    .single-sidebar { padding-left: 0; width: 240px; }
}

@media (max-width: 992px) {
    .site-nav, .single-sidebar { display: none; }
    .mobile-only, .unified-mobile-drawer { display: flex !important; }
    
    body.drawer-open { overflow: hidden; }
    body.drawer-open .unified-mobile-drawer { transform: translateX(-320px); }
    body.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }
    
    .single-layout-wrapper { flex-direction: column; padding: 0 24px; }
    .floating-tools { bottom: 20px; right: 20px; }
    .post-nav-links { grid-template-columns: 1fr; gap: 15px; }
    .next-card { text-align: left; }
    .search-field { font-size: 1.2rem; }
    .search-overlay { padding-top: 10vh; }
}

/* --- 性能优化 (渲染干预) --- */
.post-item, .nav-card { content-visibility: auto; contain-intrinsic-size: 100px 300px; }
.entry-content img, .entry-content table { content-visibility: auto; }