/* Unvalued — a book, in spreads.
   Each chapter is two pages: text on the left, the plate on the right.
   The plate stays in place while the text beside it is read. */

:root {
  --paper: #F7F5EF;
  --ink: #17160F;
  --ink-soft: #3B3A32;
  --grey: #6B6A62;
  --rule: rgba(23, 22, 15, 0.14);
  --gutter-shade: rgba(23, 22, 15, 0.06);

  --abyss: #2E5F7E;
  --ochre: #C9A062;
  --kelp: #5C7A5A;
  --plum: #7D5A79;

  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;

  --margin: 6.5rem;         /* left page: margin for numbers and notes */
  --measure: 31rem;         /* left page: text column, ~64 characters */
  --fold: 5rem;             /* the gutter between the two pages */
  --page-pad: 1.25rem;
  --head-h: 4.25rem;
  --book-w: 1440px;
  /* The left edge of the book, so fixed furniture stays with the pages on a wide screen. */
  --book-left: max(var(--page-pad), calc((100vw - var(--book-w)) / 2 + var(--page-pad)));
}

* { box-sizing: border-box; }
/* Smooth scrolling comes on once the page has opened at its address; the first jump is instant. */
html.is-ready { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html.is-ready { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.45;
  font-feature-settings: "onum" 1, "liga" 1, "kern" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-left: max(var(--page-pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--page-pad), env(safe-area-inset-right, 0px));
  overflow-x: clip;
}

/* Paper grain */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background-image:
    radial-gradient(rgba(23,22,15,0.045) 0.6px, transparent 0.7px),
    radial-gradient(rgba(23,22,15,0.025) 0.6px, transparent 0.7px);
  background-size: 3px 3px, 11px 11px;
  background-position: 0 0, 2px 5px;
}

a { color: inherit; text-decoration: underline; text-decoration-thickness: 0.6px; text-underline-offset: 0.16em; }
a:hover { text-decoration-thickness: 1px; }
a:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 4px; }
::selection { background: rgba(46, 95, 126, 0.18); }

/* ───────────── The wordmark, top left, in the title page's caps ───────────── */
.brand {
  position: fixed; left: var(--book-left); top: 1.5rem; z-index: 40;
  font-size: 0.95rem; line-height: 1; font-weight: 600; text-transform: uppercase; letter-spacing: 0.34em; text-decoration: none; color: var(--ink);
  opacity: 0; transition: opacity 500ms ease;
}
.brand.is-visible { opacity: 1; }
/* No box after a click; a keyboard reader still gets a thin underline */
.brand:focus { outline: none; }
.brand:focus-visible { outline: none; text-decoration: underline; text-underline-offset: 0.35em; text-decoration-thickness: 0.6px; }

/* ───────────── The rail: the chapters, down the left edge, level with the chapter heading ───────────── */
.rail {
  position: fixed; left: var(--book-left); top: calc(var(--head-h) + 2.2rem + 0.55rem); z-index: 40;
  display: flex; flex-direction: column; gap: 0.1rem;
  font-size: 14px; line-height: 1.45; color: var(--grey);
  opacity: 0; transition: opacity 500ms ease;
}
.rail.is-visible { opacity: 1; }
.rail a { text-decoration: none; display: grid; grid-template-columns: 1.6rem 1fr; column-gap: 0.4rem; align-items: baseline; white-space: nowrap; }
.rail a .r-num { font-variant-numeric: oldstyle-nums tabular-nums; text-align: right; }
.rail a .r-title { font-style: italic; }
.rail a:hover { color: var(--ink); }
.rail a.is-current { color: var(--ink); font-weight: 600; }
/* Project rows sit under their chapter, a step in and a size down */
.rail a.r-sub { font-size: 13px; line-height: 1.5; }
.rail a.r-sub .r-title { padding-left: 0.6rem; }
.rail a.r-sub.is-current { font-weight: 400; color: var(--ink); }
.rail a.r-sub.is-current .r-title { text-decoration: underline; text-decoration-thickness: 0.6px; text-underline-offset: 0.2em; }

/* ───────────── The book ───────────── */
.book { max-width: var(--book-w); margin: 0 auto; }

/* A spread: two pages with a fold between them */
.chapter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--fold) minmax(0, 1fr);
  padding-top: var(--head-h);
  position: relative;
}

