:root {
  --bg: #07060b;
  --ink: #f4f1ea;
  --muted: rgba(244, 241, 234, 0.6);
  --line: rgba(244, 241, 234, 0.16);
  --a: #ff6b4a;
  --b: #ffb547;
  --c: #7c5cff;
  --d: #2fd5c5;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 300;
  overflow-x: hidden;
}
a { color: inherit; }

/* Background, toned down from the home page so long text stays legible */
.aurora {
  position: fixed;
  inset: -20%;
  filter: blur(110px) saturate(130%);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}
.blob {
  position: absolute;
  width: 45vmax;
  height: 45vmax;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: drift 26s ease-in-out infinite alternate;
}
.blob:nth-child(1) { background: var(--c); top: 5%;  left: 10%; }
.blob:nth-child(2) { background: var(--a); top: 40%; left: 55%; animation-duration: 30s; animation-delay: -6s; }
.blob:nth-child(3) { background: var(--d); top: 60%; left: 0%;  animation-duration: 34s; animation-delay: -12s; opacity: 0.6; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(6vw, -5vh) scale(1.1); }
  100% { transform: translate(-5vw, 6vh) scale(0.92); }
}
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 10;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--b), var(--a), var(--c), var(--d));
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(7, 6, 11, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
/* Slides out while scrolling down, floats back in on scrolling up (topbar.js) */
.topbar { transition: transform 350ms var(--ease); }
.topbar.is-hidden { transform: translateY(-100%); }
.topbar a { text-decoration: none; color: var(--muted); transition: color 200ms ease; }
.topbar a:hover, .topbar a:focus-visible { color: var(--ink); }
.topbar .brand { font-family: "Instrument Serif", Georgia, serif; font-size: 1.15rem; letter-spacing: 0; text-transform: none; color: var(--ink); }
.topbar nav { display: flex; gap: clamp(12px, 3vw, 28px); }
.topbar nav a { position: relative; padding: 6px 0; }
/* Underline in the site gradient: grows in faintly on hover, stays lit for the current section */
.topbar nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0.22em; /* the letter-spacing after the last letter */
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--b), var(--a), var(--c), var(--d));
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0.5;
  transition: transform 450ms var(--ease), opacity 300ms ease, box-shadow 300ms ease;
}
.topbar nav a:hover::after, .topbar nav a:focus-visible::after { transform: scaleX(1); }
.topbar nav a[aria-current] { color: var(--ink); font-weight: 500; }
.topbar nav a[aria-current]::after { transform: scaleX(1); opacity: 1; box-shadow: 0 0 12px rgba(255, 107, 74, 0.45); }
@media (prefers-reduced-motion: reduce) { .topbar nav a::after { transition: none; } }

main { position: relative; z-index: 2; padding: clamp(40px, 8vw, 96px) 16px 64px; }

.wrap { width: min(780px, 100%); margin: 0 auto; }

