:root {
  /* --- Type --- */
  --sans-font: "Inter", -system-ui, system-ui, sans-serif;
  --title-font: "InterDisplay", "Inter", -system-ui, system-ui, sans-serif;
  --mono-font: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  --font-size: 16px;
  --line-height: calc(var(--font-size) * 1.5); /* 24px */

  /* --- Spacing scale (everything derives from this 8px unit) --- */
  --unit: calc(var(--font-size) * 0.5); /* 8px */
  --body-padding-x: calc(var(--unit) * 8);  /* 64px */
  --body-padding-y: calc(var(--unit) * 8);
  --body-bleed: calc(var(--unit) * 16);
  --body-max-width: calc(var(--unit) * 152); /* 1216px */

  /* --- Color --- */
  --foreground-rgb: 0, 0, 0;
  --foreground: rgb(var(--foreground-rgb));
  --foreground-dimmed: rgba(var(--foreground-rgb), 0.4);
  --background: #fff;
  --letterbox: #333;               /* frame color behind the page on wide screens */
  --accent: #0366d6;               /* link color */
  --accent-darkmode: #9ac9fe;
  --menu-inactive: rgba(0, 0, 0, 0.3);
  --menu-active: var(--foreground);

  font-family: var(--sans-font);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--foreground);
  letter-spacing: -0.01em;
  font-variant-ligatures: contextual common-ligatures;

  /* the grey letterbox frame shows through as html's background;
     body itself is the white "card" on top of it */
  background-color: var(--letterbox);
}

/* Homepage runs in dark mode, matching rsms.me's .home behavior */
@media (prefers-color-scheme: dark) {
  html.home {
    --background: #333;
    --foreground-rgb: 255, 255, 255;
    --letterbox: #111;
    --accent: var(--accent-darkmode);
    --menu-inactive: rgba(255, 255, 255, 0.6);
  }
}

@media (max-width: 640px) {
  :root { background-color: initial; } /* no letterbox frame on mobile — full bleed */
}

* { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure { margin: 0; padding: 0; }

body {
  background: var(--background);
  box-shadow: 0 0 0 var(--body-bleed) var(--background);
  margin: 0 auto;
  padding: var(--body-padding-y) var(--body-padding-x);
  max-width: var(--body-max-width);
  min-height: 100vh;
}
@media (max-width: 1024px) {
  body { --body-padding-y: calc(var(--unit) * 4); }
}
@media (max-width: 640px) {
  body { --body-padding-x: calc(var(--unit) * 3); --body-padding-y: calc(var(--unit) * 2); }
}

/* --- Links --- */
a[href] {
  text-decoration: none;
  color: var(--accent);
}
a[href]:hover { text-decoration: underline; }
h1 > a[href], h2 > a[href], h3 > a[href] {
  color: inherit;
  text-decoration: none;
}

/* --- Headings --- */
h1, h2 { font-family: var(--title-font); }
h1 {
  font-weight: 600;
  font-size: 2rem;
  line-height: 2.5rem;
  margin-top: calc(var(--line-height) * 2);
  margin-bottom: var(--line-height);
}
h2 {
  font-weight: 500;
  font-size: 1.5rem;
  line-height: 2rem;
  letter-spacing: 0.01em;
}
h2 + * { margin-top: 0; }
* + h2 { margin-top: 3rem; }
h3 {
  font-family: var(--sans-font);
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: calc(var(--unit) * 0.5);
}

p { margin-bottom: var(--line-height); }

/* --- Nav (rsms.me's "menu": dot mark + flat link row) --- */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--unit) * 3);
  margin-bottom: calc(var(--unit) * 8);
  color: var(--menu-inactive);
}
.site-nav a { color: inherit; }
.site-nav a:hover { color: var(--menu-active); text-decoration: none; }
.site-nav a.active { color: var(--menu-active); }
.site-nav .dot { font-size: 0.7rem; }

/* --- Listings (Projects / Thoughts & ideas sections) --- */
.listing { margin-bottom: calc(var(--unit) * 8); }
.listing h2 a { color: inherit; }
.item { margin-bottom: calc(var(--unit) * 4); }
.item h3 { margin-bottom: calc(var(--unit) * 0.5); }
.item p { color: var(--foreground-dimmed); font-size: 0.95rem; margin-bottom: 0; }
.item time { color: var(--foreground-dimmed); font-size: 0.85rem; }
.see-all { margin-top: var(--unit); font-size: 0.9rem; }

/* --- Single / list pages --- */
.meta { color: var(--foreground-dimmed); font-size: 0.9rem; }
.content pre {
  font-family: var(--mono-font);
  overflow-x: auto;
  padding: var(--unit);
  background: rgba(var(--foreground-rgb), 0.05);
  border-radius: 4px;
}
.content code { font-family: var(--mono-font); font-size: 0.9em; }

/* --- Footer --- */
.site-footer {
  margin-top: calc(var(--unit) * 10);
  padding-top: calc(var(--unit) * 3);
  border-top: 1px solid rgba(var(--foreground-rgb), 0.1);
  color: var(--foreground-dimmed);
  font-size: 0.9rem;
}
.footer-links a { color: var(--foreground-dimmed); }

/* --- Homepage grid ---
   This is the fixed skeleton described in the README: a 2-row, 3-column
   grid. Each partial declares its own grid-area (see columns/*.html);
   this block is the only place the *shape* is defined. Rearranging the
   layout later = editing these area names, not the HTML/templates. */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas:
    "hero  .    nav"
    "proj  posts bio";
  column-gap: calc(var(--unit) * 6);
  row-gap: calc(var(--unit) * 10);
}
.col-hero { grid-area: hero; }
.col-nav  { grid-area: nav; display: flex; flex-direction: column; align-items: flex-start; }
.col-bio  { display: flex; flex-direction: column; gap: calc(var(--unit) * 2); }
.bio-text { font-family: var(--title-font); font-weight: 500; font-size: 1.3rem; }
.bio-link {
  display: block;
  background: rgba(var(--foreground-rgb), 0.06);
  padding: calc(var(--unit) * 1.5);
  border-radius: 4px;
  color: inherit;
}
.bio-link:hover { background: rgba(var(--foreground-rgb), 0.1); text-decoration: none; }
.bio-link-eyebrow { display: block; font-weight: 600; }

@media (max-width: 900px) {
  .home-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "nav" "hero" "proj" "posts" "bio";
  }
  .col-nav { flex-direction: row; flex-wrap: wrap; gap: calc(var(--unit) * 2); }
}


@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- Generic top-level page grid (About, Work, Photography, etc.) ---
   Simpler than .home-grid: just a nav column + one content column.
   Copy/extend this the same way as .home-grid for pages with their
   own list columns. */
.page-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: calc(var(--unit) * 6);
}
.page-grid .col-nav { grid-column: 2; grid-row: 1; }
.page-grid .col-content { grid-column: 1; grid-row: 1; }
@media (max-width: 900px) {
  .page-grid { grid-template-columns: 1fr; }
  .page-grid .col-nav { grid-column: 1; grid-row: 1; flex-direction: row; flex-wrap: wrap; gap: calc(var(--unit) * 2); margin-bottom: calc(var(--unit)*6); }
  .page-grid .col-content { grid-column: 1; grid-row: 2; }
}
