/* ─── Blog layout styles ─────────────────────────────────────────────────── */

/* Font-face rules reference /fonts/ absolute path (root-relative for CF Pages) */
/* latin */
@font-face {
  font-family: 'Spectral';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url(/fonts/rnCu-xNNww_2s0amA9M8qtHEWfSFXQ.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin */
@font-face {
  font-family: 'Spectral';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(/fonts/rnCs-xNNww_2s0amA9uSsG3BafY.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin */
@font-face {
  font-family: 'Spectral';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/fonts/rnCs-xNNww_2s0amA9vKsW3BafY.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --paper: #ffffff;
  --ink: #0f1111;
  --ink-muted: rgba(15, 17, 17, 0.58);
  --ink-mid: rgba(15, 17, 17, 0.82);
  --accent: rgba(15, 17, 17, 0.35);

  --aside-width: 200px;
  --aside-gap: 64px;
  --content-max: 780px;
  --page-pad-x: 48px;
  --page-pad-top: 56px;

  --text-nav: 13px;
  --text-body: 18px;
  --text-h1: 30px;
  --text-h2: 21px;
  --text-time: 14px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

html,
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Spectral', serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: #95E78E;
  color: #062C02;
}

:focus-visible {
  outline: 2px solid #0047CC;
  outline-offset: 3px;
  border-radius: 2px;
}

/* ─── Page shell ─────────────────────────────────────────────────────────── */

.blog-shell {
  display: grid;
  grid-template-columns: 1fr minmax(0, var(--content-max)) 1fr;
  min-height: 100dvh;
  padding: var(--page-pad-top) var(--page-pad-x);
}

/* ─── Left aside ─────────────────────────────────────────────────────────── */

.blog-aside {
  grid-column: 1;
  justify-self: end;
  width: var(--aside-width);
  margin-right: var(--aside-gap);
  position: sticky;
  top: var(--page-pad-top);
  align-self: start;
  height: calc(100dvh - var(--page-pad-top) * 2);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.blog-shell>main {
  grid-column: 2;
  min-width: 0;
}

@media (max-width: 1284px) {
  .blog-shell {
    grid-template-columns: 1fr;
  }

  .blog-aside {
    grid-column: 1;
    justify-self: start;
    width: auto;
    margin-right: 0;
    position: static;
    height: auto;
    margin-bottom: 40px;
  }

  .blog-shell>main {
    grid-column: 1;
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
  }
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'Spectral', serif;
  font-weight: 300;
  font-size: var(--text-nav);
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  transition: color 120ms var(--ease-out);
}

.back-link:hover {
  color: var(--ink);
}

.back-link svg {
  flex-shrink: 0;
  stroke: currentColor;
}

/* TOC nav */
.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.toc-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.toc-nav li a {
  display: block;
  padding: 5px 0;
  font-family: 'Spectral', serif;
  font-weight: 300;
  font-size: var(--text-nav);
  color: var(--ink-muted);
  line-height: 1.4;
  transition: color 120ms var(--ease-out);
}

.toc-nav li a:hover {
  color: var(--ink);
}

.toc-nav li a.toc-active {
  color: var(--ink);
}

/* ─── Blog index list (used only on index.html) ──────────────────────────── */

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.post-list-item {
  display: grid;
  gap: 4px;
}

.post-list-item time {
  font-size: var(--text-time);
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}

.post-list-item a {
  font-size: 20px;
  font-weight: 300;
  color: var(--ink);
  line-height: 1.35;
  text-decoration-thickness: 0.25px;
  text-underline-offset: 4px;
}

.post-list-item a:hover {
  text-decoration-line: underline;
}

@media (max-width: 640px) {
  :root {
    --page-pad-x: 24px;
    --page-pad-top: 40px;
    --aside-gap: 32px;
  }

  .back-link {
    padding: 12px 0;
  }

  .toc-nav li a {
    padding: 10px 0;
  }
}

.post-list-item .post-summary {
  font-size: var(--text-body);
  color: var(--ink-muted);
  line-height: 1.55;
  margin: 0;
  margin-top: 2px;
}

/* ─── Article ────────────────────────────────────────────────────────────── */

article {
  max-width: var(--content-max);
  padding-bottom: 120px;
}

article header {
  margin-bottom: 64px;
}

article header h1 {
  font-family: 'Spectral', serif;
  font-weight: 300;
  font-size: var(--text-h1);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 10px 0;
  color: var(--ink);
}

article header time {
  display: block;
  font-size: var(--text-time);
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}

/* Section headings with hr divider (benji.org style) */
article .section-heading {
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: center;
  gap: 16px;
  margin: 64px 0 24px;
}

article .section-heading hr {
  border: none;
  border-top: 1px solid rgba(15, 17, 17, 0.12);
  margin: 0;
  flex: 1;
}

article .section-heading h2 {
  font-family: 'Spectral', serif;
  font-weight: 500;
  font-size: var(--text-h2);
  line-height: 1.2;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

article p {
  font-size: var(--text-body);
  line-height: 1.75;
  color: var(--ink-mid);
  margin: 0 0 24px 0;
}

article ul,
article ol {
  padding-left: 20px;
  margin: 0 0 20px 0;
}

article li {
  font-size: var(--text-body);
  line-height: 1.7;
  color: var(--ink-mid);
  margin-bottom: 8px;
}

article code {
  font-family: 'SF Mono', 'Fira Mono', monospace;
  font-size: 0.9em;
  background: rgba(15, 17, 17, 0.05);
  padding: 1px 5px;
  border-radius: 3px;
}

article strong {
  font-weight: 500;
  color: var(--ink);
}

article em {
  font-style: italic;
}

article blockquote {
  margin: 24px 0;
  padding: 0 0 0 20px;
  border-left: 2px solid rgba(15, 17, 17, 0.2);
  color: var(--ink-muted);
  font-style: italic;
}

article a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 4px;
  text-decoration-color: rgba(15, 17, 17, 0.35);
}

article a:hover {
  text-decoration-color: var(--ink);
  text-decoration-thickness: 1px;
}

/* ─── Index page header ──────────────────────────────────────────────────── */

.blog-index-header {
  margin-bottom: 52px;
}

.blog-index-header h1 {
  font-family: 'Spectral', serif;
  font-weight: 300;
  font-size: var(--text-h1);
  letter-spacing: -0.02em;
  margin: 0 0 8px 0;
}

.blog-index-header p {
  font-size: var(--text-body);
  color: var(--ink-muted);
  margin: 0;
}

/* ─── Article lede ───────────────────────────────────────────────────────── */

article .article-lede {
  font-size: 19px;
  line-height: 1.75;
  color: var(--ink);
  margin-bottom: 36px;
}

/* ─── Key findings callout ───────────────────────────────────────────────── */

.key-findings {
  margin: 8px 0 40px;
  padding: 20px 0;
  border-top: 1px solid rgba(15, 17, 17, 0.12);
  border-bottom: 1px solid rgba(15, 17, 17, 0.12);
}

.key-findings-label {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 14px;
  font-weight: 500;
  font-family: 'Spectral', serif;
}

.key-findings-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.key-findings-list li {
  font-size: var(--text-body);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.5;
  margin: 0;
  padding-left: 14px;
  position: relative;
}

.key-findings-list li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--ink-muted);
  font-weight: 300;
}

/* ─── Article figures ────────────────────────────────────────────────────── */

article .article-figure {
  margin: 40px -60px;
}

article .article-figure img {
  width: 100%;
  display: block;
  height: auto;
}

@media (max-width: 640px) {
  article .article-figure {
    margin-left: calc(-1 * var(--page-pad-x));
    margin-right: calc(-1 * var(--page-pad-x));
  }
  article .article-figure img {
    width: 100%;
    min-width: unset;
  }
  article figcaption {
    padding: 0;
  }
  article .section-heading {
    display: block;
  }
  article .section-heading h2 {
    white-space: normal;
    margin-bottom: 8px;
  }
  article .section-heading hr {
    display: block;
  }
}

article figcaption {
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-mid);
  font-style: italic;
  padding: 0 60px;
}

/* ─── H3 subheadings ─────────────────────────────────────────────────────── */

article h3 {
  font-family: 'Spectral', serif;
  font-weight: 500;
  font-size: 19px;
  line-height: 1.35;
  margin: 36px 0 12px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */

article table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: var(--text-body);
  line-height: 1.5;
}

article th {
  text-align: left;
  font-family: 'Spectral', serif;
  font-weight: 500;
  font-size: var(--text-body);
  color: var(--ink);
  border-bottom: 1px solid rgba(15, 17, 17, 0.18);
  padding: 0 16px 10px 0;
  letter-spacing: 0.01em;
}

article th:last-child {
  padding-right: 0;
}

article td {
  font-family: 'Spectral', serif;
  font-weight: 300;
  color: var(--ink-mid);
  border-bottom: 1px solid rgba(15, 17, 17, 0.07);
  padding: 9px 16px 9px 0;
  vertical-align: top;
  font-size: var(--text-body);
}

article td:last-child {
  padding-right: 0;
}

article td.col-center,
article th.col-center {
  text-align: center;
}

article td.col-strong {
  font-weight: 500;
  color: var(--ink);
}

article tbody tr:last-child td {
  border-bottom: none;
}

/* ─── Code blocks ────────────────────────────────────────────────────────── */

article pre {
  margin: 24px 0;
  padding: 18px 20px;
  background: rgba(15, 17, 17, 0.04);
  border-radius: 4px;
  overflow-x: auto;
}

article pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-family: 'SF Mono', 'Fira Mono', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-mid);
}

