:root {
  color-scheme: light;
  --background: #fbfaf7;
  --surface: var(--background);
  --surface-muted: #f1eee8;
  --text: #181818;
  --muted: #6f6c66;
  --border: #ddd8cf;
  --accent: #2f4d7a;
  --accent-strong: var(--accent);
  --review: var(--muted);
  --shadow: none;
  --logo-shadow: rgba(0, 0, 0, 0.4);
  --highlight-bg: rgba(47, 77, 122, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #151515;
  --surface: var(--background);
  --surface-muted: #232323;
  --text: #f1eee8;
  --muted: #aaa49a;
  --border: #343230;
  --accent: #88abdb;
  --accent-strong: var(--accent);
  --review: var(--muted);
  --shadow: none;
  --logo-shadow: rgba(255, 255, 255, 0.32);
  --highlight-bg: rgba(136, 171, 219, 0.20);
}

:root {
  /* Families */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-text: "Newsreader", Georgia, "Times New Roman", serif;
  --font-label: "Spline Sans Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* The size scale — use only these */
  --fs-display: clamp(2.75rem, 7vw, 5.25rem); /* 44->84px — hero only */
  --fs-title: clamp(1.4rem, 2.4vw, 1.95rem);  /* 22->31px — every heading & title */
  --fs-body: 1.125rem;                        /* 18px — all reading text & sidebar nav */
  --fs-micro: 0.8125rem;                      /* 13px — all labels & meta */
  --fs-fine: 0.6875rem;                       /* 11px — fine print only: dense tiles, captions */

  /* Weights */
  --w-light: 380; /* hero / large display */
  --w-mid: 520;   /* titles at small/medium size */
  --w-label: 560; /* uppercase labels */

  /* Line heights */
  --lh-display: 0.98;
  --lh-title: 1.12;
  --lh-body: 1.6;
  --lh-micro: 1.3;

  /* Tracking */
  --track-label: 0.1em;
  --track-title: -0.01em;

  /* Empty header band above both columns (reserved nav space) */
  --header-h: 88px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  font-optical-sizing: auto;
  line-height: var(--lh-body);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

button {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

/* Sits immediately left of the theme toggle, sharing its pill shape and height
   so the two read as one control cluster. 18 + 52 + 8 clears the toggle. */
.home-button {
  position: fixed;
  top: 18px;
  right: 78px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
}

.home-button:hover {
  background: var(--surface-muted);
  color: var(--accent-strong);
}

.home-button:focus-visible {
  outline: 3px solid var(--border);
  outline-offset: 3px;
}

.theme-toggle:hover {
  background: var(--surface-muted);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--border);
  outline-offset: 3px;
}

.theme-toggle-track {
  position: relative;
  width: 34px;
  height: 16px;
}

.theme-toggle-knob {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 160ms ease;
}

:root[data-theme="dark"] .theme-toggle-knob {
  transform: translateX(18px);
}

/* Mobile drawer controls — hidden on desktop, shown in the mobile media query. */
.nav-toggle,
.nav-close {
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.nav-toggle:hover,
.nav-close:hover {
  background: var(--surface-muted);
}

.nav-toggle svg,
.nav-close svg {
  display: block;
}

.nav-backdrop {
  display: none;
}

.page-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding-top: var(--header-h);
  padding-inline: clamp(20px, 4vw, 48px);
}

.side-nav {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 38px;
  height: calc(100vh - var(--header-h));
  padding: 0 42px 42px;
  overflow: auto;
  background: var(--surface);
}

.side-intro {
  display: grid;
  gap: 14px;
}

.side-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: var(--w-mid);
  line-height: var(--lh-title);
  letter-spacing: var(--track-title);
}

.side-name a {
  color: var(--text);
  text-decoration: none;
}

.side-name a:hover {
  color: var(--accent-strong);
}

.sidebar-profile {
  display: grid;
  gap: 38px;
}

.profile-photo {
  display: grid;
  place-items: center;
  width: min(100%, 190px);
  aspect-ratio: 1;
  background: var(--surface-muted);
  color: var(--muted);
  filter: grayscale(1);
  overflow: hidden;
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo span {
  font-family: var(--font-display);
  font-size: 42px; /* graphic monogram — exempt from the 4-size text scale */
  font-weight: var(--w-mid);
  letter-spacing: 0.04em;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  /* Hairline ring keeps near-black discs defined; soft drop shadow is theme-aware. */
  box-shadow: inset 0 0 0 1px var(--border), 0 2px 7px var(--logo-shadow);
  border-radius: 50%;
  text-decoration: none;
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.social-link svg {
  width: 16px;
  height: 16px;
  fill: #fff; /* knockout glyph — the disc carries the brand color */
}

.social-link:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

/* Brand colors — fixed regardless of light/dark theme. */
.social-link--x {
  background: #000000;
}

.social-link--linkedin {
  background: #0a66c2;
}

.social-link--instagram {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
}

/* No brand colour to borrow, so it takes the site's own ink. */
.social-link--scholar {
  background: #4285f4;
}

.social-link--email {
  background: var(--accent-strong);
}

.social-link--github {
  background: #181717;
}

.sidebar-disclosure {
  display: grid;
  gap: 10px;
  max-width: 240px;
}

.sidebar-disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  font-weight: var(--w-label);
  letter-spacing: var(--track-label);
  line-height: var(--lh-micro);
  list-style: none;
  text-transform: uppercase;
}

.sidebar-disclosure summary::-webkit-details-marker {
  display: none;
}

.sidebar-disclosure summary:hover {
  color: var(--text);
}

.sidebar-disclosure[open] summary {
  color: var(--accent-strong);
}

.trajectory-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 2px 0 0;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-fine);
  list-style: none;
  line-height: 1.45;
}

