/* gabrieldunin.com — typographic system
 * Direction B: Distill-leaning. Source Serif 4 body + Inter for UI furniture.
 * No cards, no shadows, single restrained accent (prussian).
 */

:root {
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, Cambria, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --bg: #ffffff;
  --bg-soft: #fafaf8;
  --ink: #1a1a1a;
  --ink-soft: #2c2c2c;
  --muted: #6f6f6f;
  --muted-soft: #9a9a9a;
  --rule: #e6e6e6;
  --rule-strong: #cfcfcf;
  --mark: #0d3b66;            /* prussian — used semantically on marker elements only */
  --mark-soft: rgba(13, 59, 102, 0.08);

  --measure: 40rem;            /* article column */
  --measure-wide: 48rem;       /* home column */
  --page-max: 64rem;           /* outer frame */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-feature-settings: "kern" 1, "liga" 1;
  -webkit-font-smoothing: subpixel-antialiased;
  text-rendering: optimizeLegibility;
}

/* === LINKS — single semantic accent === */
a {
  color: var(--mark);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  transition: background-color 120ms ease, color 120ms ease;
}
a:hover { background: var(--mark-soft); }

/* === MEDIA === */
img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.2;
  margin: 0 0 0.75rem;
  color: var(--ink);
}
h2 { font-size: 1.55rem; margin-top: 2.5rem; }
h3 { font-size: 1.2rem;  margin-top: 1.8rem; }

p, ul, ol, blockquote, pre, table, details, figure {
  margin: 0 0 1.05rem;
}

ul, ol { padding-left: 1.3rem; }
li { margin-bottom: 0.4rem; }
li > ul, li > ol { margin-top: 0.4rem; margin-bottom: 0; }

blockquote {
  margin: 1.4rem 0;
  padding: 0.1rem 0 0.1rem 1.2rem;
  border-left: 2px solid var(--rule-strong);
  color: var(--ink-soft);
  font-style: italic;
}

/* Inline + block code */
code, pre {
  font-family: var(--mono);
}
code {
  font-size: 0.88em;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
}
pre {
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.1rem;
}
pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* Tables — hairline only */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
th {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule-strong);
}

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

/* === HEADER === */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.site-header__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.2rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}
.site-brand {
  margin: 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
}
.site-brand a {
  color: var(--ink);
  border-bottom: 0;
}
.site-brand a:hover { color: var(--mark); background: transparent; }
/* G / D in the wordmark pick up the favicon's electric blue so the tab
   icon and the page wordmark read as a single identity at two scales. */
.site-brand .gd { color: #0088ff; }
.site-nav {
  display: flex;
  gap: 1.75rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
}
.site-nav a {
  color: var(--muted);
  border-bottom: 0;
  padding: 0.25rem 0;
  min-height: 0;             /* override legacy 2.25rem */
  background: transparent;
  border: 0;
  border-radius: 0;
}
.site-nav a:hover { color: var(--ink); background: transparent; }

/* === MAIN === */
.site-main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 3rem 2rem 4.5rem;
}

/* Standard page wrapper (about, 404) — replaces the legacy .prose card */
.page-prose {
  max-width: var(--measure);
}
.page-prose > :first-child { margin-top: 0; }

.page-header { margin: 0 0 2.5rem; }
.page-header__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 2.4rem);
  letter-spacing: -0.018em;
  line-height: 1.1;
  margin: 0 0 0.6rem;
  max-width: 22ch;
}
.page-header__meta {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.lead {
  font-size: 1.18rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
}
.helper-text {
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--muted);
}

/* === HOME === */
.home-hero {
  max-width: var(--measure-wide);
  margin: 0 0 4.5rem;
}
.home-hero__title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 4.4vw, 2.6rem);
  line-height: 1.14;
  letter-spacing: -0.018em;
  margin: 0 0 1.4rem;
  max-width: 24ch;
  text-wrap: balance;
  hyphens: none;
}
/* Original markup splits "Gabriel" / "Dunin-Borkowski" into <span>s.
   Flow them inline as one wordmark; keep "Dunin-Borkowski" intact so the
   hyphen never becomes a break opportunity. */
.home-hero__title span { display: inline; }
.home-hero__title span:last-child { white-space: nowrap; }

.home-hero__lead {
  font-size: 1.18rem;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 36rem;
  margin: 0;
}

.home-section { max-width: var(--measure-wide); margin-top: 3.5rem; }
.home-section + .home-section { margin-top: 3.5rem; }

.section-heading {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

/* Post list — grid rows, no cards */
.post-list {
  display: block;
  border-top: 1px solid var(--rule);
  gap: 0;
}
.post-card {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 2rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
  background: transparent;
  border-radius: 0;
  margin: 0;
}
.post-card__date {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.post-card__body { min-width: 0; }
.post-card__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.25;
  font-weight: 500;
  letter-spacing: -0.008em;
}
.post-card__title a {
  color: var(--ink);
  border-bottom: 0;
}
.post-card__title a:hover { color: var(--mark); background: transparent; }
.post-card__excerpt {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.45;
  font-family: var(--serif);
  max-width: 38rem;
}

/* === POST PAGE === */
.post-page {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 3.5rem;
  max-width: var(--page-max);
}

.post-toc {
  position: sticky;
  top: 2.5rem;
  align-self: start;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.4;
}
.post-toc__label {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.9rem;
}
.post-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}
.post-toc li {
  margin-bottom: 0.55rem;
}
.post-toc a {
  color: var(--ink-soft);
  border-bottom: 0;
  display: block;
}
.post-toc a:hover { color: var(--mark); background: transparent; }
.post-toc a.is-active { color: var(--mark); font-weight: 600; }

