/* Base element & typography styles */

html {
  font-size: clamp(16px, 15px + 0.35vw, 18.5px);
}

body {
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--ink);
  background-color: var(--bg);
  font-variant-numeric: oldstyle-nums;
}

::selection {
  background: var(--selection);
}

/* Headings use the serif at tighter leading; UI chrome uses the sans. */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-serif);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  color: var(--ink);
}

h1 {
  font-size: var(--fs-h1);
}
h2 {
  font-size: var(--fs-h2);
}
h3 {
  font-size: var(--fs-h3);
}
h4 {
  font-size: var(--fs-h4);
  font-weight: var(--fw-semibold);
}

p {
  margin: 0 0 var(--sp-4);
}

a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

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

strong,
b {
  font-weight: var(--fw-semibold);
}

em,
i {
  font-style: italic;
}

hr {
  border: none;
  border-top: var(--border);
  margin: var(--sp-7) 0;
}

ul,
ol {
  margin: 0 0 var(--sp-4);
  padding-left: 1.4em;
}

li {
  margin-bottom: var(--sp-2);
}

li::marker {
  color: var(--faint);
}

blockquote {
  margin: var(--sp-5) 0;
  padding: var(--sp-1) 0 var(--sp-1) var(--sp-5);
  border-left: 3px solid var(--rule-strong);
  color: var(--ink-soft);
  font-style: italic;
}

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

small {
  font-size: var(--fs-small);
}

sup,
sub {
  font-size: 0.72em;
}

/* Inline code */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  font-variant-numeric: normal;
  font-feature-settings: "liga" 0;
}

:not(pre) > code {
  background: var(--bg-inline-code);
  padding: 0.12em 0.38em;
  border-radius: 4px;
  white-space: nowrap;
}

/* Code blocks (Prism theme colors live in prism.css) */
pre {
  font-family: var(--font-mono);
  font-size: var(--fs-code);
  line-height: 1.6;
  background: var(--bg-code);
  border: var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  overflow-x: auto;
  margin: var(--sp-5) 0;
  -webkit-font-smoothing: auto;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  white-space: pre;
  border-radius: 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-5) 0;
  font-family: var(--font-sans);
  font-size: var(--fs-ui);
  font-variant-numeric: normal;
}

thead th {
  text-align: left;
  font-weight: var(--fw-semibold);
  border-bottom: 2px solid var(--rule-strong);
  padding: var(--sp-2) var(--sp-3);
  color: var(--ink);
}

tbody td {
  border-bottom: var(--border);
  padding: var(--sp-2) var(--sp-3);
  vertical-align: top;
  color: var(--ink-soft);
}

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

table code {
  white-space: normal;
}

/* Heading anchor links (markdown-it-anchor linkInsideHeader, placed after) */
.header-anchor {
  margin-left: 0.4em;
  color: var(--faint);
  text-decoration: none;
  font-weight: var(--fw-normal);
  opacity: 0;
  transition: opacity 0.12s ease;
}

:is(h2, h3, h4):hover > .header-anchor,
.header-anchor:focus-visible {
  opacity: 1;
}