.home-main {
  min-width: 0;
  padding: 0 min(6vw, 72px) 72px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  font-weight: var(--w-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
}

.home-about {
  max-width: 680px;
}

.home-about .eyebrow {
  margin-bottom: 16px;
}

.about-copy {
  margin: 0 0 14px;
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

.about-copy:last-child {
  margin-bottom: 0;
}

.category-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  max-width: 1000px;
  margin: 0 0 22px;
}

.category-link {
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}

.category-link:hover {
  color: var(--text);
}

.category-link.is-active {
  color: var(--accent-strong);
  font-weight: var(--w-label);
}

.category-count {
  color: var(--muted);
  font-weight: 500;
}

.category-sep {
  color: var(--border);
  font-size: var(--fs-micro);
  user-select: none;
}

.post-gallery {
  display: flex;
  align-items: center;
  margin-top: 16px;
}

.post-gallery-tile {
  flex: 0 0 auto;
  width: 42px;
  height: 30px;
  margin-left: -26px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-muted);
  /* Ring in the page color separates the overlapping tiles. */
  box-shadow: 0 0 0 2px var(--background);
}

.post-gallery-tile:first-child {
  margin-left: 0;
}

.post-gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-gallery-count {
  margin-left: 10px;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-fine);
  font-weight: var(--w-label);
  white-space: nowrap;
}

.load-error {
  margin: 0;
  padding: 22px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
}

.post-page-main {
  width: min(100% - 36px, 880px);
  margin: 0 auto;
  padding: 68px 0 88px;
}

.post-page-article {
  max-width: 760px;
}

.post-page-header {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.post-page-header h1 {
  margin: 10px 0 18px;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: var(--w-light);
  line-height: var(--lh-title);
  letter-spacing: 0;
}

.post-page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  font-weight: var(--w-label);
  letter-spacing: var(--track-label);
  line-height: var(--lh-micro);
  text-transform: uppercase;
}

.post-page-meta a {
  color: var(--accent-strong);
}

.post-original-note {
  margin: 0;
  padding-top: 28px;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  line-height: var(--lh-micro);
}

.post-original-note a {
  color: var(--accent-strong);
}