.page { min-width: 0; }
.page-text {
  grid-column: 1;
  display: grid; grid-template-columns: var(--margin) minmax(0, var(--measure));
  padding: 2.2rem 0 4rem 0;
  align-content: start;
}
.page-text > * { grid-column: 2; min-width: 0; }
.page-plate {
  grid-column: 3;
  height: 100%; min-height: 0;
  padding: 2.2rem 0 2rem 0;
  display: flex; flex-direction: column; justify-content: flex-start;   /* the plate's top sits level with the text's */
}
/* A right-hand page of text, on spreads that have no plate */
.page-right { grid-column: 3; }

/* Running text, set like the reference spreads */
.page-text p {
  margin: 0;
  text-align: justify;
  hyphens: auto; -webkit-hyphens: auto;
  text-indent: 1.5em;
  text-wrap: pretty;
}
.page-text p.first, .page-text h3 + p, .page-text figure + p, .chapter-head + p, .page-text aside + p { text-indent: 0; }
.page-text p.first::first-letter {
  float: left; font-style: normal;
  font-size: 3.55em; line-height: 0.8;
  padding: 0.08em 0.1em 0 0;
}
.page-text p em { font-style: italic; }

.cont .page-text { padding-top: 2.6rem; }
.chapter-head {
  grid-column: 1 / 3;
  display: grid; grid-template-columns: var(--margin) 1fr; align-items: baseline;
  margin-bottom: 2.4rem;
}
.ch-num { font-size: 1.1rem; font-style: italic; color: var(--ink-soft); padding-left: 0.1rem; }
.page-text h2 { grid-column: 2; margin: 0; font-size: 2.1rem; font-weight: 400; letter-spacing: -0.005em; line-height: 1.1; }
.page-text h3 { margin: 2.6rem 0 0.9rem; font-size: 1.32rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; }
/* The former heading sits under the project name as a sub-header */
.page-text .subhead { margin: -0.6rem 0 1rem; text-indent: 0; font-style: italic; font-size: 1.08rem; line-height: 1.3; color: var(--ink-soft); text-align: left; hyphens: manual; }
.page-text .subhead + p { text-indent: 0; }
/* Paragraphs that open with a label ("The question.", "Show the work.") start flush and carry the label in bold. */
.page-text p:has(> em:first-child) { text-indent: 0; margin-top: 0.55em; }
.page-text h3 + p:has(> em:first-child), .chapter-head + p:has(> em:first-child) { margin-top: 0; }
.page-text p > em:first-child { font-style: normal; font-weight: 600; }
/* A project that opens on a prompt instead of a labelled question: set bold, flush, and the paragraph after it flush too. */
.page-text .prompt { text-indent: 0; font-weight: 600; margin-top: 0; text-align: left; hyphens: manual; }
.page-text .prompt + p { text-indent: 0; margin-top: 0.55em; }
/* A project page as question, method, result: the question given air over a hairline,
   the method as numbered beats with the numerals in the margin, the result as a closing line. */
