/*
 * Blog styles: the post list and the article layout.
 * Needs ../tokens.css and ../chrome.css first (or ../../ from a post).
 */

/* Colours for terms highlighted inside posts. Text needs to stay readable
   on light paper, so the light values are deeper than the dark ones. */
:root {
  --panel: #F3F5FA;
  --code-bg: #15183A; --code-ink: #E8EBF4;
  --c-old: #0E8C6B; --c-old-rgb: 14, 140, 107;     /* cached / reused */
  --c-row: #D8431D; --c-row-rgb: 242, 85, 44;      /* new row */
  --c-col: #5B3FE0; --c-col-rgb: 91, 63, 224;      /* new column */
  --c-hit: #B57B00; --c-hit-rgb: 255, 176, 0;      /* overlap / active */
  --c-v: #0E7FA0;                                  /* value projection */
}
[data-theme="dark"] {
  --panel: #151940;
  --code-bg: #070920; --code-ink: #E6E8F5;
  --c-old: #3DDBA8; --c-old-rgb: 61, 219, 168;
  --c-row: #FF7A52; --c-row-rgb: 255, 122, 82;
  --c-col: #A595FF; --c-col-rgb: 165, 149, 255;
  --c-hit: #FFC233; --c-hit-rgb: 255, 194, 51;
  --c-v: #6FD3F2;
}

body { line-height: 1.6; }

/* reading progress, inside the top bar */
.reading-progress {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%;
  background: linear-gradient(90deg, var(--violet), var(--ember), var(--amber));
  transform-origin: 0 50%; transform: scaleX(0);
}

/* ---------- post list ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 48px); }
.list-head {
  display: grid; grid-template-columns: 1fr minmax(0, 26em); gap: 32px; align-items: end;
  padding: clamp(48px, 10vh, 110px) 0 clamp(36px, 6vh, 64px);
  margin-bottom: clamp(36px, 6vh, 56px); border-bottom: 1.5px solid var(--ink);
}
.list-head h1 {
  font-family: var(--display); font-weight: 780; font-variation-settings: "wdth" 80;
  font-size: clamp(3rem, 10vw, 8rem); line-height: .9; letter-spacing: -.01em; margin: 0;
}
.list-head p { margin: 0; color: var(--ink-soft); }
.post-list { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; padding-bottom: 96px; }
.post-card {
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
  min-height: 330px; padding: clamp(24px, 3vw, 36px); border-radius: 16px; text-decoration: none;
  background: var(--card); color: #E8EBF4;
}
.post-card:nth-child(2n) { background: var(--violet); }
.post-card h2 { font-family: var(--display); font-weight: 740; font-size: clamp(1.8rem, 3.2vw, 2.6rem); letter-spacing: -.015em; line-height: 1; margin: 0 0 14px; max-width: 13ch; }
.post-card p { margin: 0 0 20px; opacity: .82; max-width: 32ch; }
.post-card .meta { font-size: .88rem; opacity: .7; }
.post-card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.post-card .tags span { font-size: .78rem; padding: 3px 10px; border-radius: 999px; background: rgba(232, 235, 244, .14); }
.post-card canvas { position: absolute; right: -6px; top: -6px; width: 150px; height: 150px; opacity: .9; }
.post-card:hover h2 { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
.list-empty { color: var(--ink-soft); }
@media (max-width: 820px) {
  .list-head, .post-list { grid-template-columns: 1fr; }
  .post-card canvas { width: 110px; height: 110px; }
}

/* ---------- article header ---------- */
.article-head { max-width: 1180px; margin: 0 auto; padding: clamp(40px, 8vh, 96px) clamp(20px, 4vw, 48px) clamp(28px, 5vh, 48px); }
.article-head .crumbs { font-size: .92rem; color: var(--ink-soft); margin: 0 0 22px; }
.article-head .crumbs a { text-decoration: none; }
.article-head .crumbs a:hover { text-decoration: underline; text-underline-offset: 4px; }
.article-head h1 {
  font-family: var(--display); font-weight: 780; font-variation-settings: "wdth" 80;
  font-size: clamp(2.8rem, 8vw, 6.6rem); line-height: .92; letter-spacing: -.01em; margin: 0 0 26px; max-width: 12ch;
}
.article-head .dek { font-size: clamp(1.1rem, 1.6vw, 1.3rem); color: var(--ink-soft); max-width: 36em; margin: 0 0 22px; }
.article-head .meta { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: .92rem; color: var(--ink-soft); }
.article-head .meta .tag { padding: 3px 11px; border-radius: 999px; background: var(--paper-2); color: var(--ink); font-size: .82rem; }

/* ---------- article body with a contents rail ---------- */
.article-grid {
  max-width: 1180px; margin: 0 auto; padding: clamp(32px, 5vh, 56px) clamp(20px, 4vw, 48px) 96px;
  display: grid; grid-template-columns: 200px minmax(0, 760px); gap: clamp(32px, 6vw, 90px);
  /* rule aligned with the content edges, not the padding */
  background: linear-gradient(var(--ink), var(--ink)) top center / calc(100% - 2 * clamp(20px, 4vw, 48px)) 1.5px no-repeat;
}
.toc { position: sticky; top: 90px; align-self: start; font-size: .9rem; }
.toc p { margin: 0 0 10px; color: var(--ink-soft); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1.5px solid var(--cold); }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1.5px; border-left: 1.5px solid transparent; text-decoration: none; color: var(--ink-soft); line-height: 1.35; }
.toc a:hover { color: var(--ink); }
.toc a.is-current { color: var(--ink); border-left-color: var(--ember); font-weight: 700; }
@media (max-width: 980px) { .article-grid { grid-template-columns: 1fr; } .toc { display: none; } }

#blog-post { min-width: 0; }
#blog-post > h1, #blog-post .post-header-meta { display: none; } /* shown in .article-head instead */
#blog-post p { margin: 1rem 0; line-height: 1.75; }
#blog-post h2 {
  font-family: var(--display); font-weight: 720; font-variation-settings: "wdth" 88;
  font-size: clamp(1.7rem, 3vw, 2.3rem); letter-spacing: -.025em; line-height: 1.05;
  margin: 3.6rem 0 1rem; scroll-margin-top: 90px;
}
#blog-post h3 { font-family: var(--display); font-weight: 680; font-size: 1.3rem; letter-spacing: -.015em; margin: 2.4rem 0 .6rem; }
#blog-post ul { margin: 1.1rem 0 1.4rem 1.2rem; padding: 0; }
#blog-post li { margin: .45rem 0; }
#blog-post a { color: var(--line); text-underline-offset: 3px; }
#blog-post strong { font-weight: 700; }
#blog-post hr { border: none; height: 0; margin: 3rem 0 0; }
#blog-post pre { background: var(--code-bg); color: var(--code-ink); padding: 1.1rem 1.3rem; border-radius: 12px; overflow-x: auto; line-height: 1.55; font-size: .92rem; margin: 1.4rem 0; }
#blog-post code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
#blog-post :not(pre) > code { background: var(--paper-2); padding: .1em .35em; border-radius: 5px; }
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; max-width: 100%; padding: .2rem 0; }

.next-posts { margin-top: 4.5rem; padding-top: 1.6rem; border-top: 1.5px solid var(--ink); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.next-posts a { font-family: var(--display); font-weight: 650; text-decoration: none; }
.next-posts a:hover { text-decoration: underline; text-underline-offset: 4px; }
.next-posts span { display: block; font-family: var(--body); font-weight: 400; font-size: .85rem; color: var(--ink-soft); }
