/* ==========================================================================
   robphilbin.com — single stylesheet.
   All the knobs live here at the top. Change these, not the rules below.
   ========================================================================== */

:root {
  /* Type */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-size: 1.125rem;
  --line-height: 1.65;
  --line-height-tight: 1.25;

  /* Measure & layout */
  --measure: 65ch;
  --gutter: 1.5rem;
  --space: 1.5rem;
  --space-lg: 3rem;

  /* Colour */
  --bg: #ffffff;
  --fg: #1a1a1a;
  --fg-muted: #595959;
  --rule: #e0e0e0;
  --link: #14417a;
  --link-visited: #5a3b7a;
  --accent-bg: #f4f4f2;
  --accent-rule: #c9c9c4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8e8e6;
    --fg-muted: #a3a3a0;
    --rule: #2e3238;
    --link: #8ab4f8;
    --link-visited: #c9a6e8;
    --accent-bg: #1c1f24;
    --accent-rule: #3a3f47;
  }
}

/* --- Base ---------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--font-size);
  line-height: var(--line-height);
}

a { color: var(--link); }
a:visited { color: var(--link-visited); }

img, video, iframe, svg, canvas { max-width: 100%; height: auto; }

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: var(--gutter);
  top: var(--gutter);
  background: var(--bg);
  padding: 0.5rem 0.75rem;
  z-index: 10;
}

/* --- Shell --------------------------------------------------------------- */

.site-header,
.site-footer,
main {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.site-header {
  padding-block: var(--space);
}

.site-header nav {
  display: flex;
  gap: 1.25rem;
}

.site-header a {
  text-decoration: none;
}
.site-header a:hover,
.site-header a:focus { text-decoration: underline; }

.site-footer {
  margin-top: var(--space-lg);
  padding-block: var(--space);
  border-top: 1px solid var(--rule);
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* --- Headings & prose ---------------------------------------------------- */

h1, h2, h3, h4 {
  line-height: var(--line-height-tight);
  margin-block: var(--space-lg) var(--space);
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }

.post-header h1,
.page h1 { margin-top: 0; }

p, ul, ol { margin-block: var(--space); }

.post-meta {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-top: -0.5rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin-block: var(--space-lg);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--accent-bg);
  padding: var(--space);
  overflow-x: auto;
}

/* --- Post body: give embedded things room -------------------------------- */

/* Normal flow at the measure. Anything that needs to be wider opts in with a
   class, so ordinary paragraphs are never fighting a layout system. */

/* Break out of the measure to the full viewport width. */
.post-body > .full-bleed,
.post-body > figure.full-bleed,
.post-body > .embed,
.post-body > .viz {
  width: 100vw;
  max-width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
  margin-block: var(--space-lg);
}

/* A middle setting: wider than the text, still inset from the edges. */
.post-body > .wide {
  width: min(100vw - (var(--gutter) * 2), 90rem);
  margin-left: 50%;
  transform: translateX(-50%);
  margin-block: var(--space-lg);
}

.post-body > .full-bleed img,
.post-body > .wide img { width: 100%; }

/* Raw HTML blocks (data visualisations) get their own scroll if they overflow. */
.post-body > .embed,
.post-body > .viz { overflow-x: auto; }

figure {
  margin-inline: 0;
  margin-block: var(--space-lg);
}

figcaption {
  color: var(--fg-muted);
  font-size: 0.875rem;
  line-height: 1.4;
  margin-top: 0.5rem;
}

blockquote {
  margin-inline: 0;
  padding-left: var(--space);
  border-left: 3px solid var(--accent-rule);
  color: var(--fg-muted);
}

blockquote.pull-quote {
  border-left: 0;
  padding-left: 0;
  font-size: 1.4rem;
  line-height: 1.35;
  color: var(--fg);
  text-align: center;
  margin-block: var(--space-lg);
}

table {
  border-collapse: collapse;
  width: 100%;
}
th, td {
  border-bottom: 1px solid var(--rule);
  padding: 0.5rem;
  text-align: left;
}

/* --- Post lists ---------------------------------------------------------- */

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

.post-list li {
  margin-block: var(--space);
  padding-bottom: var(--space);
  border-bottom: 1px solid var(--rule);
}

.post-list li:last-child { border-bottom: 0; }

.post-list h2 {
  font-size: 1.2rem;
  margin: 0 0 0.25rem;
}

.post-list time {
  color: var(--fg-muted);
  font-size: 0.875rem;
}

.post-list p { margin: 0.5rem 0 0; }

/* --- Archive ------------------------------------------------------------- */

.provenance {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent-rule);
  padding: var(--space);
  margin-block: var(--space) var(--space-lg);
  font-size: 0.95rem;
  color: var(--fg-muted);
}

.provenance p { margin: 0; }
.provenance p + p { margin-top: 0.5rem; }
.provenance-source { font-size: 0.85rem; word-break: break-all; }

.archive-note {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.archive-back {
  margin-top: var(--space-lg);
  padding-top: var(--space);
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}

/* Callout boxes, e.g. from a Notion callout block. */
.post-body aside.note {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent-rule);
  padding: var(--space);
  margin-block: var(--space-lg);
}

.post-body aside.note > :first-child { margin-top: 0; }
.post-body aside.note > :last-child { margin-bottom: 0; }