.page-text h3.eyebrow { font-family: var(--sans); font-size: 12px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--grey); line-height: 1.5; margin-top: 0; }
.page-text h3.eyebrow + .prompt { margin-top: 0.7rem; }
.page-text .prompt-lead { font-size: 1.15em; line-height: 1.35; margin-bottom: 1.5rem; text-wrap: pretty; }
/* A paragraph after the lead, plain */
.page-text .beat { text-indent: 0; text-align: left; hyphens: manual; text-wrap: pretty; margin: 0; }
/* A small map set in the text column, in the chart's thin ink line */
/* The map on the left with its key and caption beside it, the whole row as wide as the text above */
.inset.inset-map.map-row { display: grid; grid-template-columns: min(12rem, 19svh) 1fr; align-items: start; column-gap: 1.4rem; margin-top: 1rem; max-width: none; }
.map-row svg { grid-column: 1; }
.map-row .map-side { grid-column: 2; align-self: center; }
.map-row > figcaption { grid-column: 1 / -1; margin-top: 0.6rem; max-width: none; }
.range-key { margin: 0.2rem 0 0; display: grid; grid-template-columns: 26px auto; column-gap: 0.5rem; row-gap: 0.45rem; align-items: center; font-family: var(--sans); font-size: 12px; line-height: 1.5; color: var(--grey); white-space: nowrap; }
.range-key dt, .range-key dd { margin: 0; }
.range-key dt { color: var(--ink); line-height: 0; }
.inset.inset-map { margin: 0.9rem 0 0; max-width: min(12rem, 19svh); }
.inset.inset-map svg { display: block; width: 100%; height: auto; border: 0; }
.inset.inset-map figcaption { margin-top: 0.5rem; }
.page-text .steps { margin: 0; padding: 0; list-style: none; }
.page-text .steps li { margin-bottom: 0.85em; text-align: left; hyphens: manual; text-wrap: pretty; }
/* Iterations: a repeat mark with the stage number in the margin, and the stage's name as a run-in opener */
.page-text .iterations li { position: relative; padding-left: 2.7rem; margin-bottom: 0.7em; }
.page-text .iterations li p { margin: 0; text-indent: 0; text-align: left; hyphens: manual; text-wrap: pretty; }
.page-text .iterations li p > em:first-child { font-style: normal; font-weight: 600; }
.page-text .iterations .iter { position: absolute; left: 0; top: -0.08em; width: 1.85em; height: 1.85em; color: var(--ink); }
/* A pulled line, set large between hairlines, the way a magazine lifts a sentence out of its column */
.page-text .pull { margin: 1.1rem 0 0; padding: 0; }
.page-text .pull p { margin: 0; text-indent: 0; text-align: left; hyphens: manual; font-size: 1.5em; font-weight: 600; line-height: 1.2; letter-spacing: -0.008em; text-wrap: balance; }
.page-text .pull + .result { margin-top: 0; }
.page-text .pull ~ .result:last-child { margin-bottom: -0.2rem; }
.page-text .result { margin-top: 1.6rem; text-indent: 0; text-align: left; hyphens: manual; font-style: italic; font-size: 1.15em; line-height: 1.4; text-wrap: pretty; }
/* A project page is centred on its own height, the way its plate is */
/* Centred on the plate's band (the figure and its caption), not on the whole page height, so text and figure share a middle */
.cont .page-text.centred, .page-text.centred { align-content: center; padding-top: 2.2rem; padding-bottom: max(0px, calc(100svh - var(--head-h) - 2.2rem - 68svh - 5.5rem)); }
/* A page whose content is taller than the band gives the padding up rather than scrolling */
@supports (height: 1svh) { .page-text.centred { padding-bottom: clamp(0px, calc(100svh - var(--head-h) - 2.2rem - 68svh - 5.5rem), 100%); } }
.page-text.centred.is-long { padding-top: 1.2rem; padding-bottom: 0.6rem; }
.page-text h3:first-of-type { margin-top: 2.2rem; }

/* Marginalia: notes in the left margin, italic */
.marginalia { grid-column: 1; align-self: start; padding-right: 1.2rem; margin-top: 0.2rem; }
.marginalia p { margin: 0; text-indent: 0; text-align: left; hyphens: manual; font-size: 14.5px; line-height: 1.4; font-style: italic; color: var(--grey); }

/* A statement spread to open a chapter: a small line above, the question bold and centred, and a foot that points on */
/* The question sits a little above true centre: the eye reads that as centred, and it leaves the foot line its own room. */
.chapter.statement { position: relative; display: flex; align-items: center; justify-content: center; padding-top: 0; padding-bottom: 14svh; }
.page-statement { max-width: 62rem; padding: 0 2rem; text-align: center; }
.page-statement p { margin: 0; text-indent: 0; text-align: center; }
.statement-kicker { font-style: italic; font-size: clamp(1rem, 1.4vw, 1.2rem); color: var(--ink-soft); margin-bottom: 1.4rem !important; }
.statement-main { font-weight: 600; font-size: clamp(1.5rem, 2.6vw, 2.35rem); line-height: 1.28; letter-spacing: -0.005em; text-wrap: balance; }
.statement-foot {
  position: absolute; left: 0; right: 0; bottom: 2.6rem; margin: 0; text-indent: 0; text-align: center;
  font-style: italic; font-size: 0.95rem; color: var(--grey);
}
.statement-arrow { display: block; margin: 0.5rem auto 0; color: var(--grey); animation: point-down 2.2s ease-in-out infinite; }
@keyframes point-down { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .statement-arrow { animation: none; } }