/* Long-form text card */
.article {
  padding: clamp(28px, 5vw, 60px);
  background: rgba(7, 6, 11, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 1.04rem;
  line-height: 1.8;
}
.article h1, .article h2 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.01em;
}
.article h1 { font-size: clamp(2.3rem, 6vw, 4rem); }
.article h2 { font-size: clamp(2.1rem, 5.4vw, 3.6rem); margin-bottom: 0.5em; }
.article h3 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.15;
  margin: 2.4em 0 0.8em;
  padding-top: 1.6em;
  border-top: 1px solid var(--line);
  scroll-margin-top: 80px;
}
.article h2 + h3 { margin-top: 1em; padding-top: 0; border-top: 0; }
.article p { margin: 0 0 1.15em; }
.article b { font-weight: 500; }
.article i { font-style: italic; }
.article p > i:only-child, .article p > i:first-child:last-child { color: rgba(244, 241, 234, 0.9); }
.article figure { margin: 2em 0; text-align: center; }
.article figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 2px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
/* Hover zoom, as on the home page cards: the frame lifts and glows, the image zooms inside it */
.article figure .zoom {
  display: inline-block;
  outline: none;
  max-width: 100%;
  vertical-align: top;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  transition: transform 300ms var(--ease), box-shadow 300ms ease, border-color 300ms ease;
}
.article figure.wide .zoom { display: block; }
.article figure .zoom img {
  outline: none;
  border-radius: 0;
  box-shadow: none;
  filter: saturate(0.9) brightness(0.92);
  transition: transform 900ms var(--ease), filter 300ms ease;
}
.article figure .zoom:not(.lb-quiet):hover,
.article figure .zoom:not(.lb-quiet):focus-visible,
.article figure .zoom:not(.lb-quiet):has(:focus-visible) {
  transform: translateY(-2px);
  border-color: rgba(244, 241, 234, 0.25);
  box-shadow: 0 22px 60px rgba(124, 92, 255, 0.28);
}
.article figure .zoom:not(.lb-quiet):hover img,
.article figure .zoom:not(.lb-quiet):focus-visible img,
.article figure .zoom:not(.lb-quiet):has(:focus-visible) img {
  transform: scale(1.03);
  filter: saturate(1) brightness(1);
}
@media (prefers-reduced-motion: reduce) {
  .article figure .zoom, .article figure .zoom img { transition: none; }
  .article figure .zoom:hover img, .article figure .zoom:has(:focus-visible) img { transform: none; }
}
.article figcaption {
  margin-top: 0.8em;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
}
.article .kicker, .label {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.2em;
}
.article .lede {
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  line-height: 1.3;
  margin: 0.6em 0 1.4em;
  color: rgba(244, 241, 234, 0.85);
}
.article .byline { font-size: 0.9rem; color: var(--muted); }
.article .notice {
  padding: 18px 22px;
  border-left: 2px solid var(--b);
  background: rgba(255, 181, 71, 0.07);
  font-size: 0.95rem;
}
.article .signature { margin-top: 2em; padding-top: 1.2em; border-top: 1px solid var(--line); color: var(--muted); }
.article ul:not(.biblio) { list-style: none; margin: 0 0 1.15em; padding: 0; }
.article ul:not(.biblio) li { position: relative; margin-bottom: 0.5em; padding-left: 1.3em; }
.article ul:not(.biblio) li::before { content: "•"; position: absolute; left: 0; top: 0; color: var(--muted); }
.article ul.biblio { list-style: none; margin: 0 0 1.5em; }
.article ul.biblio li { padding: 0.5em 0; border-bottom: 1px solid rgba(244, 241, 234, 0.07); font-size: 0.95rem; line-height: 1.6; }
.article a { text-decoration-color: rgba(244, 241, 234, 0.4); text-underline-offset: 0.18em; }

/* In-page contents for a chapter */
.toc {
  margin: 0 0 2.4em;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.92rem;
  line-height: 1.6;
}
.toc ol { list-style: none; }
.toc li { padding: 0.25em 0; }
.toc a { text-decoration: none; color: var(--muted); }
.toc a:hover, .toc a:focus-visible { color: var(--ink); }

/* Chapter cards on the overview page */
.chapters { display: grid; gap: 14px; margin-top: 28px; }
.chapter {
  display: block;
  padding: 22px 26px;
  text-decoration: none;
  background: rgba(7, 6, 11, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 300ms ease, transform 300ms var(--ease), box-shadow 300ms ease;
}
.chapter:hover, .chapter:focus-visible {
  border-color: rgba(124, 92, 255, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(124, 92, 255, 0.22);
}
.chapter .num { font-size: 0.72rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.chapter .title { display: block; margin-top: 4px; font-family: "Instrument Serif", Georgia, serif; font-size: clamp(1.5rem, 3.4vw, 2rem); line-height: 1.15; }
.chapter .subs { display: block; margin-top: 10px; font-size: 0.85rem; line-height: 1.6; color: var(--muted); }

/* Previous / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 28px; }
.pager a {
  display: block;
  padding: 18px 22px;
  text-decoration: none;
  border: 1px solid rgba(244, 241, 234, 0.2);
  border-radius: 4px;
  background: rgba(7, 6, 11, 0.55);
  transition: border-color 300ms ease, background 300ms ease;
}
.pager a:hover, .pager a:focus-visible { border-color: transparent; background: rgba(124, 92, 255, 0.22); }
.pager .dir { display: block; font-size: 0.7rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); }
.pager .t { display: block; margin-top: 4px; font-family: "Instrument Serif", Georgia, serif; font-size: 1.25rem; line-height: 1.2; }
.pager .next { text-align: right; grid-column: 2; }

footer {
  position: relative;
  z-index: 2;
  padding: 0 16px 56px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.7;
}
footer a { text-decoration-color: rgba(244, 241, 234, 0.4); text-underline-offset: 0.18em; }
footer a:hover { color: var(--ink); }

@media (max-width: 640px) {
  .topbar { flex-direction: column; gap: 8px; }
  .article { font-size: 1rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
