/* ==========================================================================
   Articles — long-form typography for /articles/
   Loaded after style.css, which supplies the palette tokens and the chrome
   (header, footer, buttons). Everything here is scoped under .article-page,
   .article, .artlist* so it cannot reach the README-driven home page, whose
   .prose rules are tuned for link lists rather than running prose.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Article header
   -------------------------------------------------------------------------- */
.article-head { padding: 46px 0 0; }
.article-head .eyebrow a { color: var(--slate); text-decoration: none; }
.article-head .eyebrow a:hover { color: var(--accent-tx); }
.article-head .eyebrow .sep { margin: 0 6px; opacity: .5; }

.article-head h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 4.6vw, 3.15rem);
  line-height: 1.08;
  letter-spacing: -.022em;
  color: var(--ink);
  margin: 10px 0 0;
  max-width: 20ch;
}

.article-sub {
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  line-height: 1.45;
  color: var(--ink-soft);
  font-weight: 400;
  margin: 14px 0 0;
  max-width: 46ch;
}

.article-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px;
  margin: 22px 0 0;
  font-family: var(--font-display);
  font-size: .8rem; font-weight: 500; letter-spacing: .04em;
  color: var(--muted);
}
.article-meta .sep { opacity: .5; }

.article-cover { margin: 34px 0 0; }
.article-cover img {
  display: block; width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.article-cover figcaption {
  margin-top: 10px;
  font-size: .8rem; color: var(--muted);
  font-family: var(--font-display); font-weight: 500;
}

/* --------------------------------------------------------------------------
   Article body — a single readable measure, figures allowed to breathe wider
   -------------------------------------------------------------------------- */
.article {
  padding: 8px 0 24px;
  font-size: 1.06rem;
  line-height: 1.68;
  color: var(--ink-soft);
}

/* One left rail: text wraps at 68ch, wide elements (figures, tables, code)
   extend right to 84ch. Everything shares the same left edge — the text rules
   below reset margins, so wide elements must not be centred either. */
.article > * { max-width: 68ch; margin-left: 0; margin-right: auto; }

.article p { margin: 0 0 1.15em; }

.article h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -.015em;
  color: var(--ink);
  margin: 2.1em 0 .55em;
  padding-top: .35em;
  border-top: 1px solid var(--line-soft);
  scroll-margin-top: 84px;
}

.article h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.18rem;
  line-height: 1.3;
  color: var(--ink);
  margin: 1.9em 0 .45em;
  scroll-margin-top: 84px;
}

.article h4 {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.02rem;
  color: var(--ink); margin: 1.6em 0 .4em;
}

/* kramdown auto-generated heading anchors */
.article h2 a.anchor, .article h3 a.anchor { display: none; }

.article strong { color: var(--ink); font-weight: 700; }
.article em { font-style: italic; }

.article a {
  color: var(--link);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
  text-underline-offset: 3px;
}
.article a:hover { color: var(--link-hover); text-decoration-color: var(--accent); }

/* Lists — style.css strips bullets globally for the README; put them back. */
.article ul, .article ol { margin: 0 0 1.15em; padding-left: 1.35em; }
.article ul { list-style: disc; }
.article ol { list-style: decimal; }
.article li { margin: 0 0 .4em; padding-left: .2em; }
.article li::marker { color: var(--slate); }
.article li > ul, .article li > ol { margin-top: .4em; }

/* Blockquote — used in this section for asides and pull-outs */
.article blockquote {
  margin: 1.7em 0;
  padding: 2px 0 2px 22px;
  border-left: 3px solid var(--accent);
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.55;
}
.article blockquote p:last-child { margin-bottom: 0; }

/* Figures. Images sit slightly wider than the text measure. */
.article img {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}
.article p:has(> img:only-child) {
  max-width: min(100%, 84ch);
  margin: 1.9em 0;
}
/* Standalone images are promoted to <figure> at load (see the article layout),
   with the markdown alt text reused as the caption. */
.article figure {
  max-width: min(100%, 84ch);
  margin: 1.9em 0;
}
.article figure img { margin: 0; }
.article figcaption {
  margin-top: 9px;
  font-family: var(--font-display); font-weight: 500;
  font-size: .8rem; line-height: 1.45;
  color: var(--muted);
  text-align: left;
}

/* Tables — the article leans on them, so they get real treatment. */
.article .table-wrap,
.article table { max-width: min(100%, 84ch); }
.article .table-wrap {
  margin: 1.8em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: .93rem;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.article thead th {
  background: var(--surface-2);
  font-family: var(--font-display);
  font-weight: 700; font-size: .8rem;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--slate);
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.article tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-soft);
  vertical-align: top;
}
.article tbody tr:last-child td { border-bottom: 0; }
.article tbody tr:hover td { background: var(--line-soft); }
.article tbody td strong { color: var(--accent-tx); }
/* Numeric columns read better right-aligned; the first column is the label. */
.article tbody td:not(:first-child),
.article thead th:not(:first-child) { text-align: right; }

/* Code */
.article code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: .12em .38em;
  color: var(--ink);
}
.article pre {
  max-width: min(100%, 84ch);
  margin: 1.6em 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.article pre code { background: none; border: 0; padding: 0; font-size: .86rem; line-height: 1.55; }

.article hr {
  max-width: min(100%, 84ch);
  border: 0; height: 1px;
  background: var(--line);
  margin: 2.6em 0;
}

/* The closing "Sources and method" block sets itself apart. */
.article h3#sources-and-method + p {
  font-size: .92rem;
  color: var(--muted);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Article footer
   -------------------------------------------------------------------------- */
.article-foot { padding: 10px 0 64px; }
.article-license {
  max-width: 68ch;
  margin: 0 0 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: .86rem; color: var(--muted);
}
.article-foot > p:last-child { max-width: 68ch; margin: 0; }

/* --------------------------------------------------------------------------
   Article index
   -------------------------------------------------------------------------- */
.artlist-head { padding: 52px 0 0; }
.artlist-head h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.1rem, 4.4vw, 2.9rem);
  letter-spacing: -.02em; line-height: 1.1;
  color: var(--ink); margin: 10px 0 0;
}
.artlist-head .lede {
  font-size: 1.08rem; line-height: 1.55; color: var(--ink-soft);
  max-width: 56ch; margin: 14px 0 0;
}

.artlist { padding: 34px 0 8px; }
.artlist-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.artcard { margin: 0; }
.artcard > a {
  display: flex; flex-direction: column; height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none; color: var(--ink);
  transition: transform .18s ease, box-shadow .2s, border-color .2s;
}
.artcard > a:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.artcard-thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
.artcard-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.artcard-body { display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 20px; }
.artcard-date {
  font-family: var(--font-display); font-weight: 500;
  font-size: .72rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--slate);
}
.artcard h2 {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.24rem; line-height: 1.22; letter-spacing: -.012em;
  margin: 0; color: var(--ink);
}
.artcard-sub { font-size: .93rem; line-height: 1.45; color: var(--ink-soft); }
.artcard .go {
  margin-top: 6px;
  font-family: var(--font-display); font-weight: 500; font-size: .78rem;
  color: var(--muted); transition: color .2s;
}
.artcard > a:hover .go { color: var(--accent-tx); }
.artlist-empty { color: var(--muted); }

/* --------------------------------------------------------------------------
   Reveal animation (matches the home page cards)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .artcard.reveal { opacity: 0; transform: translateY(10px); transition: opacity .5s ease, transform .5s ease; }
  .artcard.reveal.in { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .article { font-size: 1.02rem; }
  .article table { font-size: .86rem; }
  .article thead th, .article tbody td { padding: 9px 11px; }
}