/* ───────────── Figures ───────────── */
figure { margin: 0; min-width: 0; }
.plate .frame, .plate svg, .plate .empty-frame { display: block; width: 100%; }
figcaption {
  font-family: var(--sans);
  font-size: 12px; line-height: 1.5; color: var(--grey);
  margin-top: 0.75rem; text-align: left; hyphens: manual; text-indent: 0;
  max-width: 40rem;
}
/* On the plate page the figure takes the top of the page, no taller than about two-thirds of the screen, with its caption directly beneath */
.page-plate figure { display: flex; flex-direction: column; align-items: center; height: auto; max-height: 100%; min-height: 0; }
.page-plate figure svg, .page-plate figure .plate-3d { flex: 0 1 auto; min-height: 0; width: 100%; height: auto; max-height: min(68svh, 100%); }
.page-plate figure .plate-3d { aspect-ratio: 600 / 760; width: auto; height: min(68svh, 100%); max-width: 100%; cursor: grab; touch-action: none; }
.page-plate figure .plate-3d.is-dragging { cursor: grabbing; }
.page-plate figure .empty-frame, .page-plate figure .plate-placeholder { flex: 0 0 auto; width: auto; height: 68svh; max-width: 100%; }
/* A plate that is an image: the same height as the others, its width from its own proportions */
.page-plate figure .plate-img { flex: 0 0 auto; display: block; width: auto; height: 68svh; max-width: 100%; object-fit: contain; }
.page-plate figcaption { flex: 0 0 auto; align-self: stretch; margin-top: 1.1rem; }

/* A plate that is a stage: a drawing with a video on it (Fig. 5, the jaguar walking the portfolio) */
.plate-stage { position: relative; overflow: hidden; }
.plate-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* The jaguar waits offstage and unseen until the figure has sized and placed it, so it never shows at the clip's own size. */
.plate-stage video { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; pointer-events: none; transform-origin: 0 0; will-change: transform; transition: opacity 300ms ease; }
.plate-stage video.is-placed { opacity: 1; }
.page-plate figure .plate-stage { flex: 0 0 auto; height: 68svh; aspect-ratio: 4 / 5; width: auto; max-width: 100%; }
/* A quiet pause/play in the plate's corner, in the caption's type */
.stage-toggle {
  position: absolute; right: 0.4rem; top: 0.3rem;
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.06em; color: var(--grey);
  background: none; border: 0; padding: 0.2rem 0.3rem; cursor: pointer; opacity: 0.55;
  transition: opacity 300ms ease, color 300ms ease;
}
.stage-toggle:hover, .stage-toggle:focus-visible { opacity: 1; color: var(--ink); outline: none; }

/* Insets sit in the text column, small, like the reference spreads */
.inset { margin: 1.6rem 0 1.8rem; max-width: 24rem; }
.inset svg { border: 1px solid var(--rule); }
.empty-frame { border: 1px dashed var(--grey); position: relative; aspect-ratio: 4 / 5; overflow: hidden; cursor: crosshair; }
/* A plate still to come: a dashed frame with the image's name */
.plate-placeholder { border: 1px dashed var(--grey); aspect-ratio: 4 / 5; display: grid; place-items: center; text-align: center; padding: 1rem; }
.plate-placeholder span { font-style: italic; font-size: 1.15rem; color: var(--grey); }
.empty-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--serif); font-style: italic; font-size: 1.15rem; color: var(--grey);
  transition: opacity 300ms ease;
}

