/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #020617; color: #e2e8f0; font-family: 'Inter', system-ui, -apple-system, sans-serif; min-height: 100vh; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* === Background Collage === */
.bg-collage { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.tile { position: absolute; border-radius: 10px; overflow: hidden; opacity: 0.15; filter: saturate(0.4) brightness(0.8); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-l1 { width: 200px; height: 150px; top: 20px; left: 10px; transform: rotate(-3deg); }
.tile-l2 { width: 180px; height: 220px; top: 200px; left: 30px; transform: rotate(2deg); }
.tile-l3 { width: 210px; height: 160px; top: 460px; left: 5px; transform: rotate(-1deg); }
.tile-l4 { width: 190px; height: 190px; top: 660px; left: 25px; transform: rotate(3deg); }
.tile-l5 { width: 200px; height: 170px; top: 890px; left: 10px; transform: rotate(-2deg); }
.tile-r1 { width: 190px; height: 180px; top: 40px; right: 15px; transform: rotate(2deg); }
.tile-r2 { width: 210px; height: 200px; top: 260px; right: 5px; transform: rotate(-3deg); }
.tile-r3 { width: 180px; height: 170px; top: 500px; right: 20px; transform: rotate(1deg); }
.tile-r4 { width: 200px; height: 210px; top: 710px; right: 10px; transform: rotate(-2deg); }
.tile-r5 { width: 190px; height: 160px; top: 960px; right: 25px; transform: rotate(2deg); }
.bg-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, rgba(2,6,23,0.7) 18%, rgba(2,6,23,0.95) 30%, rgba(2,6,23,1) 40%, rgba(2,6,23,1) 60%, rgba(2,6,23,0.95) 70%, rgba(2,6,23,0.7) 82%, transparent 100%),
    radial-gradient(ellipse at 50% 0%, rgba(139,92,246,0.05) 0%, transparent 50%);
}
.content-layer { position: relative; z-index: 2; }