.post-article { min-width: 0; max-width: var(--measure); }
.post-article__header { margin: 0 0 2.5rem; }
.post-article__title {
  font-family: var(--serif);
  font-size: clamp(2rem, 4.6vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.12;
  margin: 0 0 1rem;
  max-width: 30ch;
  text-wrap: balance;
}
.post-article__meta {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}
.post-article__meta .dot { color: var(--rule-strong); }
.post-article__body { font-size: 1.0625rem; }
.post-article__body > :first-child { margin-top: 0; }

/* Post-internal section headers */
.post-article__body h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2.75rem;
  margin-bottom: 1rem;
  scroll-margin-top: 2rem;
}
.post-article__body h3 {
  font-size: 1.18rem;
  margin-top: 2rem;
}
.post-article__body p { margin: 0 0 1.05rem; }

/* === LEGACY POST COMPONENTS — restyled === */

/* Figure: soft plate around image, mono-ish caption */
.post-figure {
  margin: 2rem 0 2.25rem;
}
.post-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  background: var(--bg-soft);
  padding: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: none;
}
.post-figure figcaption {
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 0.75rem;
}
.post-figure figcaption strong { color: var(--ink-soft); font-weight: 600; }

/* Boxed result — left rule, no fill */
.boxed {
  margin: 1.6rem 0;
  padding: 0.4rem 0 0.4rem 1.3rem;
  background: transparent;
  border: 0;
  border-left: 2px solid var(--mark);
  border-radius: 0;
}
.boxed strong:first-child {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--mark);
  margin-bottom: 0.5rem;
}

/* "Explain" paragraphs — discursive lead-style */
.explain {
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.55;
}

/* "Centered" closing remarks */
.centered {
  text-align: center;
  font-style: italic;
  color: var(--muted);
  margin: 2.5rem 0 1.5rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

/* Code-toggle (collapse.html) — hairline disclosure, no chrome */
.code-toggle {
  margin: 1.6rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0;
  background: transparent;
  border-radius: 0;
}
.code-toggle > summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-weight: 500;
  padding: 0.85rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.code-toggle > summary::-webkit-details-marker { display: none; }
.code-toggle > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.72rem;
  transition: transform 120ms ease;
  display: inline-block;
}
.code-toggle[open] > summary::before { transform: rotate(90deg); }
.code-toggle > summary:hover { color: var(--mark); }
.code-toggle pre { margin: 0 0 0.85rem; }

/* Generic <details> (solutions blocks, etc.) */
details:not(.code-toggle) {
  margin: 1.6rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
details:not(.code-toggle) > summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.85rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
details:not(.code-toggle) > summary::-webkit-details-marker { display: none; }
details:not(.code-toggle) > summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 0.72rem;
  transition: transform 120ms ease;
  display: inline-block;
}
details:not(.code-toggle)[open] > summary::before { transform: rotate(90deg); }
details:not(.code-toggle) > *:not(summary):last-child { padding-bottom: 1rem; }

/* MathJax display blocks — keep them sized to match body */
mjx-container[jax="CHTML"][display="true"] {
  display: block;
  margin: 1.4rem 0;
  text-align: center;
}

/* === FOOTER === */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 5rem;
}
.site-footer__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer__inner p { margin: 0; }
.site-footer__inner a {
  color: var(--muted);
  border-bottom: 0;
}
.site-footer__inner a:hover { color: var(--ink); background: transparent; }

/* === QUESTIONER (webapp page kept compatible) === */
button {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 500;
  background: var(--mark);
  color: #ffffff;
  border: 0;
  padding: 0.7rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 120ms ease;
}
button:hover {
  background: #0a2f52;
  transform: none;
}
#questionBox {
  margin-top: 1.5rem;
  padding: 1.25rem;
  max-width: 38rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-soft);
  font-size: 1.1rem;
  color: var(--ink);
}

.not-found {
  text-align: center;
  padding: 3rem 0 1rem;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .post-page {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .post-toc {
    position: static;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 1.5rem;
  }
  .post-toc ol { columns: 2; column-gap: 1.5rem; }
}

@media (max-width: 640px) {
  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    gap: 0.5rem;
  }
  .site-main { padding: 2rem 1.25rem 3rem; }
  .home-hero { margin-bottom: 3rem; }
  .home-section { margin-top: 2.5rem; }
  .post-card {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    padding: 1.25rem 0;
  }
  .post-card__date { font-size: 0.78rem; }
  .post-toc ol { columns: 1; }
  .site-footer__inner { padding: 1.25rem; }
  .post-figure img { padding: 0.8rem; }
}
