/* Dark reading theme for the blog. The landing page (index.html) uses its own
 * style.css and is intentionally untouched by this file. */

:root {
  --bg: #1a1d24;
  --text: #ccd0d8;
  --muted: #8b919d;
  --link: #8ab4f8;
  --cite: #b39ddb; /* faint purple for source citations */
  --rule: #2e333d;
  --popup-bg: #232830;
  --popup-border: #3a4049;
  /* serif for reading, sans for headings/UI — flip these two to taste */
  --serif: Charter, "Charter BT", Georgia, Cambria, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  max-width: 45rem;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

/* --- headings / typography --- */

h1,
h2,
h3 {
  font-family: var(--sans);
  line-height: 1.25;
  font-weight: 650;
}

.post-header h1 {
  font-size: 2.1rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 1rem;
}

h3 {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
}

/* Substack-style section anchors: the "#" hides until you hover the heading,
   and scroll-margin keeps the target from tucking under the top of the viewport. */
h2,
h3 {
  scroll-margin-top: 1.5rem;
}
.heading-anchor {
  margin-left: 0.35rem;
  color: var(--link);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
h2:hover .heading-anchor,
h3:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 0.5;
}
.heading-anchor:hover {
  opacity: 1;
}

p {
  margin: 0 0 1.2rem;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Source citations: the cited phrase stays in the reading color and carries a
   faint-purple underline that jumps to the Sources section. See cite.js. */
a.cite {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--cite) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a.cite:hover {
  text-decoration-color: var(--cite);
  text-decoration-thickness: 2px;
}

blockquote {
  border-left: 2px solid var(--rule);
  padding-left: 1.2rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-style: italic;
}

ul,
ol {
  margin: 0 0 1.2rem 1.4rem;
}

li {
  margin-bottom: 0.4rem;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

/* Source/caption line under a chart. Authored inline in the markdown as
   <span class="chart-src">Source: [label](@id)</span> — an inline tag, so the
   `[..](@id)` cite links inside still get parsed and flow into the Sources
   section (a block tag like <p> would swallow the markdown verbatim). */
p:has(> .chart-src) {
  margin-top: -0.75rem;
  margin-bottom: 2rem;
}
.chart-src {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: #23272f;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

pre {
  background: #202430;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

pre code {
  background: none;
  padding: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-family: var(--sans);
  font-size: 0.92rem;
}

th,
td {
  border: 1px solid var(--rule);
  padding: 0.45rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 600;
  background: #21262f;
}

/* --- post chrome --- */

.post-meta {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.post-meta a {
  color: var(--muted);
}

.subtitle {
  font-size: 1.2rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 2.5rem;
}

.post-dates {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 0.75rem; /* sits below the h1 when there's no subtitle */
  margin-bottom: 0;
}

/* When a subtitle precedes the dates, tuck up under its bottom margin instead. */
.subtitle + .post-dates {
  margin-top: -1.5rem;
}

.post-dates span {
  display: block;
}

.post-header {
  margin-bottom: 1.25rem;
}

.post-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.95rem;
}

.draft-banner {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #e8c069;
  background: rgba(232, 192, 105, 0.1);
  border: 1px solid rgba(232, 192, 105, 0.3);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  margin-bottom: 1.2rem;
}

/* --- blog index --- */

.index-header {
  margin-bottom: 3rem;
}

.index-header h1 {
  font-size: 2.2rem;
}

.index-sub {
  font-family: var(--sans);
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.index-sub a {
  color: var(--muted);
}

.post-list {
  list-style: none;
  margin: 0;
}

.post-list li {
  margin-bottom: 2rem;
}

.post-link {
  font-family: var(--sans);
  font-size: 1.3rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

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

.draft-tag {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: middle;
  color: #e8c069;
  background: rgba(232, 192, 105, 0.1);
  border: 1px solid rgba(232, 192, 105, 0.3);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
}

.archive-tag {
  color: var(--muted);
  background: rgba(148, 148, 148, 0.1);
  border-color: rgba(148, 148, 148, 0.35);
}

.post-date {
  display: block;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.post-sub {
  color: var(--muted);
  font-style: italic;
  margin: 0.4rem 0 0;
}

/* --- Notes + Sources (bottom of article) --- */

/* The section border-top is the divider; hide the plugins' <hr> separators. */
.footnotes-sep,
.sources-sep {
  display: none;
}

.footnotes,
.sources {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--muted);
}

.sources {
  margin-top: 2.5rem; /* sits under Notes, so a tighter gap */
}

.footnotes-title,
.sources-title {
  font-family: var(--sans);
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 0.9rem;
}

.sources-note {
  margin: -0.5rem 0 1rem;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--muted);
}

.footnotes ol,
.sources-list {
  margin-left: 1.2rem;
}

.sources-list {
  list-style-type: lower-alpha; /* a. b. c. */
}

.footnotes p,
.source-item {
  margin-bottom: 0.5rem;
}

.source-item::marker {
  color: var(--cite);
}

.footnote-item:target {
  background: rgba(138, 180, 248, 0.12);
  border-radius: 4px;
}

.source-item:target {
  background: color-mix(in srgb, var(--cite) 14%, transparent);
  border-radius: 4px;
}

.cite-backref {
  text-decoration: none;
  margin-left: 0.25rem;
}

.footnote-ref a {
  text-decoration: none;
  font-weight: 600;
  padding: 0 1px;
}

.footnote-backref {
  text-decoration: none;
  margin-left: 0.25rem;
}

/* --- footnote hover popup (desktop; mobile falls back to anchor jump) --- */

.fn-tooltip {
  position: absolute;
  z-index: 50;
  max-width: 22rem;
  background: var(--popup-bg);
  border: 1px solid var(--popup-border);
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.fn-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Bridge the 8px gap between the marker and the popup (see footnotes.js) so the
   cursor never crosses dead space on its way up to click a link inside. The
   pseudo-element is a transparent hit-area extending toward the marker; JS adds
   `.below` when the popup is flipped under the marker, so the bridge flips too.
   Inherits the parent's pointer-events, so it's only live while `.visible`. */
.fn-tooltip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  top: 100%;
}
.fn-tooltip.below::after {
  top: auto;
  bottom: 100%;
}

.fn-tooltip p {
  margin: 0;
}

.fn-tooltip .footnote-backref,
.fn-tooltip .cite-backref {
  display: none;
}
