/* ==========================================================================
   Luca Scimeca — design tokens
   Light is the base palette; dark overrides only the tokens.
   ========================================================================== */

:root {
  /* Surfaces — cool, neutral paper */
  --bg:            #FCFCFD;
  --bg-elev:       #FFFFFF;
  --bg-sunken:     #F1F2F6;

  /* Ink */
  --fg:            #0E1116;
  --fg-strong:     #05070B;
  --fg-muted:      #4D535E;
  --fg-faint:      #6B7280;

  /* Lines */
  --line:          #E1E4EA;
  --line-strong:   #C2C7D2;

  /* Accent — deep indigo */
  --accent:        #2C46D8;
  --accent-hover:  #1F35B4;
  --accent-soft:   rgba(44, 70, 216, 0.10);

  /* Type */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Rhythm */
  --page:      1140px;
  --prose:     680px;
  --gutter:    clamp(1.25rem, 5vw, 3rem);
  --section:   clamp(3.75rem, 9vw, 7rem);
  --radius:    14px;
  --radius-sm: 8px;

  --shadow: 0 1px 2px rgba(14, 17, 22, .04), 0 8px 28px -14px rgba(14, 17, 22, .18);

  /* Logo chips keep a light ground in both themes — most org logos are dark ink. */
  --logo-chip:        #FFFFFF;
  --logo-chip-line:   var(--line);

  /* Highlighter wash behind institution names */
  --mark:             rgba(44, 70, 216, 0.07);


  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:            #0B0D11;
  --bg-elev:       #14171D;
  --bg-sunken:     #101318;

  --fg:            #E7E9ED;
  --fg-strong:     #FFFFFF;
  --fg-muted:      #A4AAB6;
  --fg-faint:      #838A97;

  --line:          #23272E;
  --line-strong:   #343A45;

  --accent:        #8497FF;
  --accent-hover:  #A2B1FF;
  --accent-soft:   rgba(132, 151, 255, 0.14);

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 34px -16px rgba(0, 0, 0, .7);

  --logo-chip:        #ECEEF2;
  --logo-chip-line:   #333944;

  --mark:             rgba(132, 151, 255, 0.11);


  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 3px;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.15;
  color: var(--fg-strong);
  text-wrap: balance;
}

p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--section) 0;
}

::selection { background: var(--accent-soft); color: var(--fg-strong); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--bg-elev);
  color: var(--fg-strong);
  padding: .6rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.prose-wrap { max-width: var(--prose); }

.section { padding-block: var(--section); }
.section + .section { padding-top: 0; }

.eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: .9375rem;
  font-weight: 500;
  letter-spacing: .075em;
  text-transform: uppercase;
  color: var(--fg-strong);
  margin: 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-strong);
}

/* The label's rule doubles as the first divider of the list beneath it. */
.eyebrow + .timeline .entry:first-child,
.eyebrow + .stack .stack-row:first-child { border-top: 0; }

.eyebrow + .card-grid,
.eyebrow + .post-body,
.eyebrow + .actions { margin-top: 2.25rem; }

.lede {
  font-size: clamp(1.0625rem, 1.6vw, 1.1875rem);
  line-height: 1.62;
  color: var(--fg-muted);
}

/* ==========================================================================
   Header / nav
   ========================================================================== */

/* --- Masthead ------------------------------------------------------------ */

.masthead {
  padding-top: clamp(1.75rem, 4vw, 2.75rem);
  padding-bottom: clamp(1.25rem, 2.5vw, 1.75rem);
  will-change: opacity, transform;
}
.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  flex-wrap: wrap;
}
.masthead-id { min-width: 0; }

.masthead-name {
  display: block;
  margin: 0;
  font-size: clamp(1.75rem, 4.4vw, 2.625rem);
  font-weight: 550;
  letter-spacing: .12em;
  text-transform: uppercase;
  line-height: 1.1;
  color: var(--fg-strong);
}
a.masthead-name { transition: color .16s ease; }
a.masthead-name:hover { color: var(--accent); }

.masthead-tagline {
  margin: .6rem 0 0;
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--fg);
}

.sociallinks--masthead { gap: .3rem; flex: none; }

/* --- Nav bar ------------------------------------------------------------- */

/*
 * The nav sits in a band ruled off above and below rather than filled — it
 * separates from the masthead without dropping a black slab into the page.
 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .2s ease;
}
/* A whisper of depth once content is passing underneath */
.site-header.is-stuck { box-shadow: 0 10px 20px -18px rgba(0, 0, 0, .5); }

