:root {
  --bg: #0b0b0b;
  --fg: #f2f0ec;
  --tile: #1a1a19;
  --faint: rgba(242, 240, 236, 0.14);

  --grotesk: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;

  --pad: clamp(1rem, 1.6vw, 1.75rem);
  --measure: 38rem;
  --ease: cubic-bezier(0.5, 0.25, 0, 1);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 0.9375rem/1.45 var(--serif);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

/* ── Page transitions ────────────────────────────────────────
   A 1.5s crossfade whenever a link goes to another page on this site —
   About, Work, Archive, an entry, anywhere — and on back/forward too
   (site.js opts every page out of the bfcache so those always replay
   it, rather than the browser silently restoring a cached page with no
   transition). Native browser feature: no JS for the fade itself, and
   it works because every page shares this stylesheet, so it also
   crossfades even when the two pages don't share a color scheme (dark
   site pages ↔ the white About/post pages). Where it doesn't do
   anything, e.g. Firefox for now, links just navigate as normal — the
   site works exactly the same either way. External links (target=_blank)
   are never affected, since they open a new tab rather than navigate. */
@view-transition {
  navigation: auto;
}
::view-transition-group(root),
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 1.5s;
  animation-timing-function: ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

/* Small uppercase grotesk used for labels everywhere */
.label,
.site-nav,
.site-name,
.kicker,
.group-label,
.site-footer {
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Dim until hovered or active: the site's main interaction idiom */
.dim { opacity: 0.5; transition: opacity 0.3s linear; }
.dim:hover,
.dim[aria-current="page"],
.dim[aria-pressed="true"],
.active > .dim { opacity: 1; }

/* ── Header ──────────────────────────────────────────────── */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--pad);
}
.site-nav { display: grid; grid-template-columns: repeat(3, minmax(4.5rem, 7rem)); }
.page .site-header { background: linear-gradient(var(--bg) 60%, transparent); }
.site-name { white-space: nowrap; }
@media (max-width: 34rem) { .site-name { display: none; } }

/* ── Home: full-bleed photos ─────────────────────────────── */

.home { overflow: hidden; height: 100svh; }

.stage { position: fixed; inset: 0; background: #000; }
.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 2s ease-in-out; /* keep in step with FADE in site.js */
}
.stage img.active { opacity: 1; }
.home .site-header,
.work,
.name { text-shadow: 0 0 1.25rem rgba(0, 0, 0, 0.35); }
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent 30%, transparent 60%, rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.work {
  position: fixed;
  z-index: 10;
  top: calc(var(--pad) + 2.25rem);
  left: var(--pad);
  right: var(--pad);
  list-style: none;
  margin: 0;
  padding: 0;
}
.work a {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) minmax(4.5rem, 7rem) 3rem;
  padding-block: 0.1rem;
}
.work .w-meta,
.work .w-year { font-family: var(--grotesk); font-size: 0.6875rem; letter-spacing: 0.04em; padding-top: 0.2rem; }
@media (max-width: 34rem) {
  .work a { grid-template-columns: 1fr auto; }
  .work .w-meta { display: none; }
}

/* Name split in two halves around the centre; the gap breathes on hover */
.name {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  font: 700 0.9375rem / 1 var(--grotesk);
  font-stretch: 112%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  pointer-events: none; /* only the words are clickable, not the whole row */
  --gap: clamp(2.5rem, 7.3vw, 9rem);
}
.name span { flex: 1; padding-block: 0.5rem; pointer-events: auto; transition: padding 0.45s var(--ease); }
.name span:first-child { text-align: right; padding-right: var(--gap); }
.name span:last-child { text-align: left; padding-left: var(--gap); }
.name:hover { --gap: clamp(1.75rem, 5.2vw, 6.5rem); }

@media (prefers-reduced-motion: reduce) {
  .stage img,
  .name span { transition: none; }
}

/* ── Inner pages ─────────────────────────────────────────── */

.page main { position: relative; padding: 6rem var(--pad) 0; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 8rem;
  padding: var(--pad);
  opacity: 0.5;
}

/* ── Archive ─────────────────────────────────────────────── */

.filters { display: grid; gap: 0.6rem; margin-bottom: 1rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: 0.25rem 1.4rem; }
.filter {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.filter sup { font-family: var(--grotesk); font-size: 0.6rem; margin-left: 0.15rem; }

.search {
  width: min(18rem, 100%);
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--faint);
  padding: 0.4rem 0;
  margin-top: 0.4rem;
}
.search::placeholder { color: var(--fg); opacity: 0.4; }
.search:focus { outline: none; border-bottom-color: var(--fg); }

.count { opacity: 0.5; margin: 0; }