/* ───────────── Title page ───────────── */
.title-page {
  /* The title page is the one dark page: ink ground, paper type, the ocean in light lines. */
  background: var(--ink); color: var(--paper);
  position: relative; height: 100svh;
  width: 100vw; margin-left: calc(50% - 50vw);   /* bleeds past the book's margins to the edges of the screen */
  display: grid; align-content: end;
  padding: 0 0 5rem clamp(1.25rem, 12vw, 16rem);
  overflow: hidden;
}
.ocean { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.half-title { position: relative; max-width: 44rem; padding: 2rem 2.5rem 1.5rem 0; }
.half-title::before {
  /* a wash of paper so the title reads over the tracks */
  content: ""; position: absolute; inset: -4rem -14rem -3rem -10rem; z-index: -1;
  background: radial-gradient(ellipse at 45% 55%, var(--ink) 52%, rgba(23,22,15,0.88) 68%, rgba(23,22,15,0) 92%);
}
/* The title and byline are set as spaced capitals, the way a title page is; the subtitle is the italic line beneath. */
.half-title h1 {
  margin: 0 0 0 0.05em; font-size: clamp(2.4rem, 6vw, 5.4rem); font-weight: 400; line-height: 1;
  text-transform: uppercase; letter-spacing: 0.34em; white-space: nowrap;
}
.half-title .subtitle { margin: 2.2rem 0 0 0.15rem; font-style: italic; color: rgba(247,245,239,0.9); font-size: 1.3rem; }
.edition { font-size: 15px; color: var(--grey); margin: 0.4rem 0 0; }
.colophon p.first::first-letter, .page-text p.first:has(> em:first-child)::first-letter { float: none; font-size: inherit; line-height: inherit; padding: 0; }
.contents {
  margin: 2.2rem 0 0 0.15rem;
  display: flex; flex-direction: column; gap: 0.15rem; align-items: flex-start;
  font-size: 17px; line-height: 1.5; font-style: italic; color: rgba(247,245,239,0.78);
}
.contents a { text-decoration: none; display: grid; grid-template-columns: 1.6rem 1fr; }
.contents a:hover { color: var(--paper); }
.half-title > * { opacity: 0; transform: translateY(6px); }
.half-title.is-in > * { opacity: 1; transform: none; transition: opacity 900ms cubic-bezier(.2,.7,.2,1), transform 900ms cubic-bezier(.2,.7,.2,1); }
.half-title.is-in > :nth-child(2) { transition-delay: 160ms; }
.half-title.is-in > :nth-child(3) { transition-delay: 320ms; }

/* The one character that beats */
.xin { display: inline-block; cursor: default; transition: color 300ms ease; font-family: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", serif; line-height: 1; }
.xin.is-beating { color: var(--plum); animation: beat 1s ease-in-out infinite; }
@keyframes beat {
  0%, 100% { transform: scale(1); } 12% { transform: scale(1.14); } 24% { transform: scale(1); } 36% { transform: scale(1.09); } 48% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .half-title > * { opacity: 1; transform: none; transition: none; }
  .xin.is-beating { animation: none; }
}

/* ───────────── Wide: one spread per screen, and the scroll snaps to it ───────────── */
@media (min-width: 1101px) {
  html { scroll-snap-type: y mandatory; }
  body { font-size: clamp(14px, 2.05vh, 20px); }
  .spread { scroll-snap-align: start; scroll-snap-stop: always; }
  .chapter { height: 100svh; overflow: hidden; }
  /* If a page runs long for the screen, it scrolls inside its own edges rather than cutting off. */
  .page-text { height: 100%; min-height: 0; overflow: hidden; padding-bottom: 1.25rem; }
  .page-text.is-long { overflow-y: auto; scrollbar-width: none; }
  .cont .page-text { padding-top: 1.3rem; }
  .page-text h3 { margin-top: 1.9rem; }
  .page-text h3:first-of-type { margin-top: 1.6rem; }
  .page-text.is-long::-webkit-scrollbar { display: none; }
  .chapter { margin-left: 14rem; }   /* room for the rail, wide enough for a project name on one line; the title page bleeds past it */
  :root { --margin: 2.5rem; }
  .marginalia { grid-column: 2; margin: 0.6rem 0 1rem; padding: 0 0 0 1rem; border-left: 1px solid var(--rule); max-width: 26rem; }
  /* The rail already numbers the chapter; the margin need not say it again. */
  .ch-num { visibility: hidden; }
}

/* ───────────── Narrower: one page at a time ───────────── */
@media (max-width: 1100px) {
  :root { --margin: 5rem; }
  .chapter { grid-template-columns: 1fr; }
  .page-text { grid-column: 1; }
  .page-plate { grid-column: 1; order: -1; position: static; height: auto; padding: 0.5rem 0 3.5rem var(--margin); max-width: 44rem; }
  .page-plate figure { height: auto; }
  .page-text { padding-bottom: 2.5rem; }
  .page-plate figure svg { height: auto; }
  .page-plate figure .empty-frame, .page-plate figure .plate-placeholder { width: 100%; height: auto; max-width: 20rem; }
  .page-plate figure .plate-img { width: 100%; height: auto; max-width: 28rem; }
  .page-plate figure .plate-stage { width: 100%; height: auto; max-width: 28rem; }
  .page-plate figure svg { max-height: none; }
  .page-plate figure .plate-3d { width: 100%; height: auto; max-width: 28rem; }
  .chapter.statement { min-height: 80svh; padding: 3rem 0 7rem; }
  .rail, .brand { display: none; }
}
@media (max-width: 640px) {
  :root { --margin: 0rem; --measure: 100%; }
  body { font-size: 18px; }
  .page-text { grid-template-columns: 0 1fr; padding-top: 1.4rem; }
  .page-text p { text-align: left; hyphens: manual; }
  .chapter-head { grid-template-columns: 2.2rem 1fr; }
  .marginalia { grid-column: 2; margin: 0.8rem 0 0.9rem; padding-left: 0.9rem; border-left: 1px solid var(--rule); }
  .page-plate { padding-left: 0; }
  .title-page { padding-bottom: 7rem; }
  .half-title h1 { font-size: 2.05rem; letter-spacing: 0.24em; }
}
