/* ============================================================
   SRRRS Docs — sister site to srrrs.com
   One navy accent + warm neutrals + generous whitespace.
   Navy is page-wide "stitching": eyebrows, links, key terms,
   tags, current state — never a large filled background.
   ============================================================ */

:root {
  --paper:         #F4F1EA;   /* page base, warm */
  --warm:          #FBF9F4;   /* gentle alt surface (sidebar, code meta) */
  --surface:       #FFFFFF;   /* cards that should pop */
  --ink:           #16181C;   /* body text */
  --muted:         #6B6B63;   /* secondary text, dates, descriptions */
  --line:          #E4E0D6;   /* hairlines, borders */
  --accent:        #1E3A6E;   /* navy — links, eyebrows, terms, tags */
  --accent-strong: #2547D0;   /* CTA, hover emphasis */
  --code-bg:       #272822;   /* dark code card (matches monokai) */

  --radius:   10px;
  --radius-s: 7px;
  --maxw:     1200px;
  --read:     700px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

h1, h2, h3, h4 { line-height: 1.25; color: var(--ink); font-weight: 700; }

::selection { background: rgba(37, 71, 208, 0.16); }

/* ---- shared bits ---- */
.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

/* navy "stitching" on key terms in body copy */
.term {
  color: var(--accent);
  font-weight: 600;
}

.count {
  display: inline-block;
  min-width: 1.5em;
  margin-left: 0.5em;
  padding: 0 0.45em;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(244, 241, 234, 0.88);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.34em;
  font-weight: 700;
  font-size: 1.06rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark:hover { color: var(--ink); }
.wordmark-name { color: var(--ink); }
.wordmark-sub  { color: var(--accent); font-weight: 600; }

.header-nav {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 18px;
  min-width: 0;
}

.cat-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.cat-links a {
  display: inline-block;
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--muted);
  border-radius: var(--radius-s);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.cat-links a:hover { color: var(--accent); background: var(--warm); }
.cat-links a.is-active { color: var(--accent); background: rgba(30, 58, 110, 0.08); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  white-space: nowrap;
}
.link-back {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--muted);
  border-radius: var(--radius-s);
}
.link-back:hover { color: var(--accent); background: var(--warm); }

.cta {
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-strong);
  border-radius: var(--radius-s);
  box-shadow: 0 1px 2px rgba(37, 71, 208, 0.25);
  transition: background 0.15s, transform 0.05s;
}
.cta:hover { color: #fff; background: #1d3bb5; }
.cta:active { transform: translateY(1px); }

/* hamburger */
.nav-toggle {
  display: none;
  margin-left: auto;
  width: 40px; height: 40px;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}
.nav-toggle span {
  display: block;
  width: 18px; height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

/* ============================================================
   Layout: sidebar + main
   ============================================================ */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 62px;
  align-self: start;
  max-height: calc(100vh - 62px);
  overflow-y: auto;
  padding: 30px 0 40px;
}
.side-block { margin-bottom: 28px; }

.side-cats, .side-tags { list-style: none; margin: 0; padding: 0; }

.side-cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  margin: 1px 0;
  font-size: 0.9rem;
  color: var(--ink);
  border-radius: var(--radius-s);
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.side-cat:hover { background: var(--warm); color: var(--accent); }
.side-cat.is-active {
  color: var(--accent);
  font-weight: 600;
  background: rgba(30, 58, 110, 0.06);
  border-left-color: var(--accent);
}
.side-cat .count { background: var(--surface); }

.side-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.side-tags .tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s, background 0.15s;
}
.side-tags .tag:hover { border-color: var(--accent); }
.side-tags .tag.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.side-tags .tag .count {
  margin-left: 0.4em;
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.7;
  min-width: auto;
  padding: 0;
}

.main { padding: 30px 0 60px; min-width: 0; }

/* ============================================================
   Intro / list header
   ============================================================ */
