/* ================================================================
   BLOG — Nicolás Biondi
   ----------------------------------------------------------------
   Standalone stylesheet for /blog/ (index, section, tag and post
   pages). LIGHT editorial theme matching the home's white blog
   section: off-white paper, ink text, Montserrat, the AA-safe dark
   blue #0369a1 for text accents (5.5:1 on white — #1AB6FF fails AA
   and is reserved for non-text accents). Loads NEITHER the fluid
   canvas NOR the custom cursor: reading pages use the system
   cursor. Pages are generated by scripts/blog/build.mjs (see
   docs/blog.md).
   ================================================================ */

/* Self-hosted Montserrat — the SAME @fontsource files the mermaid
   build renders with (Google Fonts ships slightly different metrics
   and diagram labels clipped by 1–2 px). Copied into assets/fonts/
   by scripts/blog/build.mjs. */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/montserrat-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/montserrat-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/montserrat-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/montserrat-latin-700-normal.woff2') format('woff2');
}

:root {
  --paper:      #f7f7f5;
  --panel:      #ffffff;
  --ink:        #1f2328;   /* body text — 15.6:1 on paper */
  --ink-muted:  #57606a;   /* meta text — 6.0:1 on paper */
  --ink-accent: #0369a1;   /* links/labels — 5.5:1 on paper */
  --ink-border: rgba(31, 35, 40, 0.14);
  --accent-bright: #1AB6FF; /* decorative only — never body text */
  --code-bg:    #151727;   /* code blocks stay dark for contrast */
  --font:       'Montserrat', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body.blog {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17.5px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  overflow-x: clip;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

a { color: var(--ink-accent); text-decoration: none; transition: color .25s ease; }
a:hover { color: var(--ink); }

/* Keyboard focus: a clear AA-contrast ring everywhere. */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ink-accent);
  outline-offset: 3px;
}

::selection { background: var(--ink-accent); color: #fff; }

/* Same dot-grid motif as the landing, in faint ink. */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(31,35,40,0.10) 1px, transparent 1.5px);
  background-size: 22px 22px;
  background-position: center;
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 50%, #000 40%, transparent 100%);
          mask-image: radial-gradient(ellipse 80% 75% at 50% 50%, #000 40%, transparent 100%);
}

/* --- Header / footer chrome ---------------------------------- */
.blog-header,
.blog-footer,
.blog-index,
.post {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 clamp(1.1em, 4vw, 1.75em);
}

.blog-header { padding-top: 1.6em; padding-bottom: 0.5em; }

.blog-nav {
  display: flex;
  align-items: center;
  gap: 0.8em;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.blog-nav a { color: var(--ink-muted); }
.blog-nav a:hover { color: var(--ink-accent); }
.blog-nav-sep { color: var(--ink-muted); }

/* Comfortable tap targets (≥24px high) for the small chrome links. */
.blog-nav a,
.blog-footer a,
.post-section a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0.15em 0.1em;
}

.blog-footer {
  margin-top: auto;
  padding-top: 3em;
  padding-bottom: 2.5em;
  font-size: 0.82em;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.blog-footer a { color: var(--ink-muted); }
.blog-footer a:hover { color: var(--ink-accent); }

/* --- Blog index / section / tag pages ------------------------- */
.blog-index { padding-top: 2.5em; padding-bottom: 1em; }

.blog-index-title {
  color: var(--ink);
  font-size: 2em;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 0.25em;
}

.blog-index-intro {
  color: var(--ink-muted);
  font-size: 0.9em;
  line-height: 1.6;
  margin-bottom: 1.6em;
}

.blog-list {
  display: flex;
  flex-direction: column;
  gap: 1.1em;
}

.blog-empty { color: var(--ink-muted); }

/* --- Section tabs ---------------------------------------------- */
.blog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-bottom: 1.8em;
}

.blog-tab {
  display: inline-block;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-accent);
  border: 1px solid var(--ink-border);
  border-radius: 2em;
  padding: 0.5em 1.3em;
  /* explicit properties — `all` would animate the focus outline too */
  transition: color .25s ease, background-color .25s ease, border-color .25s ease;
}
.blog-tab:hover {
  color: var(--ink-accent);
  border-color: var(--ink-accent);
  background: rgba(3, 105, 161, 0.06);
}
.blog-tab.is-active {
  color: #ffffff;
  background: var(--ink-accent);
  border-color: var(--ink-accent);
}

.blog-tabs-empty {
  color: var(--ink-muted);
  font-size: 0.88em;
  margin: 1.5em 0;
}

/* --- Post cards ------------------------------------------------- */
.blog-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--ink-border);
  border-radius: 1em;
  padding: 1.4em 1.6em;
  color: var(--ink);
  box-shadow: 0 6px 22px rgba(31, 35, 40, 0.06);
  transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}
