/* blog.css — /blog/, its categories and every post.

   ⚠️ No colour is written here: every one is a token from tokens.css, so the
   blog follows light and dark with the rest of the site and a palette change
   reaches it with no edit. Sizes follow the old-site scale in site.css (body
   17px); the reading column is narrower than the page on purpose — about 70
   Persian characters a line, where long-form text stops being tiring. */

/* ---- Listing ------------------------------------------------------------- */
.blog-intro { grid-template-columns: 1fr; min-height: 0; }
/* The listing's heading at the post title's size, not the landing hero's.
   `.page-intro h1` takes --fs-h1 (up to 76px), which is right for the one hero
   of the site and shouted on a list of articles (operator, 30 Shahrivar 1405). */
.blog-intro h1 { font-size: clamp(1.9rem, 4.6vw, 2.75rem); line-height: 1.35; letter-spacing: -.02em; }
.blog-intro p { font-size: clamp(1rem, 1.6vw, 1.125rem); line-height: 1.9; }

/* ---- Tone, glyph and drawn cover — 7 Aban 1405 (DONE 8.94) ----------------
   Every post carries one of the six pastel tones of the «دنیای تک» cards. A
   tone class sets two properties and everything below is mixed from them, so
   the art is the same drawing in six colours and in both themes: --t-bg is
   already a translucent wash in dark mode, and --t a lighter ink there.
   color-mix() needs Chrome 111 / Safari 16.2 / Firefox 113; an older browser
   drops those declarations and keeps the plain --t-bg underneath. */
.blog-tone-orange { --t: var(--p-orange); --t-bg: var(--p-orange-bg); }
.blog-tone-blue   { --t: var(--p-blue);   --t-bg: var(--p-blue-bg); }
.blog-tone-mint   { --t: var(--p-mint);   --t-bg: var(--p-mint-bg); }
.blog-tone-lilac  { --t: var(--p-lilac);  --t-bg: var(--p-lilac-bg); }
.blog-tone-rose   { --t: var(--p-rose);   --t-bg: var(--p-rose-bg); }
.blog-tone-butter { --t: var(--p-butter); --t-bg: var(--p-butter-bg); }

/* The drawn cover (site/blog/_art.html): a glass tile with the glyph, two
   rings around it, a dot field fading from one corner, two small satellites,
   and the glyph again — large, faint and turned — behind everything. The
   rings and the tile are centred with left/translate, not inset-inline, so
   they sit in the same place whichever way the page runs. */
.blog-art {
  --tile: 76px;
  position: relative; display: block; overflow: hidden; isolation: isolate;
  aspect-ratio: 1200 / 630; color: var(--t);
  background-color: var(--t-bg);
  background-image:
    radial-gradient(48% 70% at 50% 50%, color-mix(in srgb, var(--t) 24%, transparent), transparent 72%),
    radial-gradient(55% 85% at 0% 100%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%),
    linear-gradient(155deg, var(--t-bg), color-mix(in srgb, var(--t-bg) 40%, var(--surface-2)));
}
.blog-art::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: radial-gradient(color-mix(in srgb, var(--t) 45%, transparent) 1.1px, transparent 1.7px);
  background-size: 16px 16px;
  -webkit-mask-image: radial-gradient(75% 95% at 100% 0%, var(--ink), transparent 72%);
          mask-image: radial-gradient(75% 95% at 100% 0%, var(--ink), transparent 72%);
}
.blog-art::after {
  content: ""; position: absolute; top: 16%; left: 22%; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 46px -6px 0 -2px color-mix(in srgb, var(--t) 70%, transparent),
              calc(var(--tile) * 2.6) calc(var(--tile) * 1.5) 0 -1px color-mix(in srgb, var(--t) 55%, transparent);
}
.blog-art-rings {
  position: absolute; left: 50%; top: 50%; width: calc(var(--tile) * 1.75); aspect-ratio: 1;
  border-radius: 50%; transform: translate(-50%, -50%);
  border: 1px solid color-mix(in srgb, var(--t) 32%, transparent);
  box-shadow: 0 0 0 calc(var(--tile) * .34) color-mix(in srgb, var(--t) 6%, transparent),
              0 0 0 calc(var(--tile) * .34 + 1px) color-mix(in srgb, var(--t) 20%, transparent),
              0 0 0 calc(var(--tile) * .8) color-mix(in srgb, var(--t) 3%, transparent),
              0 0 0 calc(var(--tile) * .8 + 1px) color-mix(in srgb, var(--t) 12%, transparent);
}
.blog-art-tile {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: grid; place-items: center; width: var(--tile); height: var(--tile);
  border-radius: calc(var(--tile) * .3);
  background: linear-gradient(160deg, color-mix(in srgb, var(--surface) 94%, transparent),
                                      color-mix(in srgb, var(--surface) 68%, transparent));
  border: 1px solid color-mix(in srgb, var(--t) 30%, transparent);
  box-shadow: inset 0 1px 0 var(--highlight),
              0 16px 32px -14px color-mix(in srgb, var(--t) 70%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: transform .35s;
}
.blog-art-tile svg { width: 52%; height: 52%; stroke-width: 1.5; --glyph-accent: var(--accent); }
.blog-art-mark {
  position: absolute; left: -5%; bottom: -24%; width: 48%; height: auto; aspect-ratio: 1;
  opacity: .14; stroke-width: 1.1; transform: rotate(-14deg); transition: transform .5s;
}

.blog-cats { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 26px; }
.blog-cats a {
  padding: 7px 16px; border-radius: 999px; font-size: .9375rem;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
}
.blog-cats a:hover { border-color: var(--accent-line); color: var(--accent-dark); }
.blog-cats a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-dark); font-weight: 600; }