.post-content {
  padding-top: 34px;
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

.post-content > *:first-child {
  margin-top: 0;
}

.post-content > *:last-child {
  margin-bottom: 0;
}

.post-content p,
.post-content ul,
.post-content ol,
.post-content blockquote,
.post-content pre,
.post-content figure {
  margin: 0 0 1.2em;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  margin: 1.75em 0 0.55em;
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: var(--w-mid);
  line-height: var(--lh-title);
  letter-spacing: 0;
}

.post-content ul,
.post-content ol {
  padding-left: 1.35em;
}

.post-content li + li {
  margin-top: 0.45em;
}

.post-content blockquote {
  padding-left: 1.1em;
  border-left: 1px solid var(--border);
  color: var(--muted);
}

.post-content pre {
  overflow-x: auto;
  padding: 14px 16px;
  background: var(--surface-muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  line-height: var(--lh-body);
  white-space: pre-wrap;
}

.post-content hr {
  height: 1px;
  margin: 2em 0;
  border: 0;
  background: var(--border);
}

/* Migrated WordPress posts carry inline-styled highlights (<mark> and spans with
   a hardcoded light background) that break in dark mode. Normalize them to a
   theme-aware highlight that stays readable in both themes. */
.post-content mark,
.post-content [style*="background-color"] {
  background-color: var(--highlight-bg) !important;
  color: inherit !important;
  padding: 0.05em 0.18em;
  border-radius: 2px;
}

.post-content img {
  width: auto;
  max-width: 100%;
  margin: 1.5em 0;
}

.post-content figure img {
  margin: 0;
}

.post-content figcaption {
  margin-top: 0.65em;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  line-height: var(--lh-micro);
}

.post-page-footer {
  margin-top: 58px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.post-footer-all {
  display: inline-flex;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  font-weight: var(--w-label);
  letter-spacing: var(--track-label);
  line-height: var(--lh-micro);
  text-transform: uppercase;
  text-decoration: none;
}

.post-footer-all:hover {
  color: var(--accent-strong);
}

.post-related {
  margin-top: 34px;
}

.related-list {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.related-list li + li {
  margin-top: 22px;
}

.related-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  text-decoration: none;
}

.related-title {
  min-width: 0;
  max-width: 68%;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-weight: var(--w-mid);
  line-height: var(--lh-title);
}

.related-date {
  flex: none;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: var(--fs-micro);
  letter-spacing: var(--track-label);
  line-height: var(--lh-micro);
  white-space: nowrap;
}

.related-list a:hover .related-title {
  color: var(--accent-strong);
}

@media (max-width: 860px) {
  .page-grid {
    grid-template-columns: 1fr;
    padding-top: 0;
    padding-inline: 0;
  }

  .nav-toggle {
    display: inline-flex;
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 45;
    width: 36px;
    height: 30px;
  }

  .nav-close {
    display: inline-flex;
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 32px;
    height: 32px;
  }

  .side-nav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(82vw, 320px);
    height: 100vh;
    gap: 28px;
    padding: 60px 22px 28px;
    border-right: 1px solid var(--border);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 240ms ease;
  }

  body.nav-open {
    overflow: hidden;
  }

  body.nav-open .side-nav {
    transform: translateX(0);
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }

  body.nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-profile {
    align-items: end;
    grid-template-columns: minmax(96px, 138px) minmax(0, 1fr);
    gap: 18px;
    margin-top: 4px;
  }

  .profile-photo {
    width: 100%;
  }

  .social-links {
    align-content: end;
  }

  .home-main {
    padding: 68px 18px 48px;
  }

  .post-page-main {
    width: min(100% - 36px, 760px);
    padding-top: 68px;
  }
}

@media (max-width: 620px) {
  .side-nav {
    padding-right: 18px;
    padding-left: 18px;
  }

  .sidebar-profile {
    grid-template-columns: 1fr;
  }

  .profile-photo {
    width: 140px;
  }

  .post-page-main {
    width: min(100% - 32px, 760px);
    padding-bottom: 56px;
  }

  .post-page-header h1 {
    font-size: var(--fs-title);
    line-height: var(--lh-title);
  }
}
