:root {
  --void: #030303;
  --ivory: #ece7dc;
  --ivory-soft: rgba(236, 231, 220, 0.66);
  --ivory-faint: rgba(236, 231, 220, 0.16);
  --copper: #c47c4f;
  --signal: #92b6d8;
  --paper: #dcd7cb;
  --terracotta: #c86f45;
  --ink: #141210;
  --ink-soft: rgba(20, 18, 16, 0.64);
  --ink-faint: rgba(20, 18, 16, 0.3);
  --ink-rule: rgba(20, 18, 16, 0.2);
  --ink-accent: #8a4a26;
  --void-rgb: 3, 3, 3;
  --ivory-rgb: 236, 231, 220;

  /* The On stage movement: a colour layer blended over the particle canvas. */
  --terra-blend: screen;
  --on-terra: var(--ink);
  --on-terra-soft: rgba(20, 18, 16, 0.82);
  --on-terra-faint: rgba(20, 18, 16, 0.35);
  --on-terra-accent: var(--ivory);

  /* Particle canvas colours as "r, g, b"; main.js reads these. Invert = 1 draws the
     portrait dark-on-light for light themes. */
  --particle: 236, 231, 220;
  --particle-accent: 196, 124, 79;
  --particle-signal: 146, 182, 216;
  --particle-marker: 236, 231, 220;
  --particle-halo: 3, 3, 3;
  --particle-invert: 0;

  --serif: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --sans: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --display-weight: 400;
  --display-stretch: normal;
  --display-strong: 600;
  --accent-style: italic;
  --tracking-k: 1;

  --gutter: clamp(1rem, 3.5vw, 3.5rem);
  --rail: 11rem;
  --col: 34rem;

  color-scheme: dark;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--void);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
a:hover { color: var(--copper); }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 4px; border-radius: 2px; }

.skip {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 50;
  background: var(--ivory); color: var(--void); padding: 0.5rem 0.9rem;
}
.skip:focus { top: 1rem; }

/* ---------- the field ---------- */
.field {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* No z-index here: sections must share a stacking context with the canvas so the
   terracotta layer can blend with the particles behind it. */
main { position: relative; }

/* ---------- rail ---------- */
.rail {
  position: fixed; z-index: 10;
  left: var(--gutter); top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.8125rem;
}
.rail a {
  display: grid; grid-template-columns: 2.6rem auto; align-items: baseline;
  text-decoration: none; color: var(--ivory-soft);
  padding: 0.2rem 0;
  transition: color 0.3s;
}
.rail__num { font-family: var(--serif); font-style: var(--accent-style); font-size: 0.95rem; color: var(--ivory-faint); transition: color 0.3s; }
.rail__name { position: relative; }
.rail__name::before {
  content: ""; position: absolute; left: -0.9rem; top: 50%;
  width: 0.4rem; height: 1px; background: var(--copper);
  transform: scaleX(0); transform-origin: left; transition: transform 0.4s;
}
.rail a[aria-current="true"] { color: var(--ivory); }
.rail a[aria-current="true"] .rail__num { color: var(--copper); }
.rail a[aria-current="true"] .rail__name::before { transform: scaleX(1); }
.rail a:hover { color: var(--ivory); }
@media (min-width: 901px) {
  .rail--ink a, .rail--ink a:hover, .rail--ink a[aria-current="true"] { color: var(--ink); }
  .rail--ink .rail__num { color: var(--ink-faint); }
  .rail--ink a[aria-current="true"] .rail__num { color: var(--ink-accent); }
  .rail--terra a, .rail--terra a:hover, .rail--terra a[aria-current="true"] { color: var(--on-terra); }
  .rail--terra .rail__num { color: var(--on-terra-faint); }
  .rail--terra a[aria-current="true"] .rail__num { color: var(--on-terra-accent); }
  .rail--terra .rail__name::before { background: var(--on-terra); }
}

/* ---------- shared column ---------- */
.hero, .beat, .contact {
  padding-left: calc(var(--gutter) + var(--rail));
  padding-right: var(--gutter);
}

/* Display type shares one width setting so themes can use a wide or condensed face. */
.hero__name, .hero__role, .movement__title, .lead, .beat__title, .events h3, .archive__head h2,
.archive__place, .contact__title, .numeral, .rail__num, .projects__prompt { font-stretch: var(--display-stretch); }

/* ---------- hero ---------- */
.hero {
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding-top: 6rem; padding-bottom: 6rem;
  max-width: calc(var(--gutter) + var(--rail) + 44rem);
}
.hero__place {
  margin: 0 0 1.4rem;
  color: var(--copper);
  font-size: 0.875rem; letter-spacing: 0.02em;
}
.hero__name {
  margin: 0;
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: var(--display-weight);
  font-size: clamp(4rem, 9.6vw, 9rem);
  line-height: 0.86;
  letter-spacing: calc(-0.035em * var(--tracking-k));
}
.hero__role {
  margin: 2.2rem 0 0;
  max-width: 30rem;
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2.1vw, 1.6rem);
  line-height: 1.3;
}
.hero__role strong { font-weight: var(--display-strong); }
.hero__lede {
  margin: 1.4rem 0 0;
  max-width: 31rem;
  color: var(--ivory-soft);
}
.hero__cue {
  margin: 3.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--ivory-soft);
  display: flex; align-items: center; gap: 0.8rem;
}
.hero__cue::before {
  content: ""; width: 2.5rem; height: 1px; background: var(--copper);
  transform-origin: left;
  animation: cue 2.8s cubic-bezier(.6,0,.2,1) infinite;
}
@keyframes cue { 0% { transform: scaleX(0); } 50% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hero__cue::before { animation: none; } }