/* ---- Cards --------------------------------------------------------------- */
.blog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.blog-card { display: flex; }
.blog-card-link {
  display: flex; flex-direction: column; width: 100%; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.blog-card-link:hover {
  transform: translateY(-4px); border-color: color-mix(in srgb, var(--t) 45%, var(--line));
  box-shadow: 0 22px 40px -22px color-mix(in srgb, var(--t) 75%, transparent), 0 2px 6px var(--shadow);
}
.blog-card-link:hover .blog-art-tile { transform: translate(-50%, -50%) scale(1.07) rotate(-4deg); }
.blog-card-link:hover .blog-art-mark { transform: rotate(-6deg) scale(1.05); }
.blog-card .blog-art, .blog-card-img { border-bottom: 1px solid var(--line); }
.blog-card-img { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 630; object-fit: cover; background: var(--surface-2); }
.blog-card-body { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 18px; flex: 1; }
.blog-card-kicker { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.blog-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 2px 11px; border-radius: var(--r-pill);
  font-size: var(--t-micro); font-weight: 600; line-height: 1.9; color: var(--ink-2);
  background: color-mix(in srgb, var(--t) 11%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--t) 26%, transparent);
}
.blog-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--t); }
.blog-card-time { font-size: var(--t-micro); color: var(--muted-2); white-space: nowrap; }
.blog-card-title { font-size: 1.125rem; font-weight: 800; line-height: 1.65; margin: 0; color: var(--ink); }
.blog-card-excerpt { font-size: var(--t-body); line-height: 1.95; color: var(--muted); flex: 1; }
.blog-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--line-2);
  font-size: var(--t-micro); color: var(--muted-2);
}
.blog-card-go { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent-dark); }
.blog-card-go svg { width: 16px; height: 16px; transition: transform .25s; }
.blog-card-link:hover .blog-card-go svg { transform: translateX(-4px); }
.blog-empty { color: var(--muted); padding: 30px 0; }

.blog-pages { display: flex; justify-content: center; align-items: center; gap: 22px; margin: 34px 0 0; font-size: .9375rem; color: var(--muted); }
.blog-pages a { padding: 8px 16px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); }

/* ---- One post ------------------------------------------------------------ */
.blog-post { max-width: 760px; margin: 0 auto; }
.blog-preview {
  max-width: 760px; margin: 18px auto 0; padding: 12px 18px; border-radius: 14px; font-size: .9375rem;
  background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn-ink);
}
/* The head: a panel in the post's tone, words on the start side and the same
   drawn art as the post's card on the end side; one column on a phone, the art
   on top as a band. 7 Aban 1405 (DONE 8.94). */
.blog-post-head {
  display: grid; grid-template-columns: minmax(0, 1fr) 34%; margin: 30px 0 28px; overflow: hidden;
  border-radius: 24px; border: 1px solid color-mix(in srgb, var(--t) 24%, var(--line));
  background: linear-gradient(to left, var(--surface) 45%, color-mix(in srgb, var(--t) 9%, var(--surface)));
  box-shadow: 0 24px 50px -36px color-mix(in srgb, var(--t) 80%, transparent);
}
.blog-post-head .blog-art { order: 2; aspect-ratio: auto; min-height: 100%; --tile: 84px; }
.blog-post-head-text { padding: 28px 30px 24px; min-width: 0; }
.blog-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--t-small); color: var(--muted); margin-bottom: 10px; }
.blog-crumb a { color: var(--accent-dark); }
.blog-post-head h1 { font-size: clamp(1.75rem, 3.9vw, 2.4rem); line-height: 1.45; letter-spacing: -.02em; margin: 0 0 14px; }
.blog-lead { font-size: var(--fs-lead, 1.1875rem); line-height: 1.85; color: var(--muted); margin: 0 0 16px; }
.blog-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.blog-meta > span {
  padding: 2px 12px; border-radius: var(--r-pill); font-size: var(--t-micro); line-height: 1.9;
  color: var(--muted); background: color-mix(in srgb, var(--surface-2) 80%, transparent); border: 1px solid var(--line);
}
.blog-cover { margin: 0 0 30px; }
.blog-cover img { display: block; width: 100%; height: auto; border-radius: 18px; border: 1px solid var(--line); }

