/*
 * Unified stylesheet for alexpacini.com (Home, Publications, File Index, and Blog)
 *
 * Typography:
 *   - Source Serif 4 Variable (opsz 8..60, wght 400..700, Adobe Originals, SIL OFL 1.1)
 *   - IBM Plex Mono (400, 400i, 700, IBM Corp., SIL OFL 1.1)
 * Palette:
 *   - Crisp pure white background (#ffffff)
 *   - High-contrast accessible blueprint/plum/burnt-orange links (>6.2:1 WCAG AA/AAA)
 *   - GitHub Dark (#0d1117) compile-time Chroma syntax-highlighted code blocks
 *   - Regular-weight (400) headings preserving bold initial-capital wordmark (`<strong>A</strong>lex`)
 */

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/SourceSerif4Variable-Roman.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/SourceSerif4Variable-Italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #24282b;
  --ink-strong: #111111;
  --muted: #596066;
  --link: #175a85;
  --visited: #654c78;
  --accent: #b84314;
  --rule: #dfe3e6;
  --inline-code-bg: #eff1f3;
  --code-bg: #0d1117;
  --code-fg: #e6edf3;
  --serif: "Source Serif 4", "Liberation Serif", "DejaVu Serif", serif;
  --mono: "IBM Plex Mono", "DejaVu Sans Mono", monospace;
  --measure: 58rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: var(--measure);
  padding: clamp(2rem, 5vw, 3.75rem) clamp(1rem, 3vw, 1.75rem);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 1rem + 0.22vw, 1.15rem);
  line-height: 1.62;
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-numeric: lining-nums proportional-nums;
  font-synthesis: none;
}

/* Headings stay at weight 400 so `<strong>A</strong>lex <strong>P</strong>acini` initial-caps stand out */
h1, h2, h3, h4, h5 {
  color: var(--ink-strong);
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 2em 0 0.6em;
}

@media (min-width: 66rem) {
  article :is(h2, h3) {
    margin-left: -0.85em;
  }
}

h1 { font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.65rem); margin-top: 0; }
h2 { font-size: clamp(1.42rem, 1.2rem + 0.9vw, 1.85rem); }
h3 { font-size: clamp(1.18rem, 1.1rem + 0.4vw, 1.35rem); }
h4 { font-size: 1.08rem; font-style: italic; }
h5 { font-size: 1rem; font-weight: 600; }

h1.header {
  font-size: clamp(2rem, 1.55rem + 2.1vw, 2.85rem);
  margin: 0;
  letter-spacing: -0.015em;
}

h2.header {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.35rem 0 clamp(1.75rem, 4vw, 2.5rem) 0;
  letter-spacing: 0;
}

p, ul, ol, dl, blockquote, figure, table {
  margin: 0 0 1.05em;
}

p {
  text-wrap: pretty;
}

ul, ol {
  padding-left: 1.35em;
}

li + li {
  margin-top: 0.25em;
}

li > ul, li > ol {
  margin-top: 0.35em;
}

dt {
  font-weight: 600;
}

dd {
  margin: 0.2em 0 0.8em 1.4em;
}

/* Accessible links: subtle prose underline, clean standalone headers/navigation */
a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 0.065em;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  transition: color 0.14s ease, text-decoration-color 0.14s ease;
}

a:visited {
  color: var(--visited);
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.11em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

h1 a, h2 a, h3 a, .post-list a, .post-nav a, body.page-home a {
  text-decoration: none;
}

h2.header a:hover, .post-list a:hover, .post-nav a:hover, body.page-home a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.4rem auto;
}

figcaption {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.5rem;
}

blockquote {
  margin: 1.25rem 0;
  padding: 0.1rem 1.25rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

blockquote p:last-child {
  margin-bottom: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  width: 6rem;
  margin: 2.25rem auto;
}

/* ==========================================================================
   Code: Light Inline Badges + Dark GitHub-Dark Compile-Time Chroma Blocks
   ========================================================================== */

code, pre, kbd, samp {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums slashed-zero;
  font-variant-ligatures: none;
}

:not(pre) > code {
  font-size: 0.86em;
  background: var(--inline-code-bg);
  color: #24292e;
  padding: 0.1em 0.34em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

pre {
  margin: 1.15rem 0 1.45rem;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--code-fg);
  font-size: 0.85rem;
  line-height: 1.55;
  tab-size: 4;
}

pre > code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Booktabs-style tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
  font-variant-numeric: tabular-nums;
  border-top: 1.5px solid var(--ink-strong);
  border-bottom: 1.5px solid var(--ink-strong);
}