.site-header .wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;   /* links centred, toggle pinned right */
  min-height: 56px;
}

.nav {
  display: flex;
  align-items: center;
}
.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(.85rem, 2.6vw, 2.25rem);
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.nav-links a {
  color: var(--fg-muted);
  padding-block: .35rem;
  position: relative;
  transition: color .16s ease;
}
.nav-links a:hover { color: var(--fg-strong); }
.nav-links a[aria-current="page"] { color: var(--fg-strong); font-weight: 600; }
.nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1.5px;
  background: var(--accent);
  border-radius: 2px;
}

.theme-toggle {
  position: absolute;
  right: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 0;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.theme-toggle:hover {
  color: var(--fg-strong);
  border-color: var(--line-strong);
  background: var(--bg-elev);
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ==========================================================================
   Home layout — content column with a sticky portrait/links rail beside it
   ========================================================================== */

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  padding-top: clamp(2.25rem, 5vw, 3.5rem);
  padding-bottom: var(--section);
}

.home-main { min-width: 0; }

.home-side {
  /* Sticks below the 56px nav bar once the page scrolls. Falls back to normal
     flow wherever `position: sticky` is unsupported, and is switched off
     entirely on narrow screens (see the media query below). */
  position: sticky;
  top: 76px;
}
.home-side-inner {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.linkrail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}

/* Embedded PDF viewer (CV page) */
.pdf-frame {
  height: min(78vh, 1040px);
  min-height: 480px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunken);
}
.pdf-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.pdf-note {
  margin-top: 1.1rem;
  font-size: .875rem;
  color: var(--fg-muted);
  max-width: 52ch;
}

/*
 * Sticky link bar (Work page). Rendered as a sibling of the page content in
 * the `page` layout, so it stays pinned for the whole scroll rather than only
 * while the page header is on screen. It parks directly under the 56px nav bar.
 */
.linkbar {
  position: sticky;
  top: 55px;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.linkbar .wrap { padding-block: .55rem; }

.linkrail--bar {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: .25rem .9rem;
}
.linkrail--bar .sociallinks { justify-content: flex-start; }

.btn-sm {
  font-size: .8125rem;
  padding: .45rem .85rem;
}
.btn-sm svg { width: 14px; height: 14px; }

.sociallinks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .25rem;
}

/*
 * Brand-coloured glyphs. The colour arrives as an inline --brand custom
 * property from _data/links.yml, with --brand-dark for marks that vanish
 * against a dark background.
 */
.sociallink {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--brand, var(--fg));
  transition: background .16s ease, transform .16s ease;
}
.sociallink svg { width: 26px; height: 26px; }
.sociallink:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); transform: translateY(-1px); }
:root[data-theme="dark"] .sociallink { color: var(--brand-dark, var(--brand, var(--fg))); }

/* Hover label — pointer devices only, so it can't stick after a tap */
@media (hover: hover) {
  .sociallink::after {
    content: attr(data-label);
    position: absolute;
    top: calc(100% - 2px);      /* below the row — clear of the CV button */
    left: 50%;
    transform: translateX(-50%) translateY(-3px);
    background: var(--fg-strong);
    color: var(--bg);
    font-family: var(--sans);
    font-size: .6875rem;
    font-weight: 500;
    letter-spacing: .01em;
    line-height: 1;
    padding: .35rem .5rem;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease;
    z-index: 5;
  }
  .sociallink:hover::after,
  .sociallink:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  /* Keep the label on screen for the icons at either end of the row */
  .sociallink:first-child::after { left: 0; transform: translateX(0) translateY(-3px); }
  .sociallink:first-child:hover::after,
  .sociallink:first-child:focus-visible::after { transform: translateX(0) translateY(0); }
  .sociallink:last-child::after { left: auto; right: 0; transform: translateX(0) translateY(-3px); }
  .sociallink:last-child:hover::after,
  .sociallink:last-child:focus-visible::after { transform: translateX(0) translateY(0); }
}


.block { padding-top: clamp(2.75rem, 6vw, 4.25rem); }

/* Roles and education, side by side */
.dual {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: clamp(1.75rem, 4vw, 3rem);
}

.reclist { display: grid; }