.blog-toc { margin: 0 0 30px; padding: 16px 22px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.blog-toc summary { cursor: pointer; font-weight: 700; color: var(--ink); }
/* No automatic numbers: a heading that already reads «۱. …» came out «1. ۱. …»
   (router post, 30 Shahrivar 1405). The entries show what the author wrote. */
.blog-toc ol { margin: 12px 0 0; padding: 0; list-style: none; line-height: 2.1; }
.blog-toc .toc-l3 { margin-inline-start: 18px; font-size: .9375rem; }
.blog-toc a { color: var(--ink-2); }
.blog-toc a:hover { color: var(--accent-dark); }

/* The body: text written in the admin, tags written by blog/markup.py. */
.blog-body { font-size: 1.0625rem; line-height: 2.05; color: var(--ink-2); }
.blog-body > * { margin: 0 0 20px; }
.blog-body h2 { font-size: 1.5rem; line-height: 1.5; color: var(--ink); margin: 40px 0 14px; scroll-margin-top: 90px; }
.blog-body h3 { font-size: 1.1875rem; line-height: 1.6; color: var(--ink); margin: 30px 0 10px; scroll-margin-top: 90px; }
.blog-body p { text-align: justify; text-align-last: start; }
.blog-body a { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 4px; }
.blog-body strong { color: var(--ink); }
.blog-body ul, .blog-body ol { padding-inline-start: 26px; }
.blog-body ol { list-style-type: persian; }   /* «۱.» like the text around it, not «1.» */
.blog-body li { margin-bottom: 6px; }
.blog-body li > ul, .blog-body li > ol { margin-top: 6px; }
.blog-body code {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: .9em; unicode-bidi: isolate;
  padding: 2px 7px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
}
.blog-body pre {
  direction: ltr; text-align: left; overflow-x: auto; padding: 16px 18px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line); line-height: 1.7;
}
.blog-body pre code { padding: 0; border: 0; background: none; font-size: .9375rem; }
.blog-body blockquote {
  padding: 4px 20px; border-inline-start: 4px solid var(--line-2); color: var(--muted);
}
.blog-body blockquote > :last-child, .callout > :last-child { margin-bottom: 0; }
.blog-body hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }
.blog-body figure { margin: 26px 0; }
.blog-body figure img, .blog-body figure video {
  display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 14px; border: 1px solid var(--line);
}
.blog-body figcaption { text-align: center; font-size: .875rem; color: var(--muted); margin-top: 8px; }
.blog-body .table-wrap { overflow-x: auto; }
.blog-body table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.blog-body th, .blog-body td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: start; }
.blog-body th { color: var(--ink); background: var(--surface-2); }
.blog-embed { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.blog-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.blog-missing { padding: 12px 16px; border-radius: 12px; background: var(--bad-soft); border: 1px solid var(--bad-line); color: var(--bad-ink); }

.callout { padding: 14px 20px; border-radius: 14px; border: 1px solid; }
.callout .callout-title { font-weight: 700; margin: 0 0 4px; }
.callout-tip       { background: var(--ok-soft);   border-color: var(--ok-line);   color: var(--ok-ink); }
.callout-warn      { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.callout-important { background: var(--info-soft); border-color: var(--info-line); color: var(--info-ink); }
.callout p { text-align: start; }

.blog-cta {
  margin: 40px 0 0; padding: 22px 24px; border-radius: 18px;
  background: linear-gradient(120deg, var(--mint-soft), var(--accent-soft)); border: 1px solid var(--mint-line);
}
.blog-cta p { margin: 0 0 12px; line-height: 2; }
.blog-cta-actions { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 !important; }
.blog-cta .button { padding: 11px 20px; font-size: .9375rem; }
.blog-related { margin-top: 60px; }
.blog-related > h2 { font-size: 1.5rem; margin: 0 0 20px; }

@media (max-width: 1000px) { .blog-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .blog-grid { grid-template-columns: 1fr; }
  .blog-post-head { grid-template-columns: 1fr; margin-top: 18px; border-radius: var(--r-lg); }
  .blog-post-head .blog-art { order: 0; aspect-ratio: 5 / 2; min-height: 0; --tile: 64px; }
  .blog-post-head-text { padding: 20px 18px 18px; }
  .blog-body { font-size: 1rem; line-height: 2; }
  .blog-body p, .blog-lead { text-align: start; }   /* narrow columns + justify = rivers */
}