/* ---------- movements & beats ---------- */
.movement { position: relative; }
.beat {
  min-height: 88svh;
  display: flex; flex-direction: column; justify-content: center;
  padding-top: 5rem; padding-bottom: 5rem;
}
.beat > * { max-width: var(--col); }
.beat--open { min-height: 100svh; }
.movement--major .beat--open .movement__title { font-size: clamp(2.75rem, 6.4vw, 5.75rem); }

.movement__mark {
  margin: 0 0 1.25rem;
  display: flex; align-items: baseline; gap: 0.75rem;
  color: var(--copper); font-size: 0.9375rem;
}
.numeral { font-family: var(--serif); font-style: var(--accent-style); font-size: 1.6rem; line-height: 1; }

.movement__title {
  margin: 0 0 1.75rem;
  font-family: var(--serif);
  font-weight: var(--display-weight);
  font-size: clamp(2.3rem, 5vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: calc(-0.02em * var(--tracking-k));
  max-width: min(14ch, 37rem);
}
.lead {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1.7vw, 1.375rem);
  line-height: 1.5;
  margin: 0 0 1.2rem;
}
.beat p { margin: 0 0 1.1rem; }
.beat p:not(.lead):not(.movement__mark):not(.events__when):not(.projects__prompt) { color: var(--ivory-soft); }

.beat__title {
  margin: 0 0 1.1rem;
  font-family: var(--serif);
  font-weight: var(--display-weight);
  font-size: clamp(1.9rem, 3.6vw, 3rem);
  line-height: 1.05;
  letter-spacing: calc(-0.015em * var(--tracking-k));
}
.beat__index { font-style: var(--accent-style); color: var(--copper); margin-right: 0.3em; }

/* ---------- events ---------- */
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 3rem; }
.events h3 { margin: 0 0 0.6rem; font-family: var(--serif); font-weight: var(--display-weight); font-size: clamp(1.8rem, 3.2vw, 2.6rem); line-height: 1.05; }
.events__when { margin: 0 0 0.5rem !important; font-size: 0.875rem; color: var(--copper); display: flex; gap: 0.8rem; align-items: center; }
.events__tag {
  font-size: 0.75rem; color: var(--void); background: var(--copper);
  padding: 0.05rem 0.5rem; border-radius: 999px;
}

/* ---------- projects ---------- */
.projects { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--ivory-faint); }
.projects li { padding: 1.1rem 0 1.2rem; border-bottom: 1px solid var(--ivory-faint); }
.beat .projects__prompt { margin: 0 0 0.45rem; font-family: var(--serif); font-style: var(--accent-style); font-size: 1.2rem; line-height: 1.4; color: var(--ivory); }
.projects a { font-size: 0.9375rem; color: var(--copper); text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 0.35s; }
.projects a:hover { background-size: 100% 1px; }

/* ---------- terracotta movement ----------
   The colour is a "screen" layer over the particle canvas: solid terracotta over the
   black page, with the particles showing through as light dots. */