.page-intro {
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.page-intro h1 {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
}
.page-intro .lede {
  margin: 0;
  max-width: 64ch;
  color: var(--muted);
  font-size: 1.02rem;
}

/* ============================================================
   Filter bar (home)
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 9px 14px;
  background: var(--warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  font-size: 0.88rem;
}
.filter-label { color: var(--muted); }
.filter-current { font-weight: 600; color: var(--accent); }
.filter-clear {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
}
.filter-clear:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   Post list — dense, information-rich
   ============================================================ */
.post-list { display: flex; flex-direction: column; }

.post-card {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.post-card[hidden] { display: none; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.78rem;
}
.card-cat {
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.card-meta time, .reading-time { color: var(--muted); }

.card-title {
  margin: 0 0 5px;
  font-size: 1.18rem;
  font-weight: 650;
  line-height: 1.3;
}
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--accent-strong); }

.card-desc {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.94rem;
  max-width: 76ch;
}

.card-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.card-tags a {
  display: inline-block;
  padding: 2px 9px;
  font-size: 0.74rem;
  color: var(--accent);
  background: var(--warm);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.card-tags a:hover { border-color: var(--accent); background: var(--surface); }

.no-results { color: var(--muted); padding: 30px 0; }

/* ============================================================
   Single article
   ============================================================ */
.single {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 48px;
  align-items: start;
}
.article { min-width: 0; max-width: var(--read); }

.article-head {
  padding-bottom: 22px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.8rem;
}
.article-head h1 {
  margin: 0 0 0.5rem;
  font-size: 2.1rem;
  letter-spacing: -0.015em;
}
.article-lede {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}
.article-head .card-tags a { background: var(--surface); }

/* body content typography */
.content { font-size: 1.02rem; line-height: 1.75; color: var(--ink); }
.content > p { margin: 0 0 1.2rem; }
.content h2 {
  margin: 2.2rem 0 0.9rem;
  font-size: 1.42rem;
  padding-top: 0.4rem;
  scroll-margin-top: 80px;
}
.content h3 {
  margin: 1.8rem 0 0.7rem;
  font-size: 1.16rem;
  scroll-margin-top: 80px;
}
.content a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
.content a:hover { text-decoration-color: var(--accent-strong); }
.content ul, .content ol { margin: 0 0 1.2rem; padding-left: 1.4rem; }
.content li { margin: 0.3rem 0; }
.content li::marker { color: var(--accent); }
.content blockquote {
  margin: 1.4rem 0;
  padding: 0.4rem 0 0.4rem 1.1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.content img { max-width: 100%; height: auto; border-radius: var(--radius-s); }
.content hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0;
  font-size: 0.94rem;
}
.content th, .content td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.content th { color: var(--ink); font-weight: 600; background: var(--warm); }

/* inline code */
.content :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  color: var(--accent);
  background: var(--warm);
  border: 1px solid var(--line);
  border-radius: 5px;
}

/* dark code cards (chroma monokai supplies inline colors) */
.content pre {
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--code-bg);
  color: #f8f8f2;
  padding: 16px 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.4rem 0;
  border: 1px solid #000;
  -webkit-overflow-scrolling: touch;
}
.content pre code {
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
}
.content .highlight { margin: 1.4rem 0; }
.content .highlight pre { margin: 0; }

/* ---- TOC ---- */
.toc {
  position: sticky;
  top: 86px;
  align-self: start;
  font-size: 0.86rem;
}
.toc .eyebrow { margin-bottom: 0.7rem; }
.toc-inner { padding-left: 14px; border-left: 1px solid var(--line); }
.toc nav ul { list-style: none; margin: 0; padding: 0; }
.toc nav ul ul { padding-left: 12px; }
.toc nav li { margin: 0.32rem 0; }
.toc nav a { color: var(--muted); line-height: 1.4; display: block; }
.toc nav a:hover { color: var(--accent); }

.toc-mobile {
  display: none;
  margin: 0 0 26px;
  padding: 12px 16px;
  background: var(--warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.toc-mobile summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.9rem;
}
.toc-mobile nav ul { list-style: none; margin: 0.6rem 0 0; padding-left: 0.6rem; }
.toc-mobile nav ul ul { padding-left: 1rem; }
.toc-mobile nav li { margin: 0.3rem 0; }
.toc-mobile nav a { color: var(--muted); }

/* prev / next */
.post-nav {
  display: flex;
  gap: 14px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.post-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.post-nav-link:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(22, 24, 28, 0.05); }
.post-nav-link.next { text-align: right; align-items: flex-end; }
.post-nav-link .dir { font-size: 0.74rem; color: var(--accent); font-weight: 600; letter-spacing: 0.02em; }
.post-nav-link .t { color: var(--ink); font-weight: 600; font-size: 0.96rem; }

/* ============================================================
   Tag index
   ============================================================ */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 9px; }
.tag-cloud .tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  font-size: 0.88rem;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s;
}
.tag-cloud .tag:hover { border-color: var(--accent); }
.tag-cloud .tag .count {
  margin-left: 0.5em; background: var(--warm);
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--line);
  background: var(--warm);
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 36px 24px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: space-between;
}
.footer-brand .footer-tag { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.footer-links a { color: var(--muted); font-size: 0.9rem; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 24px 28px;
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  gap: 8px;
}
.footer-bottom .dot { opacity: 0.5; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1000px) {
  .single { grid-template-columns: 1fr; gap: 0; }
  .article { max-width: 100%; }
  .toc { display: none; }
  .toc-mobile { display: block; }
}

/* Medium widths: header category links get cramped (would wrap to a 2nd line).
   They're redundant with the sidebar here, so hide them until the hamburger. */
@media (min-width: 821px) and (max-width: 1100px) {
  .cat-links { display: none; }
}

@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .header-nav {
    position: fixed;
    top: 62px; left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 24px 20px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 24px rgba(22, 24, 28, 0.07);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.16s, opacity 0.16s;
  }
  body.nav-open .header-nav { transform: none; opacity: 1; pointer-events: auto; }
  .cat-links { flex-direction: column; gap: 0; margin-bottom: 10px; }
  .cat-links a { padding: 10px; font-size: 0.95rem; border-bottom: 1px solid var(--line); border-radius: 0; }
  .header-actions { gap: 10px; }
  .header-actions .cta, .header-actions .link-back { flex: 1; text-align: center; }

  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 22px 0 4px;
    border-bottom: 1px solid var(--line);
  }
  .side-cats { display: flex; flex-wrap: wrap; gap: 6px; }
  .side-cat { border-left: none; padding: 6px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
  .side-cat.is-active { border-left: none; }
}

@media (max-width: 520px) {
  .header-inner { padding: 0 16px; gap: 12px; }
  .layout, .footer-inner, .footer-bottom { padding-left: 16px; padding-right: 16px; }
  .page-intro h1 { font-size: 1.6rem; }
  .article-head h1 { font-size: 1.7rem; }
  .post-nav { flex-direction: column; }
}

@media (max-width: 820px) {
  .side-tags {
    max-height: 8.5em;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