.blog-card:hover {
  color: var(--ink);
  border-color: var(--ink-accent);
  transform: translateY(-2px);
  box-shadow: 0 12px 34px rgba(31, 35, 40, 0.12);
}

/* Meta rows are flex so wrapped lines align flush (no hanging badge
   indent) and each item stays on one line. */
.blog-card-meta,
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.45em;
  row-gap: 0.3em;
}
.blog-card-meta > *,
.post-meta > * { white-space: nowrap; }

.blog-card-meta {
  font-size: 0.72em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.5em;
}
.blog-card-dot { margin: 0; }

.blog-sec-label {
  color: var(--ink-accent);
  font-weight: 700;
}

.blog-new-badge {
  display: inline-block;
  font-size: 11px;              /* never below 11px, wherever it lands */
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffffff;
  background: var(--ink-accent);
  border-radius: 2em;
  padding: 0.15em 0.8em;
  vertical-align: middle;
}

.blog-card-title {
  color: var(--ink);
  font-size: 1.18em;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.35em;
  transition: color .25s ease;
}
.blog-card:hover .blog-card-title { color: var(--ink-accent); }

.blog-card-desc {
  font-size: 0.86em;
  line-height: 1.65;
  color: var(--ink);
  opacity: 0.85;
}

.blog-card-tags { margin-top: 0.8em; }

/* Tag chip — link on post pages, plain span inside cards. */
.blog-tag {
  display: inline-block;
  font-size: 11.9px;            /* ≥11px everywhere */
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-accent);
  background: rgba(3, 105, 161, 0.07);
  border: 1px solid rgba(3, 105, 161, 0.28);
  border-radius: 2em;
  padding: 0.25em 0.9em;
  margin-right: 0.4em;
  transition: color .25s ease, background-color .25s ease, border-color .25s ease;
}
a.blog-tag:hover {
  color: #ffffff;
  background: var(--ink-accent);
  border-color: var(--ink-accent);
}

/* --- Tag cloud --------------------------------------------------- */
.blog-tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 2.2em;
}

.blog-cloud-tag {
  font-size: 0.78em;
  font-weight: 500;
  color: var(--ink-accent);
  border: 1px solid var(--ink-border);
  border-radius: 2em;
  padding: 0.35em 1em;
  transition: color .25s ease, background-color .25s ease, border-color .25s ease;
}
.blog-cloud-tag:hover {
  color: var(--ink-accent);
  border-color: var(--ink-accent);
  background: rgba(3, 105, 161, 0.06);
}
.blog-cloud-count { color: var(--ink-muted); font-weight: 400; }

/* --- Post page --------------------------------------------------- */
.post { padding-top: 2.5em; }

.post-header { margin-bottom: 2.2em; }

.post-section {
  font-size: 0.74em;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.8em;
}
.post-section a { color: var(--ink-accent); }
.post-section a:hover { color: var(--ink); }

.post-title {
  color: var(--ink);
  font-size: clamp(1.7em, 5vw, 2.3em);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
  margin-bottom: 0.5em;
}

.post-meta {
  font-size: 0.74em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.post-series {
  font-size: 0.8em;
  color: var(--ink-muted);
  margin-top: 0.7em;
}
.post-series strong { color: var(--ink); }

.post-tags { margin-top: 0.9em; }

/* --- Post body typography ----------------------------------------- */
.post-body > * + * { margin-top: 1.1em; }

.post-body h2,
.post-body h3,
.post-body h4 {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.35;
  margin-top: 1.9em;
}
.post-body h2 { font-size: 1.45em; }
.post-body h3 { font-size: 1.18em; }
.post-body h4 { font-size: 1em; letter-spacing: 0.04em; }

.post-body strong { color: var(--ink); font-weight: 700; }

.post-body a {
  color: var(--ink-accent);
  border-bottom: 1px solid rgba(3, 105, 161, 0.35);
}
.post-body a:hover { color: var(--ink); border-color: var(--ink); }

.post-body ul,
.post-body ol { padding-left: 1.5em; }
.post-body li + li { margin-top: 0.35em; }
.post-body li::marker { color: var(--ink-accent); }

.post-body hr {
  border: none;
  border-top: 1px solid var(--ink-border);
  margin: 2.2em 0;
}

.post-body img { max-width: 100%; height: auto; border-radius: 0.6em; }

/* Code — blocks stay DARK on the light page for contrast. */
.post-body code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85em;
  background: rgba(31, 35, 40, 0.06);
  border: 1px solid rgba(31, 35, 40, 0.1);
  border-radius: 0.35em;
  padding: 0.12em 0.4em;
  color: var(--ink);
}

.post-body pre {
  background: var(--code-bg);
  border: 1px solid rgba(31, 35, 40, 0.2);
  border-radius: 0.75em;
  padding: 1.1em 1.3em;
  overflow-x: auto;
  line-height: 1.6;
}
.post-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82em;
  color: #dbe3ef;
}