thead th {
  border-bottom: 1px solid var(--ink-strong);
  font-weight: 600;
}

th, td {
  padding: 0.45rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

tbody tr + tr td {
  border-top: 1px solid color-mix(in srgb, var(--rule) 75%, transparent);
}

/* ==========================================================================
   Landing Card (web/index.html — <body class="page-home">)
   ========================================================================== */

body.page-home {
  font-family: var(--mono);
  padding-top: clamp(3rem, 8vh, 5.5rem);
}

body.page-home h1#AlexPacini {
  font-size: clamp(2.2rem, 1.55rem + 3vw, 3.35rem);
  letter-spacing: -0.03em;
  margin: 0 0 clamp(1.5rem, 4vw, 2.4rem) 0;
}

body.page-home h2 {
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.75rem);
  line-height: 1.35;
  margin: 0.65rem 0 0.25rem 4%;
  letter-spacing: -0.01em;
}

body.page-home h2.icon-links {
  margin-top: clamp(1.5rem, 3.5vw, 2.25rem);
  display: flex;
  flex-wrap: wrap;
  gap: 1.15rem;
}

body.page-home p {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.icon-links svg {
  display: inline-block;
  height: 1.05em;
  width: auto;
  vertical-align: -0.125em;
  fill: currentColor;
}

/* ==========================================================================
   Publications (web/pubs.html — <body class="page-pubs">)
   ========================================================================== */

#publications h1 {
  font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.7rem);
  margin: 1.8rem 0 0.65rem 0;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.3rem;
}

#publications ul {
  list-style: none;
  padding-left: 0;
}

#publications li {
  padding: 0.5rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 65%, transparent);
}

#publications p {
  display: flow-root;
  text-align: left;
  margin: 0;
  font-size: 1rem;
  line-height: 1.52;
  overflow-wrap: break-word;
}

div.section {
  margin-bottom: 2rem;
  scroll-margin-top: 1.25rem;
}

div.section h1 a:hover::after {
  content: ' #';
  color: var(--muted);
  font-size: 0.75em;
}

.pub-actions {
  float: right;
  margin-left: 1rem;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.bib-copy-btn,
a.pdf-open-btn,
a.pdf-open-btn:visited {
  padding: 0;
  font: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--link);
  text-decoration: none;
}

a.pdf-open-btn + .bib-copy-btn {
  margin-left: 0.45em;
}

.bib-copy-btn:hover,
a.pdf-open-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ==========================================================================
   Blog (/blog/ — <body class="page-blog">)
   ========================================================================== */

/* Optimal ~70ch prose column on the shared 58rem left rail; plots, code, tables, and equations span full 58rem */
article > :is(p, ul, ol, dl, blockquote) {
  max-width: 70ch;
}

article > p:has(> img) {
  max-width: none;
}

.year-group h2 {
  font-family: var(--mono);
  font-size: 1.05rem;
  color: var(--muted);
  margin: 2rem 0 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.25rem;
}

.post-list {
  list-style: none;
  padding-left: 0;
}

.post-list li {
  margin: 0 0 0.45rem 0;
  padding-left: 6.4rem;
  text-indent: -6.4rem;
  line-height: 1.48;
}

.post-date,
.post-meta {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.post-date {
  display: inline-block;
  width: 6.4rem;
  text-indent: 0;
}

@media (max-width: 520px) {
  .post-list li { padding-left: 0; text-indent: 0; margin-bottom: 0.7rem; }
  .post-date { display: block; width: auto; }
}

.post-meta {
  margin: -0.25rem 0 1.6rem 0;
}

.tag-link,
.tag-link:visited {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  margin-left: 0.35rem;
  text-indent: 0;
}

.tag-link:hover {
  color: var(--accent);
}

.badge-deprecated {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #8a4b08;
  background: #fdf3e7;
  border: 1px solid #eccfa8;
  padding: 0.05em 0.4em;
  border-radius: 3px;
  margin-left: 0.35rem;
}

.deprecation-notice {
  border-left: 3px solid #d9822b;
  background: #fdf6ec;
  padding: 0.65rem 1.1rem;
  margin: 1rem 0 1.6rem;
  font-size: 0.94rem;
  line-height: 1.5;
  color: #4a3500;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 2.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.92rem;
}

.katex {
  font-size: 1.07em;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0;
  margin: 1.15rem 0;
}

@media print {
  body { color: #000000; font-size: 11pt; max-width: 100%; padding: 0; }
  a, a:visited { color: inherit; text-decoration: none; }
  .pub-actions, .post-nav, .icon-links { display: none; }
}