.group-label { margin: 2.75rem 0 0.5rem; }
.subgroup-label {
  font-family: var(--grotesk);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  opacity: 0.55;
  margin: 1.5rem 0 0.5rem;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.25rem 0.375rem;
}
@media (max-width: 60rem) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 34rem) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.book-feature {
 overflow: hidden;
 width: 100%;
}
.book-track {
 display: flex;
 align-items: flex-start;
 gap: 1.25rem;
 transition: transform 0.8s ease;
 will-change: transform;
}
.book-card {
 flex: 0 0 13rem;
 min-width: 0;
}
.book-card a {
 display: block;
}
.book-cover {
 aspect-ratio: 2 / 3;
 background: var(--tile);
 overflow: hidden;
}
.book-cover img { width: 100%; height: 100%; object-fit: contain; }
.book-cover-placeholder {
 display: flex;
 flex-direction: column;
 justify-content: center;
 gap: 0.75rem;
 height: 100%;
 padding: 1rem;
 background: #e8e1d3;
 color: #24211d;
 font-family: var(--serif);
 font-size: 1.15rem;
 line-height: 1.15;
 text-align: center;
}
.book-cover-placeholder span {
 font-family: var(--grotesk);
 font-size: 0.625rem;
 letter-spacing: 0.06em;
 text-transform: uppercase;
}
.book-details h3 { margin: 0.55rem 0 0; font-size: 1rem; line-height: 1.15; }
.book-subtitle { margin: 0.35rem 0 0; font-size: 0.875rem; line-height: 1.25; font-style: italic; }
.book-author { margin: 0.75rem 0 0; font-family: var(--grotesk); font-size: 0.6875rem; letter-spacing: 0.04em; text-transform: uppercase; }
@media (max-width: 34rem) {
 .book-card { flex-basis: 10rem; }
}