.movement--terracotta { color: var(--on-terra); }
.movement--terracotta::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--terracotta);
  mix-blend-mode: var(--terra-blend);
}
.movement--terracotta > .beat { position: relative; }
.movement--terracotta .movement__mark,
.movement--terracotta .events__when { color: var(--on-terra); }
.movement--terracotta .beat p:not(.lead):not(.movement__mark):not(.events__when) { color: var(--on-terra-soft); }
.movement--terracotta .beat .lead { color: var(--on-terra); }
.movement--terracotta .events__tag { background: var(--on-terra); color: var(--terracotta); }
.movement--terracotta a:hover { color: var(--on-terra-accent); }
.movement--terracotta :focus-visible { outline-color: var(--on-terra); }

/* ---------- archive (paper) ---------- */
.archive {
  position: relative; z-index: 3;
  background: var(--paper); color: var(--ink);
  padding: clamp(4rem, 9vw, 8rem) var(--gutter) clamp(4rem, 9vw, 7rem) calc(var(--gutter) + var(--rail));
  display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 40rem); gap: clamp(2rem, 6vw, 6rem);
}
.archive__head h2 { margin: 0 0 1rem; font-family: var(--serif); font-weight: var(--display-weight); font-size: clamp(2rem, 3.6vw, 3rem); line-height: 1.05; letter-spacing: calc(-0.015em * var(--tracking-k)); }
.archive__head p { margin: 0 0 1.4rem; color: var(--ink-soft); font-size: 0.9375rem; }
.archive__head a { font-size: 0.9375rem; }
.archive__head a:hover, .archive a:hover { color: var(--ink-accent); }
.archive :focus-visible { outline-color: var(--ink); }
.archive__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink-rule); }
.archive__list li { display: grid; grid-template-columns: 4rem 1fr; gap: 1rem; padding: 0.95rem 0; border-bottom: 1px solid var(--ink-rule); }
.archive__list--path li { grid-template-columns: 11rem 1fr; align-items: baseline; padding: 1.15rem 0; }
.archive__place { font-family: var(--serif); font-size: 1.5rem; line-height: 1.2; }
.archive__list--path li:last-child .archive__place { color: var(--ink-accent); }
.archive__what { color: var(--ink-soft); font-size: 0.9375rem; }

/* ---------- contact ---------- */
.contact {
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding-top: 6rem; padding-bottom: 4rem;
}
.contact__title {
  margin: 0 0 2.5rem;
  font-family: var(--serif); font-weight: var(--display-weight);
  font-size: clamp(2.5rem, 5vw, 4.75rem); line-height: 1; letter-spacing: calc(-0.025em * var(--tracking-k));
  max-width: 13ch;
}
.contact__links { list-style: none; margin: 0 0 3rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.contact__links a {
  display: inline-block; text-decoration: none;
  border: 1px solid var(--ivory-faint); border-radius: 999px;
  padding: 0.65rem 1.3rem; font-size: 0.9375rem;
  transition: border-color 0.25s, background 0.25s, color 0.25s;
}
.contact__links a:hover { border-color: var(--copper); background: var(--copper); color: var(--void); }
.contact__meta { margin: 0 0 0.3rem; color: var(--ivory-soft); font-size: 0.9375rem; }
.contact__meta--small { font-size: 0.8125rem; opacity: 0.7; margin-top: 1rem; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  :root { --rail: 0rem; }
  .rail {
    top: auto; bottom: 0; left: 0; right: 0; transform: none;
    flex-direction: row; justify-content: space-between; gap: 0;
    padding: 0.6rem var(--gutter) calc(0.6rem + env(safe-area-inset-bottom));
    background: linear-gradient(rgba(var(--void-rgb), 0), rgba(var(--void-rgb), .92) 40%);
  }
  .rail a { grid-template-columns: auto; justify-items: center; font-size: 0.72rem; }
  .rail__num { font-size: 0.85rem; }
  .rail__name::before { display: none; }
  .rail a[data-for="top"] { display: none; }

  .hero, .beat, .contact { padding-left: var(--gutter); padding-right: var(--gutter); }
  .hero { justify-content: flex-end; padding-bottom: 7rem; }
  .beat { min-height: 100svh; justify-content: flex-end; padding-top: 48svh; padding-bottom: 6rem; }
  .hero__lede, .beat p { color: rgba(var(--ivory-rgb), .8); }
  .archive { grid-template-columns: 1fr; padding-left: var(--gutter); }
  .archive__list--path li { grid-template-columns: 1fr; gap: 0.2rem; }
}

@media (max-width: 480px) {
  .hero__name { font-size: clamp(3.6rem, 21vw, 5rem); }
}