/*
 * Two rows: the year sits alone in the text column, then the logo and the
 * role line share the row below. That lines the logo up with the role rather
 * than the date, without hard-coding an offset.
 */
.rec {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 1.05rem;
  align-items: start;
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
}
.rec-years { grid-column: 2; grid-row: 1; }
.rec-logo  { grid-column: 1; grid-row: 2; }
.rec-body  { grid-column: 2; grid-row: 2; }
.rec:last-child { border-bottom: 1px solid var(--line); }
.eyebrow + .reclist .rec:first-child { border-top: 0; }

.rec-logo {
  width: 56px; height: 56px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--logo-chip);
  border: 1px solid var(--logo-chip-line);
  overflow: hidden;
}
.rec-logo img { width: 42px; height: 42px; object-fit: contain; }
.rec-logo--empty { background: none; border-color: transparent; }

.rec-body { min-width: 0; }
.rec-years {
  font-family: var(--mono);
  font-size: .8125rem;
  color: var(--fg-muted);
  margin: 0 0 .3rem;
  font-variant-numeric: tabular-nums;
}
.rec-role {
  font-size: 1rem;
  font-weight: 550;
  letter-spacing: -0.014em;
  color: var(--fg-strong);
  margin: 0 0 .25rem;
  line-height: 1.32;
}
.rec-org {
  font-size: .9063rem;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0;
}

/* ==========================================================================
   Hero
   ========================================================================== */

.portrait {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunken);
  aspect-ratio: 4 / 5;
  box-shadow: var(--shadow);
}
.portrait img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 22%;
}

/* Action buttons ---------------------------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .625rem;
}


.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
  padding: .68rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--fg);
  white-space: nowrap;
  transition: border-color .16s ease, color .16s ease, background .16s ease, transform .16s ease;
}
.btn:hover {
  border-color: var(--line-strong);
  color: var(--fg-strong);
  transform: translateY(-1px);
}
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary {
  background: var(--fg-strong);
  border-color: var(--fg-strong);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root[data-theme="dark"] .btn-primary { color: #0B0D11; }
:root[data-theme="dark"] .btn-primary:hover { color: #0B0D11; }


/* ==========================================================================
   "Now" callout
   ========================================================================== */

.now {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem 1.25rem;
  padding: 1.4rem 1.6rem;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.now-label {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  flex: none;
}
.now-title {
  font-size: 1.0625rem;
  font-weight: 550;
  color: var(--fg-strong);
  letter-spacing: -0.015em;
}
.now-note { color: var(--fg-muted); font-size: .9375rem; }

/* ==========================================================================
   Timeline (roles, education)
   ========================================================================== */

.timeline { display: grid; gap: 0; }

.entry {
  display: grid;
  grid-template-columns: 108px 60px minmax(0, 1fr);
  gap: 0 1.5rem;
  align-items: start;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}
.entry:last-child { border-bottom: 1px solid var(--line); }

.entry-years {
  font-family: var(--mono);
  font-size: .875rem;
  color: var(--fg-muted);
  padding-top: .12rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry-logo {
  width: 56px; height: 56px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--logo-chip);
  border: 1px solid var(--logo-chip-line);
  overflow: hidden;
}
.entry-logo img {
  width: 42px; height: 42px;
  object-fit: contain;
}

/* Text stand-in for institutions with no logo file */
.logo-monogram {
  font-family: var(--mono);
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--fg);
}
.entry-logo--empty {
  background: none;
  border-color: transparent;
}

.entry-body { min-width: 0; }
.entry-role {
  font-size: 1.0625rem;
  font-weight: 550;
  letter-spacing: -0.016em;
  color: var(--fg-strong);
  margin: 0 0 .2rem;
}
.entry-org {
  font-size: .9375rem;
  color: var(--fg-muted);
  margin: 0;
}
.entry-org .sep { color: var(--fg-faint); margin-inline: .45rem; }

/*
 * Institution names sit a shade darker and heavier than the line around them,
 * with a faint tint resting under the baseline — enough to catch the eye when
 * scanning, quiet enough to sit beside the bold role title above.
 */