.thumb {
  aspect-ratio: 4 / 3;
  background: var(--tile);
  overflow: hidden;
  transition: opacity 0.25s linear;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-text {
  display: flex;
  align-items: flex-end;
  height: 100%;
  padding: 0.6rem;
  font-style: italic;
  font-size: clamp(0.9375rem, 1.4vw, 1.25rem);
  line-height: 1.15;
}
/* Hovering one thumbnail fades out the rest */
.grid:has(a:hover) a:not(:hover) .thumb { opacity: 0.12; }

.t-title,
.t-meta { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-title { margin-top: 0.35rem; }
.t-meta { opacity: 0.5; }
.ext { font-family: var(--grotesk); font-size: 0.8em; opacity: 0.6; }

.empty { margin-top: 2.5rem; opacity: 0.7; }

/* ── Entry ───────────────────────────────────────────────── */

.entry-head { max-width: 52rem; }
.title-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 0.5rem 1.5rem; }
.entry-head h1 {
  margin: 0.75rem 0 0;
  font: 800 clamp(2rem, 5.5vw, 4.5rem) / 0.92 var(--grotesk);
  font-stretch: 112%;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.visit-top {
  position: absolute;
  top: 7.75rem; /* level with the title's cap-height */
  right: var(--pad); /* flush with the page edge, under "SAMUEL LEE" in the header */
  flex-shrink: 0;
  white-space: nowrap;
  font-family: var(--grotesk);
  font-weight: 600;
  font-size: 1.0625rem;
  opacity: 0.8;
}
@media (max-width: 40rem) {
  /* Too tight next to a wrapped, multi-line title — drop back into the flow. */
  .visit-top { position: static; display: inline-block; margin-top: 1rem; font-size: 0.9375rem; }
}
.kicker { margin: 0; }
.kicker a { opacity: 0.5; transition: opacity 0.3s; }
.kicker a:hover { opacity: 1; }
.lede { font-size: clamp(1.125rem, 1.8vw, 1.5rem); line-height: 1.35; max-width: var(--measure); margin: 1.25rem 0 0; opacity: 0.7; }

.entry-cover { margin-top: 2.5rem; }
.entry-cover img { width: 100%; max-height: 88svh; object-fit: cover; }
.cover-link { display: block; overflow: hidden; position: relative; }
.cover-link img { transition: transform 0.4s ease, filter 0.4s ease; }
.cover-link:hover img { transform: scale(1.015); filter: brightness(0.85); }
.cover-link::after {
  content: "Visit ↗";
  position: absolute;
  inset: auto auto 1.25rem 1.25rem;
  padding: 0.5rem 0.9rem;
  background: var(--bg);
  color: var(--fg);
  font: 600 0.8125rem var(--grotesk);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.cover-link:hover::after { opacity: 0.92; }
@media (prefers-reduced-motion: reduce) {
  .cover-link img { transition: none; }
}

figure { margin: 0; }
figcaption { margin-top: 0.4rem; opacity: 0.5; font-size: 0.8125rem; }

.prose { max-width: var(--measure); margin-top: 3rem; font-size: 1.125rem; line-height: 1.6; }
.prose h2 { font: 600 0.6875rem var(--grotesk); letter-spacing: 0.06em; text-transform: uppercase; margin: 2.5rem 0 0.75rem; }
.prose p,
.prose ul,
.prose ol { margin: 0 0 1.1rem; }
.prose a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.prose blockquote { margin: 2.25rem 0; font-style: italic; font-size: 1.6rem; line-height: 1.25; }
.prose img { margin-block: 2rem; }

.grid.children { margin-top: 3rem; }
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem 0.375rem; margin-top: 3rem; }
@media (max-width: 34rem) { .gallery { grid-template-columns: 1fr; } }

.visit,
.tags { margin: 2.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--faint);
}
.pager a { max-width: 48%; }
.pager a.older { text-align: right; margin-left: auto; }
.pager .label { display: block; opacity: 0.5; margin-bottom: 0.2rem; }

/* ── Post (reader mode) ──────────────────────────────────────
   For writing entries with reader: true — reads like the original
   publication: white page, Georgia serif, narrow centered column,
   a subtitle and byline instead of the site's usual dark kicker. */

body.post { --post-serif: Georgia, "Times New Roman", "Iowan Old Style", serif; }
body.post main { max-width: 42rem; margin-inline: auto; }
body.post .entry-head,
body.post .prose,
body.post .gallery,
body.post .visit,
body.post .tags,
body.post .pager { max-width: none; }

.post-head { text-align: center; }
.post-head h1 {
  font: 700 clamp(1.875rem, 4vw, 2.75rem) / 1.15 var(--post-serif);
  text-transform: none;
  letter-spacing: -0.01em;
  font-stretch: normal;
  margin-top: 0;
}
.post-subtitle {
  font: italic 1.25rem/1.4 var(--post-serif);
  color: var(--muted-post, #6b6b6b);
  opacity: 0.75;
  margin: 0.75rem 0 0;
}
.post-byline {
  font: 500 0.8125rem var(--grotesk);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.55;
  margin: 1.5rem 0 0;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--faint);
}

.post-prose { font-family: var(--post-serif); font-size: 1.25rem; line-height: 1.6; margin-top: 2.25rem; }
.post-prose p { margin: 0 0 1.4rem; }
.post-prose em { font-style: italic; }
.post-prose strong { font-weight: 700; }
.post-prose h2 {
  font: italic 700 1.375rem/1.35 var(--post-serif); /* the shorthand doesn't reset these two: */
  text-transform: none;
  letter-spacing: normal;
  margin: 2.75rem 0 1.1rem;
}
.post-prose h3 {
  font: 700 1.0625rem/1.4 var(--post-serif);
  text-transform: none;
  letter-spacing: normal;
  margin: 2rem 0 0.85rem;
}
.post-prose .eq { text-align: center; font-style: italic; margin: 1.75rem auto; max-width: 32rem; }
.post-prose sub { font-size: 0.7em; }

/* A stargazer-style regression table: numbers right-aligned, SE in
   parens on the line below the coefficient, double rule above/below. */
.reg-table-wrap { overflow-x: auto; margin: 2rem 0; }
.reg-table { width: 100%; min-width: 28rem; border-collapse: collapse; font: 0.875rem/1.4 var(--grotesk); }
.reg-table caption {
  caption-side: top;
  text-align: center;
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
}
.reg-table th,
.reg-table td { padding: 0.4rem 0.5rem; text-align: right; vertical-align: top; }
.reg-table th:first-child,
.reg-table td:first-child { text-align: left; }
.reg-table thead th { border-top: 3px double var(--faint); border-bottom: 1px solid var(--faint); }
.reg-table .se { display: block; font-size: 0.8em; opacity: 0.65; }
.reg-table .rule-top td { border-top: 1px solid var(--faint); padding-top: 0.6rem; }
.reg-table tfoot td { border-top: 3px double var(--faint); padding-top: 0.6rem; }
.reg-table .note { text-align: left; font-size: 0.75rem; opacity: 0.65; }

.post-prose blockquote {
  margin: 1.75rem 0;
  padding-left: 1.25rem;
  border-left: 2px solid var(--faint);
  font-style: italic;
}

.post-prose sup.fn { font-size: 0.7em; margin-left: 0.05em; }
.post-prose sup.fn a { text-decoration: none; }
.post-prose .footnotes {
  font: 0.9375rem/1.55 var(--grotesk);
  padding-left: 1.25rem;
  margin: 0;
}
.post-prose .footnotes li { margin-bottom: 0.9rem; }
.post-prose .footnotes .fn-back { margin-left: 0.35em; text-decoration: none; opacity: 0.6; }
.post-prose .references p { font-size: 1.0625rem; margin-bottom: 0.9rem; text-indent: -1.5em; padding-left: 1.5em; }

/* ── About ───────────────────────────────────────────────── */

/* The About page flips to black on white */
.light {
  --bg: #ffffff;
  --fg: #111111;
  --faint: rgba(17, 17, 17, 0.14);
  color-scheme: light;
}

/* Centred on the page, independent of the text column below it */
.seal {
  display: block;
  width: clamp(4.5rem, 8vw, 6.5rem);
  height: auto;
  margin: 4rem 0 0;
}

.about { max-width: var(--measure); padding-top: 2.5rem; }
.about .lede { opacity: 1; margin-top: 0; }
.about .lede + .lede { margin-top: 1.25rem; }
.about dl { display: grid; grid-template-columns: 7rem 1fr; gap: 0.5rem 1rem; margin: 3rem 0 0; }
.about dt { opacity: 0.5; padding-top: 0.15rem; }
.about dd { margin: 0; }
.about dd a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
