/* =========================================================================
   Manish Agrawal — blog / notes. Same tokens as the portfolio, reading layout.
   ========================================================================= */
@font-face { font-family: "Geist"; src: url("../fonts/geist-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("../fonts/geist-mono-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f3f4f7;
  --paper: #ffffff;
  --ink: #0b0d12;
  --ink-2: #3d4352;
  --muted: #6b7283;
  --line: rgba(11, 13, 18, .09);
  --line-2: rgba(11, 13, 18, .16);
  --blue: #2340ff;
  --cyan: #18c4ff;
  --orange: #ff5b1f;
  --green: #0f9d58;
  --code-bg: #0e1118;
  --f: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fm: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --g: clamp(16px, 3.4vw, 48px);
  --r: 18px;
  --measure: 860px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; accent-color: var(--blue); scroll-padding-top: 96px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.7 var(--f); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p, li { text-wrap: pretty; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: var(--blue); color: #fff; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 6px; }
.mono { font-family: var(--fm); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; font-weight: 450; }
.skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 99; top: 12px; left: 12px; padding: 10px 16px; border-radius: 99px; background: var(--ink); color: #fff; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px var(--g); background: rgba(243, 244, 247, .82); backdrop-filter: blur(12px) saturate(1.3); -webkit-backdrop-filter: blur(12px) saturate(1.3); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand svg { width: 36px; height: 36px; flex: none; transition: transform 400ms var(--ease-out); }
.brand rect { fill: var(--ink); transition: fill .3s; }
.brand path { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand:hover svg { transform: rotate(-12deg); }
.brand:hover rect { fill: var(--blue); }
.brand b { display: block; font-weight: 600; font-size: 15px; line-height: 1.1; }
.brand small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.top nav { display: flex; gap: 6px; }
.pill { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 99px; text-decoration: none; background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px var(--line); transition: background-color .18s, color .18s; }
.pill:hover { background: var(--ink); color: #fff; }
.pill[aria-current="page"] { background: var(--ink); color: #fff; }

/* ---------- article header ---------- */
.hero { max-width: calc(var(--measure) + 2 * var(--g)); margin: 0 auto; padding: clamp(40px, 8vw, 88px) var(--g) 28px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); margin-bottom: 22px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--blue); }
.hero h1 { font-size: clamp(34px, 5.6vw, 58px); line-height: 1.02; font-weight: 550; letter-spacing: -.035em; }
.hero h1 em { font-style: normal; color: var(--blue); }
.dek { margin: 20px 0 0; font-size: clamp(18px, 2vw, 21px); line-height: 1.55; color: var(--ink-2); }
.meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); }
.meta b { color: var(--ink); font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; }
.tags li { padding: 4px 10px; border-radius: 99px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }

/* ---------- body ---------- */
.post { max-width: calc(var(--measure) + 2 * var(--g)); margin: 0 auto; padding: 0 var(--g) 40px; }
.post h2 { font-size: clamp(25px, 3.2vw, 32px); line-height: 1.15; letter-spacing: -.025em; font-weight: 550; margin: 64px 0 16px; }
.post h2 .n { display: inline-block; min-width: 1.6em; color: var(--blue); font-family: var(--fm); font-size: .62em; font-weight: 500; vertical-align: .22em; }
.post h3 { font-size: 19px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; margin: 32px 0 8px; }
.post p { margin: 0 0 18px; color: var(--ink-2); }
.post p strong, .post li strong { color: var(--ink); font-weight: 600; }
.post ul, .post ol { margin: 0 0 20px; padding-left: 1.3em; color: var(--ink-2); }
.post li { margin: 6px 0; }
.post li::marker { color: var(--blue); }
.post a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.post a:hover { text-decoration-thickness: 2px; }
.post hr { border: 0; border-top: 1px solid var(--line); margin: 48px 0; }
:not(pre) > code { font-family: var(--fm); font-size: .86em; padding: .12em .4em; border-radius: 6px; background: rgba(35, 64, 255, .07); color: #1a2fd0; overflow-wrap: anywhere; }

/* summary card */
.tldr { margin: 8px 0 36px; padding: 22px 24px; border-radius: var(--r); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line), 0 20px 50px -34px rgba(17, 24, 64, .35); }
.tldr > .mono { display: block; color: var(--blue); margin-bottom: 10px; }
.tldr ul { margin: 0; }
.tldr li { margin: 7px 0; }

/* table of contents */
.toc { margin: 0 0 40px; padding: 20px 24px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line-2); }
.toc > .mono { display: block; color: var(--muted); margin-bottom: 8px; }
.toc ol { margin: 0; padding-left: 1.4em; columns: 2 260px; column-gap: 32px; }
.toc li { margin: 4px 0; break-inside: avoid; font-size: 15.5px; }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--blue); }

