/*
Theme Name: QNTLab
Description: Minimal technical knowledge sharing theme
Version: 1.0
Author: QNTLab
Text Domain: qntlab
*/

:root {
  --bg: #fafafa; --surface: #fff; --text: #1a1a2e; --text2: #555;
  --accent: #2563eb; --accent-hover: #1d4ed8; --border: #e5e7eb;
  --code-bg: #f3f4f6; --max-w: 720px; --nav-h: 56px;
}
[data-theme="dark"] {
  --bg: #0f172a; --surface: #1e293b; --text: #e2e8f0; --text2: #94a3b8;
  --accent: #60a5fa; --accent-hover: #93bbfd; --border: #334155;
  --code-bg: #1e293b;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; }

/* nav */
.site-nav { position: sticky; top: 0; z-index: 100; background: var(--surface); border-bottom: 1px solid var(--border); height: var(--nav-h); display: flex; align-items: center; padding: 0 1.5rem; }
.site-nav .logo { font-size: 1.25rem; font-weight: 700; color: var(--text); text-decoration: none; }
.site-nav .links { margin-left: auto; display: flex; gap: 1.5rem; }
.site-nav .links a { color: var(--text2); text-decoration: none; font-size: 0.9rem; transition: color .2s; }
.site-nav .links a:hover, .site-nav .links a.current { color: var(--accent); }

/* layout */
.container { max-width: var(--max-w); margin: 0 auto; padding: 2rem 1.5rem; }
.wide { max-width: 1100px; }

/* index layout */
.index-layout { display: grid; grid-template-columns: 1fr 200px; gap: 2.5rem; max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem; }
.index-main { min-width: 0; }
.index-sidebar { position: relative; }
.tag-filter { position: sticky; top: calc(var(--nav-h) + 1.5rem); }
.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-list .tag { cursor: pointer; transition: all .2s; }
.tag-list .tag-active { background: var(--accent); color: #fff; }
.tag-count { font-size: .7rem; opacity: .7; }
@media (max-width: 860px) { .index-layout { grid-template-columns: 1fr; } .index-sidebar { order: -1; } .tag-filter { position: static; } }

/* index */
.post-list { list-style: none; }
.post-item { padding: 1.5rem 0; border-bottom: 1px solid var(--border); }
.post-item:last-child { border-bottom: none; }
.post-item h2 { font-size: 1.3rem; margin-bottom: .3rem; }
.post-item h2 a { color: var(--text); text-decoration: none; }
.post-item h2 a:hover { color: var(--accent); }
.post-meta { font-size: .85rem; color: var(--text2); margin-bottom: .4rem; }
.post-summary { color: var(--text2); font-size: .95rem; }
.ai-badge { display: inline-block; font-size: .7rem; font-weight: 600; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; padding: .1rem .4rem; border-radius: 3px; margin-right: .4rem; vertical-align: middle; letter-spacing: .03em; }
.tag { display: inline-block; background: var(--code-bg); color: var(--accent); padding: .1rem .5rem; border-radius: 3px; font-size: .8rem; margin-right: .3rem; text-decoration: none; }
.tag:hover { background: var(--accent); color: #fff; }

/* article */
.article-header { margin-bottom: 2rem; }
.article-header h1 { font-size: 2rem; line-height: 1.3; margin-bottom: .5rem; }
.article-body h2 { font-size: 1.4rem; margin: 2rem 0 .8rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); }
.article-body h3 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.article-body h4 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.article-body p { margin-bottom: 1rem; }
.article-body a { color: var(--accent); }
.article-body img { max-width: 100%; border-radius: 6px; margin: 1rem 0; }
.article-body blockquote { border-left: 3px solid var(--accent); padding: .5rem 1rem; margin: 1rem 0; color: var(--text2); background: var(--code-bg); border-radius: 0 4px 4px 0; }
.article-body ul, .article-body ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.article-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: .5rem .75rem; text-align: left; }
.article-body th { background: var(--code-bg); }

/* code */
.article-body code { font-family: "JetBrains Mono", "Fira Code", monospace; font-size: .88rem; background: var(--code-bg); padding: .15rem .35rem; border-radius: 3px; }
.article-body pre { background: #1e293b; color: #e2e8f0; padding: 1rem 1.25rem; border-radius: 6px; overflow-x: auto; margin: 1rem 0; }
.article-body pre code { background: none; padding: 0; color: inherit; font-size: .85rem; }

/* toc */
.toc { position: sticky; top: calc(var(--nav-h) + 1.5rem); font-size: .85rem; max-height: calc(100vh - var(--nav-h) - 3rem); overflow-y: auto; }
.toc-title { font-weight: 600; margin-bottom: .5rem; color: var(--text2); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.toc ul { list-style: none; padding-left: 0; }
.toc ul ul { padding-left: .8rem; }
.toc a { color: var(--text2); text-decoration: none; display: block; padding: .2rem 0; }
.toc a:hover { color: var(--accent); }
.article-layout { display: grid; grid-template-columns: 1fr 200px; gap: 3rem; max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem; }
@media (max-width: 860px) { .article-layout { grid-template-columns: 1fr; } .toc { display: none; } }

/* gallery */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.gallery-item { border-radius: 8px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); transition: transform .2s; }
.gallery-item:hover { transform: translateY(-2px); }
.gallery-item img { width: 100%; display: block; }
.gallery-item .desc { padding: .6rem .8rem; font-size: .9rem; color: var(--text2); }

/* pagination */
.pagination { display: flex; justify-content: center; gap: .5rem; margin-top: 2rem; }
.pagination a, .pagination span { padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 4px; text-decoration: none; color: var(--text2); font-size: .9rem; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }

/* footer */
.site-footer { text-align: center; padding: 2rem; font-size: .8rem; color: var(--text2); border-top: 1px solid var(--border); margin-top: 3rem; }
.site-footer .icp { margin-left: .5rem; }
.site-footer .icp a { color: var(--text2); text-decoration: none; }
.site-footer .icp a:hover { color: var(--accent); }

/* page title */
.page-title { font-size: 1.6rem; margin-bottom: 1.5rem; }

/* 404 */
.not-found { text-align: center; padding: 4rem 1rem; }
.not-found h1 { font-size: 4rem; color: var(--border); }

/* lang switch */
.lang-switch { font-size: .8rem !important; padding: .15rem .5rem; border: 1px solid var(--border); border-radius: 3px; color: var(--text2) !important; transition: all .2s; }
.lang-switch:hover { border-color: var(--accent); color: var(--accent) !important; }

/* theme toggle */
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 3px; padding: .3rem .4rem; cursor: pointer; line-height: 0; color: var(--text2); transition: all .2s; display: inline-flex; align-items: center; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: none; }

/* dark mode overrides */
[data-theme="dark"] .article-body pre { background: #0f172a; }
[data-theme="dark"] .tag { background: var(--surface); }
