/* Engineering Notes: one small stylesheet, system fonts, light and dark via prefers-color-scheme. */
:root {
  --bg: #fbfaf7;
  --surface: #f2f0ea;
  --text: #1d1f21;
  --muted: #5d6166;
  --border: #e1ddd3;
  --accent: #1f6f5c;
  --accent-soft: #e2efe9;
  --code-bg: #f4f2ec;
  --measure: 44rem;
  --font-body: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Bengali", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --text: #e4e2dd;
    --muted: #9da3aa;
    --border: #2d3136;
    --accent: #6cc4a8;
    --accent-soft: #1e3a32;
    --code-bg: #0d1117;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1rem; }

/* Header and footer */
.site-header { border-bottom: 1px solid var(--border); font-family: var(--font-ui); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; flex-wrap: wrap; }
.site-title { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.site-header nav { display: flex; gap: 1.1rem; font-size: 0.95rem; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--accent); }
.site-footer { margin-top: 4rem; border-top: 1px solid var(--border); padding: 1.5rem 0 2.5rem; font-family: var(--font-ui); font-size: 0.875rem; color: var(--muted); }
.site-footer p { margin: 0.35rem 0; }
.site-footer a { color: var(--muted); }

/* Index */
.intro { padding: 2.75rem 0 1rem; }
.intro h1 { font-family: var(--font-ui); font-size: clamp(2rem, 6vw, 2.6rem); line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 0.75rem; }
.lede { color: var(--muted); margin: 0; font-size: 1.15rem; }
.section-label { font-family: var(--font-ui); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 2.5rem 0 0.5rem; }
.post-list { list-style: none; margin: 0; padding: 0; }
.post-item { padding: 1.4rem 0; border-bottom: 1px solid var(--border); }
.post-item:last-child { border-bottom: 0; }
.post-item h3 { font-family: var(--font-ui); font-size: 1.3rem; line-height: 1.3; letter-spacing: -0.01em; margin: 0 0 0.3rem; }
.post-item h3 a { color: var(--text); text-decoration: none; }
.post-item h3 a:hover { color: var(--accent); }
.summary { margin: 0.4rem 0 0.6rem; }
.meta { font-family: var(--font-ui); font-size: 0.875rem; color: var(--muted); margin: 0; }
.meta code.repo { font-size: 0.82rem; background: none; padding: 0; color: var(--muted); }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 0; padding: 0; }
.tag { font-family: var(--font-ui); font-size: 0.75rem; line-height: 1; padding: 0.35rem 0.55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.about { padding-bottom: 1rem; }
.about p { margin: 0.6rem 0; }

/* Article */
.post-header { padding: 2.25rem 0 0.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.post-header h1 { font-family: var(--font-ui); font-size: clamp(1.75rem, 5.5vw, 2.35rem); line-height: 1.18; letter-spacing: -0.022em; margin: 0.25rem 0 0.75rem; }
.back { font-family: var(--font-ui); font-size: 0.9rem; margin: 0; }
.back a { text-decoration: none; }
.source { font-family: var(--font-ui); font-size: 0.875rem; color: var(--muted); margin: 0.75rem 0 1rem; }

.prose h2, .prose h3 { font-family: var(--font-ui); line-height: 1.3; letter-spacing: -0.012em; scroll-margin-top: 1rem; }
.prose h2 { font-size: 1.45rem; margin: 2.4rem 0 0.6rem; }
.prose h3 { font-size: 1.15rem; margin: 1.8rem 0 0.4rem; }
.prose .headerlink { margin-left: 0.4rem; color: var(--border); text-decoration: none; font-weight: 400; opacity: 0; transition: opacity 0.15s; }
.prose h2:hover .headerlink, .prose h3:hover .headerlink, .prose .headerlink:focus { opacity: 1; color: var(--muted); }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1rem; }
.prose li { margin: 0.25rem 0; }
.prose blockquote { margin: 1.5rem 0; padding: 0.2rem 0 0.2rem 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose img { max-width: 100%; height: auto; }

code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
.highlight { margin: 1.25rem 0 1.4rem; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.highlight pre { margin: 0; padding: 0.9rem 1rem; overflow-x: auto; font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.55; tab-size: 4; }
.highlight code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.prose p.file { font-family: var(--font-ui); font-size: 0.8rem; color: var(--muted); margin: 1.25rem 0 -0.9rem; }
.prose p.file + .highlight { margin-top: 1rem; }

.table-wrap { overflow-x: auto; margin: 1.25rem 0 1.5rem; border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 0.86rem; line-height: 1.45; }
th, td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
td:first-child, th:first-child { white-space: normal; }
thead th { background: var(--surface); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td[align="right"], th[align="right"] { text-align: right; font-variant-numeric: tabular-nums; }

.diagram { margin: 1.5rem 0; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; }
.diagram pre.mermaid { margin: 0; display: flex; justify-content: center; font-family: var(--font-ui); font-size: 0.85rem; background: none; }
.diagram pre.mermaid:not([data-processed]) { white-space: pre; color: var(--muted); }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; font-family: var(--font-ui); font-size: 0.95rem; }
.post-nav a { display: block; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); }
.post-nav a:hover { border-color: var(--accent); }
.post-nav .nav-older { grid-column: 2; text-align: right; }
.nav-label { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.2rem; }

@media (max-width: 560px) {
  body { font-size: 1.05rem; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .nav-older { grid-column: 1; text-align: left; }
  .highlight pre { font-size: 0.8rem; }
}
@media print {
  .site-header nav, .post-nav, .headerlink { display: none; }
  body { background: #fff; color: #000; }
}