/* tables */
.tbl { margin: 8px 0 24px; overflow-x: auto; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line-2); background: var(--paper); -webkit-overflow-scrolling: touch; }
.tbl table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.45; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { font: 500 11.5px/1.3 var(--fm); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: #fafbfc; white-space: nowrap; }
.tbl td code { white-space: nowrap; }
.tbl--wide table { min-width: 560px; }

/* code blocks */
.code { position: relative; margin: 8px 0 24px; border-radius: 14px; background: var(--code-bg); color: #e6e9f2; }
.code pre { margin: 0; padding: 18px 20px; overflow-x: auto; font: 400 13.5px/1.65 var(--fm); tab-size: 2; -webkit-overflow-scrolling: touch; }
.code .c { color: #7d869c; }
.code[data-label] pre { padding-top: 14px; }
.code .o { color: #7ee2a8; }
.code[data-label]::before { content: attr(data-label); display: block; min-height: 34px; padding: 12px 20px 0; border-bottom: 1px solid rgba(255,255,255,.07); font: 500 11px/1 var(--fm); letter-spacing: .06em; text-transform: uppercase; color: #8a93a8; }
.copy { position: absolute; top: 6px; right: 6px; min-height: 28px; padding: 0 12px; border: 0; border-radius: 99px; font: 500 11px/1 var(--fm); letter-spacing: .05em; text-transform: uppercase; color: #cfd5e3; background: rgba(255,255,255,.08); cursor: pointer; transition: background-color .18s, color .18s; }
.copy:hover { background: rgba(255,255,255,.16); color: #fff; }
.copy.is-done { background: var(--green); color: #fff; }

/* callouts */
.note { margin: 8px 0 24px; padding: 16px 20px; border-radius: 14px; background: rgba(35, 64, 255, .06); box-shadow: inset 3px 0 0 var(--blue); }
.note--warn { background: rgba(255, 91, 31, .07); box-shadow: inset 3px 0 0 var(--orange); }
.note--ok { background: rgba(15, 157, 88, .07); box-shadow: inset 3px 0 0 var(--green); }
.note p { margin: 0; }
.note p + p { margin-top: 8px; }
.note b.mono { display: block; margin-bottom: 4px; color: var(--ink); }

/* checklist */
.check { list-style: none; padding-left: 0 !important; }
.check li { position: relative; padding-left: 30px; }
.check li::before { content: ""; position: absolute; left: 0; top: .38em; width: 18px; height: 18px; border-radius: 6px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--blue); }
.check li::after { content: ""; position: absolute; left: 6px; top: calc(.38em + 4px); width: 6px; height: 9px; border: solid var(--blue); border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* faq */
.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq details:first-of-type { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; font-weight: 550; color: var(--ink); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font: 400 22px/1 var(--fm); color: var(--blue); transition: transform .25s var(--ease-out); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 0 16px; }

/* author + footer */
.author { display: flex; gap: 18px; align-items: center; margin: 56px 0 0; padding: 22px 24px; border-radius: var(--r); background: var(--ink); color: #fff; }
.author svg { width: 52px; height: 52px; flex: none; }
.author rect { fill: var(--blue); }
.author path { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.author p { margin: 0; color: rgba(255,255,255,.78); font-size: 15.5px; }
.author b { color: #fff; }
.author a { color: #fff; }
.foot { max-width: 1180px; margin: 0 auto; padding: 28px var(--g) 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--blue); }

/* ---------- article layout: contents rail + body ---------- */
.layout { max-width: 1180px; margin: 0 auto; padding: 0 var(--g); display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "toc" "body"; }
.layout > .hero { grid-area: hero; max-width: none; margin: 0; padding-inline: 0; }
.layout > .toc { grid-area: toc; }
.layout > .post { grid-area: body; max-width: none; margin: 0; padding-inline: 0; }
@media (min-width: 1080px) {
  .layout { grid-template-columns: 210px minmax(0, 1fr); column-gap: clamp(40px, 5vw, 72px); grid-template-areas: "toc hero" "toc body"; }
  .layout > .toc { align-self: start; position: sticky; top: 92px; margin: clamp(40px, 8vw, 88px) 0 0; padding: 0; box-shadow: none; max-height: calc(100vh - 120px); overflow-y: auto; }
  .layout > .toc ol { columns: auto; padding-left: 0; list-style: none; border-left: 1px solid var(--line); }
  .layout > .toc li { margin: 0; font-size: 14px; }
  .layout > .toc a { display: block; margin-left: -1px; padding: 5px 0 5px 14px; border-left: 2px solid transparent; transition: color .18s, border-color .18s; }
  .layout > .toc a.is-active { color: var(--blue); border-left-color: var(--blue); }
}

/* ---------- blog index ---------- */
.list { max-width: calc(var(--measure) + 2 * var(--g)); margin: 0 auto; padding: 0 var(--g) 64px; display: grid; gap: 14px; }
.card { display: block; padding: 24px; border-radius: var(--r); background: var(--paper); text-decoration: none; box-shadow: inset 0 0 0 1px var(--line), 0 20px 50px -36px rgba(17, 24, 64, .4); transition: translate .3s var(--ease-out), box-shadow .3s; }
.card:hover { translate: 0 -3px; box-shadow: inset 0 0 0 1px var(--line-2), 0 26px 60px -34px rgba(17, 24, 64, .45); }
.card .mono { color: var(--muted); }
.card h2 { margin: 10px 0 8px; font-size: clamp(22px, 2.8vw, 28px); line-height: 1.15; letter-spacing: -.02em; font-weight: 550; }
.card p { margin: 0; color: var(--ink-2); }
.card .more { display: inline-block; margin-top: 14px; color: var(--blue); }

@media (max-width: 620px) {
  body { font-size: 16.5px; }
  .brand small { display: none; }
  .pill { padding: 0 13px; }
  .post h2 { margin-top: 52px; }
  .tldr, .toc { padding: 18px; }
  .code pre { padding: 16px; font-size: 12.5px; }
  .code[data-label]::before { padding: 10px 16px 0; }
  .author { flex-direction: column; align-items: flex-start; }
  .tbl--stack table { min-width: 0; }
  .tbl--stack thead { display: none; }
  .tbl--stack tr { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .tbl--stack tr:last-child { border-bottom: 0; }
  .tbl--stack td { display: block; padding: 2px 0; border: 0; }
  .tbl--stack td::before { content: attr(data-l); display: block; margin-top: 8px; font: 500 10.5px/1.4 var(--fm); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .tbl--stack td:first-child::before { margin-top: 0; }
  .tbl--stack td:first-child { font-weight: 600; color: var(--ink); }
  .tbl--stack td code { white-space: normal; }
}
@media (pointer: coarse) { .toc li { margin: 8px 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print { .top, .copy, .toc { display: none; } body { background: #fff; } .code { background: #f4f5f7; color: #111; } }