.mark {
  font-weight: 500;
  color: var(--fg);
  background: var(--mark);
  padding: .16em .36em .2em;
  /* Pull the chip left so the text still aligns with the role title above. */
  margin-left: -.36em;
  border-radius: 5px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.entry-detail {
  font-size: .9375rem;
  color: var(--fg-muted);
  margin: .6rem 0 0;
  max-width: 56ch;
}
.entry-sub {
  margin: .75rem 0 0;
  padding: .7rem 0 0;
  border-top: 1px dashed var(--line);
  font-size: .875rem;
  color: var(--fg-muted);
  max-width: 56ch;
}
.entry-sub strong { color: var(--fg); font-weight: 550; }

/* ==========================================================================
   Services / awards lists
   ========================================================================== */

.stack { display: grid; gap: 0; }

.stack-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 0 1.5rem;
  padding: 1.35rem 0;
  border-top: 1px solid var(--line);
}
.stack-row:last-child { border-bottom: 1px solid var(--line); }
.stack-row > .entry-years { padding-top: .3rem; }

.stack-row ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: .55rem;
}
.stack-row li {
  font-size: .9375rem;
  color: var(--fg-muted);
  max-width: 62ch;
  position: relative;
  padding-left: 1.05rem;
}
.stack-row li::before {
  content: "";
  position: absolute;
  left: 0; top: .68em;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--line-strong);
}
.stack-row li em { color: var(--fg); font-style: normal; font-weight: 500; }

.award-title {
  font-size: 1rem;
  font-weight: 550;
  color: var(--fg-strong);
  letter-spacing: -0.014em;
  margin: 0 0 .15rem;
}
.award-org { font-size: .9375rem; color: var(--fg-muted); margin: 0; }
.award-org .sep { color: var(--fg-faint); margin-inline: .45rem; }
.award-detail { font-size: .875rem; color: var(--fg-muted); margin: .3rem 0 0; max-width: 58ch; }

/* ==========================================================================
   Post cards
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: clamp(1.5rem, 3vw, 2.25rem);
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-media {
  aspect-ratio: 16 / 9;
  background: var(--bg-sunken);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.card-media img,
.card-media video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s cubic-bezier(.2,.7,.3,1);
}
.card:hover .card-media img,
.card:hover .card-media video { transform: scale(1.028); }

.card-media--contain {
  display: grid;
  place-items: center;
  padding: 1rem;
}
.card-media--contain img,
.card-media--contain video { object-fit: contain; }

.card-body {
  padding: 1.25rem 1.35rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  flex: 1;
}

.card-date {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.card-title {
  font-size: 1.0625rem;
  font-weight: 550;
  letter-spacing: -0.018em;
  line-height: 1.32;
  color: var(--fg-strong);
}
.card:hover .card-title { color: var(--accent); }
.card-excerpt {
  font-size: .9063rem;
  color: var(--fg-muted);
  line-height: 1.58;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-more {
  margin-top: auto;
  padding-top: .85rem;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.card-more svg { width: 13px; height: 13px; transition: transform .18s ease; }
.card:hover .card-more svg { transform: translateX(3px); }

/* ==========================================================================
   Page header (Work, Posts, single post)
   ========================================================================== */

.page-head {
  padding-top: clamp(2.75rem, 6vw, 4.5rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
}
/* When a sticky link bar follows, it supplies the rule instead */
.page-head:has(+ .linkbar),
body:has(.linkbar) .page-head { border-bottom: 0; }
.page-head h1 {
  font-size: clamp(2.125rem, 5vw, 3.25rem);
  font-weight: 550;
  letter-spacing: -0.035em;
  margin: 0 0 1rem;
}
.page-head .lede { max-width: 46em; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 1.75rem;
  transition: color .16s ease;
}
.back-link:hover { color: var(--accent); }
.back-link svg { width: 13px; height: 13px; }

/* ==========================================================================
   Post article
   ========================================================================== */

.post-head { padding-top: clamp(2.25rem, 5vw, 3.5rem); }
.post-meta {
  font-family: var(--mono);
  font-size: .8125rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 1.1rem;
}
.post-head h1 {
  font-size: clamp(1.875rem, 4.4vw, 2.75rem);
  font-weight: 550;
  letter-spacing: -0.032em;
  line-height: 1.13;
  margin: 0 0 1.15rem;
}
.post-standfirst {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--fg-muted);
  margin: 0;
}

.post-cover {
  margin-top: clamp(2rem, 4vw, 3rem);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
}
.post-cover img { width: 100%; }

.post-body {
  padding-block: clamp(2.25rem, 5vw, 3.25rem) var(--section);
  font-size: 1.0625rem;
  line-height: 1.72;
  color: var(--fg);
}
.post-body > * { max-width: var(--prose); }