/* Horizontal-scroll containers (tables + diagrams) share a subtle
   right-edge fade hint. The fade sits on the STATIC wrapper, not the
   scroller, so it stays put while the content scrolls; over empty
   paper it's invisible (paper-on-paper). */
.scroll-fade { position: relative; }
.scroll-fade::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 28px;
  background: linear-gradient(to right, rgba(247, 247, 245, 0), var(--paper));
  pointer-events: none;
}

/* Tables (wrapped in .table-wrap > .table-scroll by build.mjs) */
.post-body .table-scroll { overflow-x: auto; }
.post-body table {
  width: 100%;
  min-width: 540px;    /* below this, scroll instead of crushing columns */
  border-collapse: collapse;
  font-size: 0.88em;
}
.post-body th,
.post-body td {
  border: 1px solid #d8dce3;
  padding: 0.55em 0.9em;
  text-align: left;
}
.post-body td { background: #ffffff; }   /* opaque: the dot grid must not show through */
.post-body th {
  background: #eef1f4;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.post-body tr:nth-child(even) td { background: #fbfbfa; }

/* Blockquotes */
.post-body blockquote {
  border-left: 3px solid rgba(3, 105, 161, 0.5);
  background: #eef1f4;
  border-radius: 0 0.6em 0.6em 0;
  padding: 0.9em 1.2em;
  color: var(--ink);
}
.post-body blockquote > * + * { margin-top: 0.7em; }

/* Callouts (built from blockquotes by scripts/blog/build.mjs).
   Light tints; label + body keep AA contrast on the tinted bg. */
.post-body .callout {
  border-radius: 0.75em;
  border: 1px solid;
  padding: 1em 1.25em;
}
.post-body .callout--analogy {
  border-color: rgba(91, 63, 212, 0.35);
  border-left: 3px solid #5b3fd4;
  background: #f3f0fd;
}
.post-body .callout--analogy > p:first-child > strong:first-child { color: #4c33bd; }
.post-body .callout--tldr {
  border-color: rgba(3, 105, 161, 0.35);
  border-left: 3px solid var(--ink-accent);
  background: #e9f3fa;
}
.post-body .callout--tldr > p:first-child > strong:first-child { color: var(--ink-accent); }
.post-body .callout strong:first-child { letter-spacing: 0.03em; }

/* Diagrams (mermaid → inline SVG at build time, light theme).
   build.mjs sets --dw to the diagram's natural width (viewBox px,
   where labels are 15px). Instead of squeezing into the column —
   which made labels 4–8px — the svg never shrinks below 0.8× its
   natural size on desktop (labels ≥12px) / 0.75× on phones (≥11px);
   anything wider scrolls horizontally behind the right-edge fade. */
.post-body .diagram {
  margin: 1.6em 0;
  text-align: center;
}
.post-body .diagram-scroll {
  overflow-x: auto;
  padding: 0.25em 0;
}
.post-body .diagram svg {
  width: clamp(calc(var(--dw, 700) * 0.8px), 100%, calc(var(--dw, 700) * 1px));
  height: auto;
  display: inline-block;
}
@media (max-width: 700px) {
  .post-body .diagram svg {
    width: clamp(calc(var(--dw, 700) * 0.75px), 100%, calc(var(--dw, 700) * 1px));
  }
}
/* Safety net for the 1–2px label clipping class of bugs: let
   foreignObject HTML labels paint outside their measured box. */
.post-body .diagram svg foreignObject { overflow: visible; }
.post-body .diagram figcaption {
  margin-top: 0.7em;
  font-size: 0.78em;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

/* --- Post footer nav (prev/next + more in section) --------------- */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin-top: 3em;
  padding-top: 1.6em;
  border-top: 1px solid var(--ink-border);
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  max-width: 48%;
}
.post-nav-newer { text-align: right; margin-left: auto; }

.post-nav-dir {
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.post-nav-title {
  font-size: 0.88em;
  font-weight: 600;
  color: var(--ink-accent);
  line-height: 1.4;
}
.post-nav-link:hover .post-nav-title { color: var(--ink); }

.post-more {
  margin-top: 2.6em;
  padding-top: 1.6em;
  border-top: 1px solid var(--ink-border);
}

.post-more-title {
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1em;
}
.post-more-title a { color: var(--ink-accent); }
.post-more-title a:hover { color: var(--ink); }

.post-more-empty {
  font-size: 0.88em;
  color: var(--ink-muted);
}

/* --- Mobile -------------------------------------------------------- */
@media (max-width: 600px) {
  body.blog { font-size: 17px; }
  .blog-card { padding: 1.2em 1.25em; }
  .post-body pre { padding: 0.9em 1em; }
  .post-nav { flex-direction: column; }
  .post-nav-link { max-width: 100%; }
  .post-nav-newer { text-align: left; margin-left: 0; }
}