/* === Nav === */
nav { position: sticky; top: 0; z-index: 50; background: rgba(2,6,23,0.8); backdrop-filter: blur(20px); border-bottom: 1px solid rgba(139,92,246,0.1); padding: 0 32px; }
.nav-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 64px; }
.nav-logo { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; background: linear-gradient(135deg, #a78bfa, #38bdf8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.nav-links { display: flex; gap: 28px; }
.nav-links a { color: #94a3b8; font-size: 14px; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: #e2e8f0; }
.nav-links a.active { color: #a78bfa; }

/* === Search === */
.search-toggle { background: none; border: 1px solid rgba(139,92,246,0.2); border-radius: 8px; color: #64748b; cursor: pointer; padding: 6px 8px; display: flex; align-items: center; transition: all 0.2s; }
.search-toggle:hover { color: #a78bfa; border-color: rgba(139,92,246,0.4); }
.search-overlay { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(2,6,23,0.7); backdrop-filter: blur(4px); align-items: flex-start; justify-content: center; padding-top: 100px; }
.search-overlay.active { display: flex; }
.search-modal { width: 580px; max-width: 92vw; max-height: 70vh; background: #0f172a; border: 1px solid rgba(139,92,246,0.2); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.search-input-wrap { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid #1e293b; }
.search-input-wrap svg { flex-shrink: 0; }
#search-input { flex: 1; background: none; border: none; outline: none; color: #e2e8f0; font-size: 16px; font-family: inherit; }
#search-input::placeholder { color: #475569; }
.search-kbd { font-size: 11px; color: #475569; background: rgba(30,41,59,0.6); border: 1px solid #1e293b; border-radius: 4px; padding: 2px 6px; font-family: inherit; }
.search-results { overflow-y: auto; padding: 8px; }
.search-result { display: block; padding: 14px 16px; border-radius: 10px; text-decoration: none; color: inherit; transition: background 0.15s; }
.search-result:hover { background: rgba(139,92,246,0.08); }
.search-result-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.search-date { font-size: 12px; color: #475569; }
.search-title { font-size: 15px; font-weight: 600; color: #e2e8f0; margin-bottom: 4px; }
.search-summary { font-size: 13px; color: #64748b; line-height: 1.5; }
.search-tags { display: flex; gap: 6px; margin-top: 8px; }
.search-tag { font-size: 11px; color: #64748b; background: rgba(51,65,85,0.4); padding: 2px 8px; border-radius: 4px; }
.search-hint { padding: 24px; text-align: center; color: #475569; font-size: 14px; }

/* === Hero === */
.hero { max-width: 1100px; margin: 0 auto; padding: 80px 32px 48px; }
.hero h1 { font-size: 42px; font-weight: 700; letter-spacing: -1px; line-height: 1.2; margin-bottom: 12px; }
.gradient-text { background: linear-gradient(135deg, #a78bfa, #38bdf8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero p { color: #64748b; font-size: 17px; line-height: 1.6; max-width: 560px; }

/* === Section Nav Pills === */
.section-nav { max-width: 1100px; margin: 0 auto; padding: 0 32px 32px; display: flex; gap: 10px; flex-wrap: wrap; }
.pill { padding: 6px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; border: 1px solid transparent; }
.pill.active { background: rgba(139,92,246,0.15); color: #a78bfa; border-color: rgba(139,92,246,0.3); }
.pill:not(.active) { background: rgba(30,41,59,0.5); color: #94a3b8; }
.pill:not(.active):hover { background: rgba(30,41,59,0.8); color: #e2e8f0; }

/* === Section Header (list pages) === */
.section-header { max-width: 1100px; margin: 0 auto; padding: 60px 32px 24px; }
.section-header h1 { font-size: 36px; font-weight: 700; letter-spacing: -0.8px; margin-bottom: 8px; }
.section-desc { color: #64748b; font-size: 16px; }

/* === Post Grid === */
.posts { max-width: 1100px; margin: 0 auto; padding: 0 32px 64px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.post-card { background: rgba(15,23,42,0.75); backdrop-filter: blur(8px); border: 1px solid rgba(139,92,246,0.12); border-radius: 12px; overflow: hidden; transition: border-color 0.3s, transform 0.2s; }
.post-card:hover { border-color: rgba(139,92,246,0.35); transform: translateY(-2px); }
.post-card-link { display: block; text-decoration: none; color: inherit; }
.post-card.featured { grid-column: 1 / -1; }
.post-card.featured .post-card-link { display: grid; grid-template-columns: 1.2fr 1fr; }
.post-img { background: linear-gradient(135deg, #1e1b4b, #0f172a); min-height: 180px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.post-img img { width: 100%; height: 100%; object-fit: cover; }
.post-img-placeholder .img-icon { font-size: 40px; opacity: 0.2; }
.post-card.featured .post-img { min-height: 260px; }
.post-body { padding: 20px; }
.post-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.post-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 8px; border-radius: 4px; }
.section-homelab { background: rgba(56,189,248,0.15); color: #38bdf8; }
.section-ai { background: rgba(139,92,246,0.15); color: #a78bfa; }
.section-trading { background: rgba(251,191,36,0.15); color: #fbbf24; }
.section-thoughts { background: rgba(52,211,153,0.15); color: #34d399; }
.post-date { font-size: 12px; color: #475569; }
.post-body h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; margin-bottom: 8px; line-height: 1.3; }
.post-card.featured .post-body h3 { font-size: 24px; }
.post-body p { font-size: 14px; color: #94a3b8; line-height: 1.6; }
.post-tags { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.tag { font-size: 11px; color: #64748b; background: rgba(51,65,85,0.4); padding: 2px 8px; border-radius: 4px; text-decoration: none; }
.tag:hover { color: #94a3b8; }

/* === Article (single post) === */
.article-wrapper { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; }
.hero-img { width: 100%; height: 360px; border-radius: 16px; overflow: hidden; margin-bottom: 40px; border: 1px solid rgba(139,92,246,0.15); }
.hero-img img { width: 100%; height: 100%; object-fit: cover; }
.post-header { margin-bottom: 40px; }
.post-section-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding: 3px 10px; border-radius: 5px; display: inline-block; margin-bottom: 16px; }
.post-header h1 { font-size: 36px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.25; margin-bottom: 16px; }
.post-meta-row { display: flex; align-items: center; gap: 16px; color: #64748b; font-size: 14px; flex-wrap: wrap; }
.post-meta-row .author { color: #a78bfa; font-weight: 500; }
.post-meta-row .dot { opacity: 0.4; }

/* === Article Body Typography === */
.article-body { line-height: 1.8; font-size: 16.5px; color: #cbd5e1; }
.article-body p { margin-bottom: 24px; }
.article-body h2 { font-size: 24px; font-weight: 700; color: #f1f5f9; margin: 48px 0 16px; letter-spacing: -0.3px; }
.article-body h3 { font-size: 18px; font-weight: 600; color: #e2e8f0; margin: 32px 0 12px; }
.article-body a { color: #a78bfa; text-decoration: underline; text-decoration-color: rgba(167,139,250,0.3); text-underline-offset: 3px; }
.article-body a:hover { text-decoration-color: #a78bfa; }
.article-body strong { color: #f1f5f9; font-weight: 600; }
.article-body ul, .article-body ol { margin-bottom: 24px; padding-left: 24px; }
.article-body li { margin-bottom: 8px; }
.article-body blockquote { border-left: 3px solid #a78bfa; padding: 16px 20px; margin: 24px 0; background: rgba(139,92,246,0.05); border-radius: 0 8px 8px 0; color: #94a3b8; font-style: italic; }
.article-body code { font-family: 'JetBrains Mono', monospace; font-size: 14px; background: rgba(30,41,59,0.6); padding: 2px 6px; border-radius: 4px; color: #a78bfa; }
.article-body pre { background: #0f172a; border: 1px solid #1e293b; border-radius: 10px; padding: 20px; margin: 24px 0; overflow-x: auto; }
.article-body pre code { background: none; padding: 0; font-size: 13.5px; color: #e2e8f0; line-height: 1.7; }
.article-body img { border-radius: 12px; margin: 32px 0; border: 1px solid rgba(139,92,246,0.1); }

/* === Article Tags (bottom of post) === */
.article-wrapper > .post-tags { margin: 48px 0 40px; padding-top: 32px; border-top: 1px solid rgba(139,92,246,0.1); }

/* === Comments === */
.comments-section { margin-top: 48px; padding-top: 40px; border-top: 1px solid rgba(139,92,246,0.1); }
.comments-section h2 { font-size: 20px; font-weight: 600; margin-bottom: 24px; }
.comments-dev-note { color: #475569; font-size: 14px; font-style: italic; }

/* === Post Nav (prev/next) === */
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; }
.post-nav a { padding: 20px; border: 1px solid #1e293b; border-radius: 10px; transition: border-color 0.2s; display: flex; flex-direction: column; gap: 4px; }
.post-nav a:hover { border-color: rgba(139,92,246,0.3); }
.post-nav .label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.post-nav .title { font-size: 14px; color: #e2e8f0; font-weight: 500; }
.post-nav-next { text-align: right; }

/* === Footer === */
footer { max-width: 1100px; margin: 0 auto; padding: 32px; border-top: 1px solid rgba(139,92,246,0.1); display: flex; justify-content: space-between; align-items: center; }
footer p { color: #475569; font-size: 13px; }
.socials { display: flex; gap: 16px; }
.socials a { color: #475569; font-size: 13px; transition: color 0.2s; }
.socials a:hover { color: #a78bfa; }

/* === 404 === */
.page-404 { max-width: 600px; margin: 0 auto; padding: 120px 32px; text-align: center; }
.page-404 h1 { font-size: 96px; font-weight: 700; background: linear-gradient(135deg, #a78bfa, #38bdf8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.page-404 p { color: #64748b; font-size: 18px; margin: 16px 0 32px; }

/* === Article Layout with TOC === */
.article-layout { display: grid; grid-template-columns: 1fr; max-width: 1100px; margin: 0 auto; }
@media (min-width: 1100px) {
  .article-layout { grid-template-columns: 1fr 220px; gap: 40px; padding: 0 32px; }
  .article-wrapper { max-width: 760px; padding-left: 0; padding-right: 0; }
}

/* === TOC Sidebar === */
.toc-sidebar { display: none; }
@media (min-width: 1100px) {
  .toc-sidebar { display: block; padding-top: 140px; }
}
.toc-sticky { position: sticky; top: 96px; }
.toc-heading { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; margin-bottom: 12px; }
.toc-sidebar nav#TableOfContents ul { list-style: none; padding: 0; margin: 0; }
.toc-sidebar nav#TableOfContents li { margin-bottom: 6px; }
.toc-sidebar nav#TableOfContents a { font-size: 13px; color: #475569; text-decoration: none; transition: color 0.2s; display: block; padding: 2px 0; border-left: 2px solid transparent; padding-left: 12px; }
.toc-sidebar nav#TableOfContents a:hover { color: #e2e8f0; }
.toc-sidebar nav#TableOfContents a.active { color: #a78bfa; border-left-color: #a78bfa; }
.toc-sidebar nav#TableOfContents ul ul { padding-left: 12px; }
.toc-sidebar nav#TableOfContents ul ul a { font-size: 12px; color: #3f3f46; }

/* === Responsive === */
@media (max-width: 1400px) { .tile { opacity: 0.08; } }
@media (max-width: 1200px) { .bg-collage { display: none; } }
@media (max-width: 700px) {
  .posts { grid-template-columns: 1fr; }
  .post-card.featured .post-card-link { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
  .post-header h1 { font-size: 28px; }
  .nav-links { gap: 16px; font-size: 13px; }
  .post-nav { grid-template-columns: 1fr; }
}

/* YouTube embed */
.youtube-embed { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 12px; margin: 32px 0; }
.youtube-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* Instagram card */
.instagram-card { margin: 24px 0; }
.instagram-card a { display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: rgba(30,41,59,0.5); border: 1px solid #1e293b; border-radius: 10px; text-decoration: none; color: #a78bfa; transition: border-color 0.2s; }
.instagram-card a:hover { border-color: rgba(139,92,246,0.3); }
.instagram-icon { font-size: 24px; }

/* Figure */
.article-figure { margin: 32px 0; }
.article-figure img { width: 100%; border-radius: 12px; border: 1px solid rgba(139,92,246,0.1); cursor: zoom-in; }
.article-figure figcaption { text-align: center; font-size: 13px; color: #64748b; margin-top: 8px; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin: 32px 0; }
.gallery-item { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid rgba(139,92,246,0.1); }
.gallery-item img { width: 100%; height: 200px; object-fit: cover; cursor: zoom-in; display: block; }
.gallery-caption { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px 12px; background: rgba(2,6,23,0.8); font-size: 12px; color: #94a3b8; }