.post-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.024em;
  margin: 2.75rem 0 .9rem;
}
.post-body h3 {
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  margin: 2.25rem 0 .7rem;
}
.post-body p { margin: 0 0 1.35em; }
.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, transparent);
  transition: text-decoration-color .16s ease;
}
.post-body a:hover { text-decoration-color: var(--accent); }

.post-body ul, .post-body ol { margin: 0 0 1.35em; padding-left: 1.35em; }
.post-body li { margin-bottom: .45em; }

.post-body blockquote {
  margin: 1.75rem 0;
  padding: .2rem 0 .2rem 1.4rem;
  border-left: 2px solid var(--accent);
  color: var(--fg-muted);
  font-size: 1.0625rem;
}

.post-body code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--bg-sunken);
  padding: .15em .38em;
  border-radius: 4px;
}
.post-body pre {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-size: .875rem;
  line-height: 1.6;
}
.post-body pre code { background: none; padding: 0; }

/* Figures line up with the text column rather than breaking out of it */
.post-body figure {
  margin: 2rem 0;
  max-width: var(--prose);
}
.post-body figure img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
}
.post-body figure.plain img { border: 0; background: none; }
/* Small source images stay at their own size rather than being upscaled. */
.post-body figure.natural { width: fit-content; }
.post-body figure.natural img { width: auto; max-width: 100%; }
.post-body figcaption {
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--fg-muted);
  margin-top: .7rem;
}

/* Looping clips (converted from the original GIFs) */
.post-body .clip {
  margin: 2rem 0;
  max-width: var(--prose);
}
.post-body .clip video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunken);
}
.post-body .clip--portrait { max-width: min(100%, 340px); }

.post-body .video {
  position: relative;
  margin: 2rem 0;
  max-width: var(--prose);
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
}
.post-body .video iframe {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* Math overflow guard */
.post-body mjx-container[jax="CHTML"][display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: .3rem;
}

/* Inline resource links at the end of a post */
.post-links {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
  margin-top: 2.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  max-width: var(--prose);
}

/* Prev / next */
.post-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  max-width: var(--prose);
}
.post-nav a {
  display: block;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .16s ease, background .16s ease;
}
.post-nav a:hover { border-color: var(--line-strong); background: var(--bg-elev); }
.post-nav .dir {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  display: block;
  margin-bottom: .4rem;
}
.post-nav .t {
  font-size: .9375rem;
  font-weight: 500;
  color: var(--fg-strong);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-nav .next { text-align: right; }

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: clamp(2.5rem, 5vw, 3.5rem);
  margin-top: var(--section);
}
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  align-items: center;
  justify-content: space-between;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.35rem;
  font-size: .875rem;
}
.footer-links a {
  color: var(--fg-muted);
  transition: color .16s ease;
}
.footer-links a:hover { color: var(--accent); }
.footer-note {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--fg-muted);
  letter-spacing: .02em;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .home-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .home-side {
    position: static;   /* no sticky rail once the columns stack */
    top: auto;
    order: -1;
    width: 100%;
  }
  /* Cap the photo, not the whole rail, so the links keep the full width to
     wrap across instead of stacking into a tall tower. */
  .home-side-inner { align-items: center; gap: 1.25rem; }
  .home-side .portrait { width: 200px; }
  .linkrail { width: 100%; }
  /* Once the columns stack, the masthead icons and the rail icons end up a
     few centimetres apart. Keep the rail, drop the duplicate. */
  .sociallinks--masthead { display: none; }
  .masthead-inner { gap: 0; }
}

@media (max-width: 640px) {
  .entry {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 0 1rem;
    padding: 1.35rem 0;
  }
  .entry-years {
    grid-column: 1 / -1;
    margin-bottom: .55rem;
    padding-top: 0;
  }
  .entry-logo { width: 48px; height: 48px; }
  .entry-logo img { width: 34px; height: 34px; }

  .stack-row { grid-template-columns: 1fr; gap: .75rem; }
  .stack-row > .entry-years { padding-top: 0; }

  .nav-links { gap: .9rem; font-size: .8125rem; }

  .post-nav .next { text-align: left; }
}

@media (max-width: 460px) {
  .site-header .wrap { justify-content: flex-start; padding-right: 3.25rem; }
  .nav-links { gap: .8rem; font-size: .78125rem; }
  .masthead { padding-top: 1.75rem; }
}