/* ─── References list ────────────────────────────────────────────────────── */

article .references-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

article .references-list li {
  font-size: var(--text-body);
  line-height: 1.6;
  color: var(--ink-mid);
  margin: 0;
}

/* ─── Highlight / underline styles (10 variants) ────────────────────────── */
/*
  4 site colors (OKLCH → hex):
    Orange  fg #b54800   bg #ffe2cf
    Blue    fg #1442be   bg #d7e8ff
    Purple  fg #6f2c96   bg #f2dfff
    Green   fg #00722e   bg #d9f3dd
*/

/* 1 — Orange marker: solid warm background */
.hl-mark-orange {
  background: #ffe2cf;
  color: #b54800;
  padding: 0 3px;
  border-radius: 2px;
  font-weight: inherit;
}

/* 2 — Blue marker: cool technical highlight */
.hl-mark-blue {
  background: #d7e8ff;
  color: #1442be;
  padding: 0 3px;
  border-radius: 2px;
  font-weight: inherit;
}

/* 3 — Purple marker: statistical / methodological */
.hl-mark-purple {
  background: #f2dfff;
  color: #6f2c96;
  padding: 0 3px;
  border-radius: 2px;
  font-weight: inherit;
}

/* 4 — Green marker: positive finding */
.hl-mark-green {
  background: #d9f3dd;
  color: #00722e;
  padding: 0 3px;
  border-radius: 2px;
  font-weight: inherit;
}

/* p-value: very light green tint */
.hl-p-value {
  background: #edf8ee;
  color: #007a30;
  padding: 0 2px;
  border-radius: 2px;
}

/* 5 — Orange wavy underline: danger / threshold */
.hl-wave-orange {
  text-decoration: underline wavy #b54800;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

/* 6 — Blue dashed underline: secondary technical term */
.hl-dash-blue {
  text-decoration: underline dashed #1442be;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

/* 7 — Purple solid bar underline: key comparison term */
.hl-bar-purple {
  border-bottom: 2.5px solid #6f2c96;
  padding-bottom: 1px;
}

/* 8 — Green double underline: methodology term */
.hl-double-green {
  text-decoration: underline double #00722e;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* 9 — Orange text only: "Finding:" labels */
.hl-text-orange {
  color: #b54800;
  font-weight: 600;
}

/* 10 — Blue italic glow: author citations */
.hl-glow-blue {
  color: #1442be;
  font-style: italic;
  text-shadow: 0 0 10px rgba(20, 66, 190, 0.25);
}
