/* ─── Reset ───────────────────────────────────────────────── */

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

* {
  margin: 0;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  line-height: 1.6;
  scroll-behavior: smooth;
}

body {
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}

a {
  text-decoration: none;
}

b, strong {
  font-weight: 700;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

ul, ol {
  list-style: none;
  padding: 0;
}

figure {
  margin: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-block: var(--space-5);
}

/* ─── Base styles ─────────────────────────────────────────── */

html {
  background:
    radial-gradient(circle at top left, rgba(47, 95, 134, 0.05), transparent 24rem),
    linear-gradient(180deg, #ffffff 0%, var(--color-bg) 100%);
  color: var(--color-text);
}

body {
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
}

h1, h2, h3, h4 {
  color: var(--color-text);
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

h1 { font-size: clamp(2.4rem, 4vw, 3.2rem); }
h2 { font-size: clamp(1.75rem, 2.2vw, 2.15rem); }
h3 { font-size: clamp(1.32rem, 1.6vw, 1.6rem); }
h4 { font-size: 1.08rem; }

a {
  color: var(--color-accent-strong);
}

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

:focus-visible {
  outline: 2px solid rgba(29, 70, 104, 0.55);
  outline-offset: 3px;
}

p, li, blockquote {
  color: var(--color-text);
}

main {
  display: block;
  flex: 1 0 auto;
}

img {
  border-radius: calc(var(--radius-card) - 0.5rem);
}

blockquote {
  background: var(--color-surface-muted);
  border-left: 0.25rem solid var(--color-accent);
  border-radius: 0 1rem 1rem 0;
  margin-inline: 0;
  padding: var(--space-4) var(--space-5);
}

/* ─── Prose content (article body markdown) ───────────────── */

.prose-flow > * + * {
  margin-top: var(--space-5);
}

.article-body > * {
  margin-inline: auto;
  max-width: 42rem;
}

.article-body > figure,
.article-body > pre,
.article-body > table {
  max-width: 46rem;
}

.prose-flow h1,
.prose-flow h2,
.prose-flow h3,
.prose-flow h4 {
  line-height: 1.15;
}

.prose-flow h2 {
  font-size: clamp(1.6rem, 2vw, 2rem);
  margin-top: calc(var(--space-7) + 0.5rem);
}

.prose-flow h3 {
  font-size: clamp(1.25rem, 1.7vw, 1.5rem);
  margin-top: calc(var(--space-6) + 0.25rem);
}

.prose-flow h4,
.prose-flow h5 {
  font-size: 1.05rem;
  margin-top: var(--space-5);
}

.prose-flow p,
.prose-flow li {
  font-size: 1.12rem;
  line-height: 1.82;
}

.prose-flow p + p {
  margin-top: var(--space-4);
}

.prose-flow ul,
.prose-flow ol {
  padding-left: var(--space-5);
}

.prose-flow ul {
  list-style: disc;
}

.prose-flow ol {
  list-style: decimal;
}

.prose-flow li + li {
  margin-top: var(--space-2);
}

.prose-flow ul ul,
.prose-flow ol ol,
.prose-flow ul ol,
.prose-flow ol ul {
  margin-top: var(--space-2);
}

.prose-flow a {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.prose-flow figure > a {
  display: block;
}

.prose-flow > figure,
.prose-flow figure > img,
.prose-flow figure > a > img {
  width: 100%;
}

.prose-flow > figure {
  margin-inline: 0;
}

.prose-flow > figure > img,
.prose-flow > figure > a > img {
  background: transparent;
  border: 0;
  border-radius: 1rem;
  padding: 0;
}

.article-body > figure {
  margin-block: var(--space-6);
}

.article-body > figure > img,
.article-body > figure > a > img {
  height: auto;
  margin-inline: auto;
  max-height: 30rem;
  max-width: 36rem;
  object-fit: contain;
}

.article-shell--books .article-body > figure:first-child > img,
.article-shell--books .article-body > figure:first-child > a > img {
  max-height: 18rem;
  max-width: 14rem;
}

.article-shell--books .article-body > figure:first-child {
  float: left;
  margin: 0.35rem 1.5rem 1rem 0;
  max-width: 14rem;
  width: min(42%, 14rem);
}

.article-shell--books .article-body > figure:first-child + * {
  margin-top: 0;
}

.article-body::after {
  clear: both;
  content: "";
  display: table;
}

.prose-flow figcaption,
.prose-flow cite {
  color: var(--color-muted);
  display: block;
  font-size: var(--font-size-sm);
  margin-top: var(--space-2);
}

.prose-flow blockquote p,
.prose-flow blockquote li {
  font-size: 1rem;
}

.prose-flow blockquote > * + * {
  margin-top: var(--space-3);
}

.prose-flow hr {
  margin-block: var(--space-6);
}

@media (max-width: 39.99rem) {
  .article-shell--books .article-body > figure:first-child {
    float: none;
    margin: 0 auto var(--space-5);
    width: 100%;
  }
}

.prose-flow code {
  background: rgba(29, 70, 104, 0.08);
  border-radius: 0.35rem;
  font-family: "SFMono-Regular", "SF Mono", "Menlo", monospace;
  font-size: 0.92em;
  padding: 0.15rem 0.35rem;
}

.prose-flow pre {
  background: #f1f4f7;
  border: 1px solid rgba(29, 70, 104, 0.12);
  border-radius: 1rem;
  overflow-x: auto;
  padding: var(--space-4);
}

.prose-flow pre code {
  background: transparent;
  padding: 0;
}

.prose-flow table {
  border-collapse: collapse;
  width: 100%;
}

.prose-flow th,
.prose-flow td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

.prose-flow > figure > figure {
  margin-top: 0;
}

.page-content > h3 + figure {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.page-content > h3 + figure > figure {
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  padding: 0.5rem;
}

.page-content > h3 + figure > figure img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
}

.page-content > h3 + figure > figure figcaption {
  padding-inline: 0.25rem;
}

.page-content > hr + p,
.page-content > figure + p {
  margin-top: var(--space-5);
}

@media (max-width: 39.99rem) {
  .page-content > h3 + figure {
    grid-template-columns: 1fr;
  }
}
