/* CoreReflex Journal — shared design system for the blog index (public/blog.html)
   and the server-rendered post + category pages (src/blog-render.js). One source of
   truth so the client-rendered index and the SSR reader look identical. */

:root {
  --bg: #0b0d0c; --bg-1: #111412; --bg-2: #151a16; --ink: #f2f5ec; --muted: #a9afa5; --faint: #868b82;
  --line: rgba(242, 245, 236, 0.12); --line-strong: rgba(242, 245, 236, 0.22);
  --lime: #c7ff3d; --sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0; text-transform: uppercase; }
.wrap { width: min(1180px, 92vw); margin: 0 auto; }

/* Reading progress bar (post pages) */
.read-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 60; background: var(--lime); box-shadow: 0 0 12px var(--lime); transition: width 0.08s linear; }

#nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50; display: flex; align-items: center;
  justify-content: space-between; padding: 18px max(4vw, 24px); border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 12, 0.72); backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 14px var(--lime); }
.nav-links, .foot-links { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.nav-links a.link, .foot-links a { color: var(--muted); font-size: 14px; }
.nav-links a.link:hover, .foot-links a:hover { color: var(--ink); }
.nav-toggle { display: none; width: 42px; height: 42px; align-items: center; justify-content: center; flex-direction: column; gap: 5px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(242, 245, 236, 0.04); color: var(--ink); cursor: pointer; }
.nav-toggle span { width: 18px; height: 2px; border-radius: 999px; background: currentColor; transition: transform 0.18s ease, opacity 0.18s ease; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.mobile-menu { display: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent;
  border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease, background 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-lime { background: var(--lime); color: #0b0d0c; }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.btn-ghost:hover { background: rgba(242, 245, 236, 0.06); }
main { padding: 132px 0 78px; }

/* ---- Index hero + listing ---- */
.hero { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.72fr); gap: 42px; align-items: end; }
.kicker { color: var(--lime); margin-bottom: 16px; }
h1 { max-width: 18ch; margin: 0 0 18px; font-size: clamp(36px, 6vw, 70px); line-height: 1; letter-spacing: 0; }
.lead { max-width: 58ch; color: var(--muted); font-size: clamp(15px, 1.8vw, 19px); line-height: 1.6; }
.quick { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-1); padding: 22px; }
.quick h2 { margin: 0 0 12px; font-size: 18px; letter-spacing: 0; }
.quick p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.quick .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section { margin-top: 48px; padding-top: 36px; border-top: 1px solid var(--line); }
.section-status { color: var(--lime); margin-bottom: 22px; }

/* Index two-column: sticky filter sidebar + post list */
.index-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 40px; align-items: start; }
.index-side { position: sticky; top: 104px; align-self: start; display: grid; gap: 22px; }
.filterbar { display: flex; gap: 10px; }
.filterbar input { flex: 1; min-width: 0; background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--ink); font-family: var(--sans); font-size: 14px; }
.filterbar input:focus { outline: none; border-color: var(--line-strong); }
.cat-list { display: grid; gap: 2px; }
.cat-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--muted); font-size: 14px; }
.cat-list a:hover { background: rgba(242, 245, 236, 0.05); color: var(--ink); }
.cat-list a.active { background: rgba(var(--accent-rgb), 0.1); color: var(--ink); }
.cat-list a .n { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.side-title { color: var(--faint); margin: 0 0 8px; }

.post-list { display: grid; gap: 16px; }
.post-card {
  display: block; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-1); padding: 24px;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
.post-card:hover { border-color: var(--line-strong); background: var(--bg-2); transform: translateY(-1px); }
.post-card .post-meta { display: flex; gap: 12px; align-items: center; color: var(--faint); margin-bottom: 12px; flex-wrap: wrap; }
.post-card .cat { color: var(--lime); }
.post-card h2 { margin: 0 0 10px; font-size: clamp(19px, 2.4vw, 26px); letter-spacing: 0; }
.post-card p { margin: 0 0 14px; color: var(--muted); font-size: 15px; line-height: 1.6; max-width: 72ch; }
.post-card .more { color: var(--lime); font-weight: 700; font-size: 14px; }
.empty, .loading { color: var(--muted); font-size: 15px; line-height: 1.6; }
.reader-error { color: #ff9a86; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 32px; }
.pagination a, .pagination span { padding: 8px 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 14px; }
.pagination a:hover { border-color: var(--line-strong); color: var(--ink); }
.pagination .cur { background: var(--lime); color: #0b0d0c; border-color: var(--lime); font-weight: 700; }
.pagination .gap { border: 0; }

/* ---- Post (SSR) layout: article + sticky sidebar ---- */
.breadcrumbs { margin-bottom: 22px; }
.breadcrumbs ol { display: flex; gap: 8px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; color: var(--faint); font-size: 13px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--ink); }
.breadcrumbs .here { color: var(--ink); max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--lime); background: rgba(var(--accent-rgb), 0.06); }
.chip:hover { border-color: var(--lime); }

.post-head { margin-bottom: 24px; }
.post-head h1 { max-width: 24ch; font-size: clamp(30px, 5vw, 52px); margin: 0 0 16px; line-height: 1.05; }
.post-head .desc { color: var(--muted); font-size: clamp(16px, 2vw, 20px); line-height: 1.5; max-width: 60ch; margin: 0 0 22px; }
.post-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; color: var(--muted); font-size: 14px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.byline { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #0b0d0c; background: linear-gradient(135deg, var(--lime), #7bd000); }
.byline .who { line-height: 1.25; }
.byline .who b { color: var(--ink); font-weight: 600; }
.byline .who span { display: block; color: var(--faint); font-size: 12px; }
.meta-pill { display: inline-flex; align-items: center; gap: 6px; }

.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 264px; gap: 52px; align-items: start; margin-top: 8px; }
.post-aside { position: sticky; top: 104px; align-self: start; display: grid; gap: 20px; max-height: calc(100vh - 130px); overflow: auto; }
.toc h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); margin: 0 0 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); font-size: 13.5px; line-height: 1.4; transition: color 0.15s, border-color 0.15s; }
.toc a.lvl-3 { padding-left: 26px; font-size: 13px; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--lime); border-left-color: var(--lime); }
.aside-cta { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-1); padding: 18px; }
.aside-cta h3 { margin: 0 0 8px; font-size: 15px; }
.aside-cta p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Article body (shared doc-content) */
.post-body { max-width: 75ch; }
.doc-content { color: var(--ink); line-height: 1.72; }
.doc-content > *:first-child { margin-top: 0; }
.doc-content h2, .doc-content h3, .doc-content h4 { line-height: 1.18; letter-spacing: 0; margin: 38px 0 12px; scroll-margin-top: 110px; }
.doc-content h2 { font-size: clamp(23px, 3vw, 31px); }
.doc-content h3 { font-size: 21px; }
.doc-content h4 { font-size: 17px; color: var(--muted); }
.doc-content p, .doc-content li, .doc-content td, .doc-content th { font-size: 16px; }
.doc-content p { color: var(--muted); }
.doc-content a { color: var(--lime); text-decoration: underline; text-underline-offset: 3px; }
.doc-content a:hover { text-decoration-thickness: 2px; }
.doc-content ul, .doc-content ol { padding-left: 22px; color: var(--muted); }
.doc-content li { margin: 6px 0; }
.doc-content blockquote { margin: 22px 0; padding: 14px 18px; border-left: 3px solid var(--lime); background: rgba(var(--accent-rgb), 0.06); color: var(--ink); }
.doc-content code { font-family: var(--mono); font-size: 0.9em; padding: 2px 5px; border-radius: 4px; background: rgba(242, 245, 236, 0.08); color: var(--ink); }
.doc-content pre { overflow-x: auto; margin: 20px 0; padding: 16px; border-radius: 8px; background: #090b0a; border: 1px solid var(--line); }
.doc-content pre code { padding: 0; background: transparent; }
.doc-content table { width: 100%; border-collapse: collapse; margin: 22px 0; display: block; overflow-x: auto; }
.doc-content th, .doc-content td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
.doc-content th { color: var(--ink); background: rgba(242, 245, 236, 0.05); }
.doc-content hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

/* Share + related + CTA */
.share { margin-top: 40px; padding-top: 26px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.share h3 { margin: 0 0 2px; font-size: 16px; }
.share p { margin: 0; color: var(--muted); font-size: 14px; }
.share .links { display: flex; gap: 10px; flex-wrap: wrap; }
.share a { border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.share a:hover { border-color: var(--line-strong); color: var(--ink); }
.related { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--line); }
.related h2 { font-size: 24px; margin: 0 0 18px; }
.related-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
.related-grid a { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--bg-1); transition: border-color 0.2s, transform 0.15s; }
.related-grid a:hover { border-color: var(--lime); transform: translateY(-1px); }
.related-grid .cat { color: var(--lime); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.related-grid h3 { margin: 8px 0 6px; font-size: 16px; line-height: 1.3; }
.related-grid p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 28px; }
.metric-card { border: 1px solid var(--line); background: rgba(242,245,236,.04); padding: 18px; }
.metric-card span { color: var(--lime); font: 700 18px/1.25 "Space Grotesk", sans-serif; }
.case-quote { border-left: 3px solid var(--lime); margin: 0 0 30px; padding: 14px 0 14px 22px; color: var(--ink); }
.case-quote p { font-size: 22px; line-height: 1.45; margin: 0 0 10px; }
.case-quote cite { color: var(--muted); font-style: normal; }
.post-cta { margin-top: 40px; padding: 26px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-1); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.post-cta p { margin: 0; color: var(--muted); font-size: 15px; }
.post-back { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.post-back:hover { color: var(--ink); }

footer { border-top: 1px solid var(--line); padding: 40px 0; color: var(--faint); font-size: 13px; }
footer .wrap { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; }
.skip-link { position: fixed; left: 18px; top: 12px; z-index: 100; transform: translateY(-180%); background: var(--lime); color: #0b0d0c; border-radius: 8px; padding: 10px 14px; font-weight: 700; transition: transform 0.15s ease; }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; border-radius: 4px; }

@media (max-width: 1000px) {
  .post-layout { grid-template-columns: 1fr; }
  .post-aside { position: static; max-height: none; overflow: visible; order: -1; }
  .toc { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-1); padding: 16px 18px; }
  .related-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } .index-layout { grid-template-columns: 1fr; } .index-side { position: static; } }
@media (max-width: 720px) {
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
  .related-grid { grid-template-columns: 1fr; }
  .mobile-menu { position: fixed; inset: 67px 0 auto 0; z-index: 49; display: grid; padding: 8px max(4vw, 24px) 18px; border-bottom: 1px solid var(--line); background: rgba(11, 13, 12, 0.94); backdrop-filter: blur(14px); }
  .mobile-menu[hidden] { display: none; }
  .mobile-menu a { padding: 14px 0; border-top: 1px solid var(--line); color: var(--ink); font-weight: 700; }
  .mobile-menu a.btn { margin-top: 10px; padding: 12px 18px; border-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
