/* ------------------------------------------------------------------
   bryanboyer.com — minimal baseline.
   Intentionally plain and placeholder-ish; this is the file to replace
   when we do the real design. Everything tunable lives in :root.
   ------------------------------------------------------------------ */

:root {
  /* The site is a 3% grey, and the board of squares lies on it with no
     field of its own. */
  color-scheme: light;

  --ink:        #171719;
  --paper:      #f7f7f7;
  --rule:       #cccdd0;
  --accent:     #171719;
  --highlight:  #f2e6a0;   /* text selection */

  --font-head:  'Noto Serif Display', Georgia, serif;
  --font-body:  'Noto Sans', system-ui, sans-serif;
  --font-ui:    'Noto Sans', system-ui, sans-serif;
  --font-mono:  'Noto Sans Mono', ui-monospace, monospace;

  /* Type scale. Change --size-body and the rest stay in proportion by eye;
     the column widens with the text so line length stays readable. */
  --size-body:  1.25rem;     /* 20px */
  --size-h1:    2.3rem;      /* 37px */
  --size-h2:    1.65rem;     /* 26px */
  --size-h3:    1.4375rem;   /* 23px */
  --size-notes: 1.125rem;    /* 18px — footnotes */
  --size-nav:   1rem;        /* 16px — header nav */
  --size-meta:  0.9375rem;   /* 15px — dates, venues, captions */

  --measure:    38rem;   /* reading column width, ~62 characters */
  --gutter:     1.5rem;
  --rhythm:     1.7;

  /* Height of the fixed header: nav type (1rem) on the body rhythm, plus its
     own 1rem of padding top and bottom. Body padding and scroll targets both
     clear the header by referencing this. */
  --header-h:   3.7rem;
}

@media (max-width: 30rem) {
  :root {
    --size-body: 1.125rem;
    --size-h1:   2rem;
    --size-h2:   1.5rem;
    --size-h3:   1.3rem;
    --gutter:    1.25rem;
  }
}

/* --- reset ------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, ul, ol, li, figure, blockquote { margin: 0; }

/* --- page -------------------------------------------------------- */

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  background: var(--paper);
  color: var(--ink);
  font: 300 var(--size-body)/var(--rhythm) var(--font-body);
  margin: 0 auto;
  max-width: var(--measure);
  padding: calc(var(--header-h) + 1.25rem) var(--gutter) 6rem;
  text-rendering: optimizeLegibility;
}

/* --- header / footer --------------------------------------------- */

/* Fixed, so the name and nav stay reachable while the board or a long piece
   scrolls under them. Being fixed positions it against the viewport, which
   also puts it at the page's own corners rather than the text measure's —
   so the full-bleed trick .stage needs isn't wanted here, and we avoid
   100vw's scrollbar overflow along with it.

   z-index because .stage and its sheets are positioned and come later in the
   document; without it they paint over the header as they scroll past. The
   header itself is transparent, so what scrolls under it stays visible. */
.site-header {
  align-items: baseline;
  background: transparent;
  display: flex;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: var(--size-nav);
  gap: 0.5rem 1.25rem;
  justify-content: space-between;
  left: 0;
  padding: 1rem var(--gutter);
  position: fixed;
  right: 0;
  top: 0;
  z-index: 10;
}

.site-name { font-weight: 600; text-decoration: none; }
.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { font-weight: 600; text-decoration: none; }   /* matches .site-name */

/* A text page's title, docked in the header once the real one has scrolled
   away (header-title.js). Same type and top padding as the nav, so it sits
   on the nav's baseline, lined up with the reading column.

   Its arrival and departure are tied to the scroll, not timed: the script
   sets --dock from 0 (the big title is fully in view below the header) to 1
   (it has gone up under it), and --dock-shift, how far the small title
   still has to travel. It moves with the page, so scrolling back up carries
   it down and away as the big title comes back into view. */
.header-title {
  font-weight: 600;   /* matches .site-name */
  left: max(var(--gutter), (100% - var(--measure)) / 2 + var(--gutter));
  opacity: var(--dock, 0);
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  text-overflow: ellipsis;
  top: 1rem;
  transform: translateY(var(--dock-shift, 0px));
  transition: color 0.6s ease;
  white-space: nowrap;
  width: min(calc(var(--measure) - 2 * var(--gutter)), 100% - 2 * var(--gutter) - 5rem);
}

/* Behind the docked title, a bar of paper that fades to transparent at its
   foot, so the essay fades out as it scrolls up under the header instead of
   running into the title. Solid behind the nav line, then a soft edge below
   it. It comes and goes with the title. z-index -1 keeps it under the
   header's own text but, inside the header's stacking context, over the
   essay. */
.page-piece .site-header::before {
  background: linear-gradient(to bottom,
    var(--paper) 0, var(--paper) var(--header-h), transparent 100%);
  content: '';
  height: calc(var(--header-h) + 2.5rem);
  left: 0;
  opacity: var(--dock, 0);
  pointer-events: none;
  position: absolute;
  right: 0;
  top: 0;
  z-index: -1;
}

/* On a narrow window there's no room beside the site name, and the name
   wins: no docked title. The bar still fades the essay under the header. */
@media (max-width: 54rem) {
  .header-title { display: none; }
}

/* The writing views are the homepage (the squares) and an individual piece —
   on those, a link to Writing points at where you already are. Hidden by
   naming the writing views rather than by showing it only on About, so a
   future section page gets the link instead of silently losing it. */
.page-home .nav-writing,
.page-piece .nav-writing { display: none; }

.site-footer {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--size-meta);
  margin-top: 5rem;
  padding-top: 0.75rem;
}

/* --- type -------------------------------------------------------- */

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.25; }

/* The text is set light (300), and the browser's own "bolder" only steps
   that up to 400 -- regular, barely different. Bold gets a weight of its own. */
b, strong { font-weight: 600; }
h1 { font-size: var(--size-h1); margin-bottom: 0.5rem; }
h2 { font-size: var(--size-h2); margin: 2.5rem 0 0.5rem; }
h3 { font-size: var(--size-h3); margin: 2rem 0 0.25rem; }

p, ul, ol, blockquote, pre, figure { margin-bottom: 1.25rem; }
ul, ol { padding-left: 1.25rem; }
li { margin-bottom: 0.25rem; }

::selection { background: var(--highlight); color: var(--ink); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* Quotes step in by one column -- the board's type column and its gap --
   and set in italic, with no rule. Narrower on a phone. */
blockquote {
  font-style: italic;
  margin-left: 7.75rem;
}
blockquote em { font-style: normal; }

@media (max-width: 30rem) {
  blockquote { margin-left: 2.5rem; }
}

code, pre { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.875em; }
pre {
  background: #ececec;
  border-radius: 3px;
  overflow-x: auto;
  padding: 0.75rem 1rem;
}
pre code { background: none; padding: 0; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* --- images ------------------------------------------------------ */

img { display: block; height: auto; max-width: 100%; }
figure { margin-inline: 0; }
figcaption,
p > img + em,
/* A linked image wraps the img in an <a>, so match that shape too. */
p > a:has(> img) + em {
  /* Its own block, so this line-height governs it rather than the body
     rhythm of the paragraph it sits in. */
  display: block;
  font-family: var(--font-ui);
  font-size: var(--size-meta);
  line-height: 1.485;
  /* Same gap as between two images, which is the paragraph spacing. */
  margin-top: 1.25rem;
}

/* --- writing index ----------------------------------------------- */

.page-title { margin-bottom: 2.5rem; }

/* Each year is two columns: the year on the left, on the baseline of its
   first title, and the titles to its right. With room, the year column
   hangs out into the left margin so the titles keep the reading column's
   left edge; on a narrow window it takes its width from the column. */
.year {
  align-items: baseline;
  column-gap: 1.25rem;
  display: grid;
  grid-template-columns: 3rem 1fr;
  margin-bottom: 2.5rem;
}

@media (width > 54rem) {
  .year { margin-left: -4.25rem; }
}

.year-label {
  margin: 0;
}

/* The list's meta columns, year and type: small mono capitals in ink. */
.year-label,
.piece-type {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8125rem;   /* 13px */
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.piece-list { list-style: none; padding: 0; }
.piece-list li { margin-bottom: 0.5rem; }

/* Each entry is its type, then its title, as two columns on one baseline. */
.piece-list li {
  align-items: baseline;
  column-gap: 1.25rem;
  display: grid;
  grid-template-columns: 6.5rem 1fr;
}

/* The type links to the list filtered to that type (list-filter.js); on a
   filtered list, to the whole list again. */
.piece-type { text-decoration: none; }
.piece-type:hover { text-decoration: underline; }

/* Filtered out. Spelled out because both are display: grid, which would
   otherwise beat the browser's own [hidden] rule. */
.year[hidden],
.piece-list li[hidden] { display: none; }

/* On a phone, three columns leave the titles too little room: the type
   goes above its title instead. */
@media (max-width: 30rem) {
  .piece-list li { display: block; }
  .piece-type { display: block; }
}

/* Arriving from a piece's year (/#slug): mark the piece you came from. */
.piece-list li:target > a:not(.piece-type) { background: var(--highlight); }


/* --- a single piece ---------------------------------------------- */

.piece-header { margin-bottom: 2rem; }

/* The essay itself starts halfway down the window. The header fills the
   space above it and sets the title at its foot, just over the first line:
   50vh, less the body's top padding and the header's own margin. */
.page-piece .piece-header {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: calc(50vh - var(--header-h) - 1.25rem - 2rem);
}
.piece-header h1 { margin-bottom: 0.375rem; }

/* The About page leads with its travels graphic, the same way: wide,
   centred on the text, and no taller than most of the window -- which,
   for a graphic this close to square, is what usually sets its size. */
.lead-figure {
  --w: min(100vw - 2 * var(--gutter), 64rem, 72vh * 600 / 554);
  margin: 0 0 2rem calc(50% - var(--w) / 2);
  width: var(--w);
}
.lead-figure .airports { aspect-ratio: 600 / 554; width: 100%; }
/* The caption comes back in to the text column: it's indented by however
   far the figure overhangs the column on each side. The column is the
   body's content box -- the measure, less the gutters. */
.lead-figure figcaption {
  --column: calc(min(var(--measure), 100vw) - 2 * var(--gutter));
  padding-inline: max(0px, (var(--w) - var(--column)) / 2);
}

/* A piece with a cover of its own leads with it, big: wider than the text,
   centred on it, and no taller than most of the window, so the title still
   shows beneath it on arrival. The cover fills the space the 50vh rule
   would otherwise hold open, so that rule is dropped. */
.page-piece .piece-header.has-cover { min-height: 0; }
/* A hero with a credit: the figure shrinks to the image as drawn, centred
   on the column, so the caption lines up with the image's left edge.
   The caption doesn't count toward the figure's width, only wraps in it. */
.piece-hero {
  margin: 0 0 2rem 50%;
  transform: translateX(-50%);
  width: fit-content;
}
.piece-hero .piece-cover {
  height: auto;
  margin: 0 0 0.75rem;
  max-width: min(100vw - 2 * var(--gutter), 64rem);
  width: auto;
}
.piece-hero figcaption { contain: inline-size; }
.piece-cover {
  --wide: min(100vw - 2 * var(--gutter), 64rem);
  margin: 0 0 2rem calc(50% - var(--wide) / 2);
  max-height: 72vh;
  max-width: none;
  object-fit: contain;
  object-position: center top;
  width: var(--wide);
}

/* A film in place of a cover: as wide as a cover, at 16:9, and no taller
   than a cover may be -- so on a short window it narrows, still centred. */
.piece-video {
  --wide: min(100vw - 2 * var(--gutter), 64rem, 72vh * 16 / 9);
  aspect-ratio: 16 / 9;
  margin: 0 0 2rem calc(50% - var(--wide) / 2);
  width: var(--wide);
}
.piece-video iframe { border: 0; display: block; height: 100%; width: 100%; }

/* Until it's played: the film's still, with a play mark at its centre --
   a black triangle on a disc of paper, which swells a little on hover. */
.video-poster { display: block; height: 100%; position: relative; }
.video-poster img { display: block; height: 100%; object-fit: cover; width: 100%; }
.video-play {
  background: var(--paper);
  border-radius: 50%;
  height: 4.5rem;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: transform 180ms ease-out;
  width: 4.5rem;
}
.video-play::after {
  background: var(--ink);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  content: '';
  height: 1.5rem;
  left: 50%;
  position: absolute;
  top: 50%;
  /* Nudged right of centre: a triangle's weight sits toward its base. */
  transform: translate(-38%, -50%);
  width: 1.3rem;
}
.video-poster:hover .video-play,
.video-poster:focus-visible .video-play { transform: translate(-50%, -50%) scale(1.08); }

@media (prefers-reduced-motion: reduce) {
  .video-play { transition: none; }
}

/* Headings inside a piece's text are bold; the title above keeps 600. */
.piece h2, .piece h3 { font-weight: 700; }

/* A heading that labels what follows (a film's script or transcript)
   rather than opening a section: set like the thread filters over the
   board. Written in the Markdown as <h2 class="label">. */
.piece h2.label {
  font: 400 0.8125rem/1.5 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Lists in the text take the label's small mono, in sentence case -- they
   run to whole sentences. Footnotes keep their own type. */
.piece > ul,
.piece > ol {
  font: 400 0.8125rem/1.3 var(--font-mono);
  letter-spacing: 0.04em;
}
.piece > ul > li,
.piece > ol > li { margin-bottom: 1.1rem; }
/* Bulleted lists drop the bullet and sit flush with the text; the space
   between items is what sets them apart. Numbered lists keep their numbers. */
.piece > ul { list-style: none; padding-left: 0; }

/* The coda: where a piece was written, closing the text. */
.piece-coda {
  font-family: var(--font-ui);
  font-size: var(--size-meta);
  margin-top: 2.5rem;
}


/* --- year, bottom left of the window ------------------------------ */

/* The piece's year, pinned to the bottom-left corner and set like the site
   name in the opposite corner. It links to the piece in the list view on the
   homepage, so you can see it among its neighbours. It goes when the header gives up the docked
   title (54rem and below): narrower than that it would sit on the text, and
   the coda carries the date. */
.piece-year { display: none; }

@media (width > 54rem) {
  .piece-year {
    bottom: 1rem;
    display: block;
    font-family: var(--font-ui);
    font-size: var(--size-nav);
    font-weight: 600;   /* matches .site-name */
    left: var(--gutter);
    margin: 0;
    position: fixed;
    text-decoration: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .piece-year { transition: none; }
}

/* The reading ruler: a column of hairline ticks in the left margin, one per
   300 words, centred between the name and the year. The tick
   for where the reader is runs longer (see reading-ruler.js).
   With JS each tick is a jump to its place in the piece: the span is a
   7px-tall strip, as wide as the site name above it, to aim at, and the
   hairline is drawn inside it. Under the
   pointer a tick reaches out halfway to the marked one's length. A tick
   that holds a section heading is drawn that long already. */
.reading-ruler { display: none; }

@media (width > 54rem) {
  .reading-ruler {
    display: flex;
    flex-direction: column;
    left: var(--gutter);
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
  }
  .reading-ruler span {
    align-items: center;
    display: flex;
    height: 7px;
    width: var(--ruler-reach, 2rem);   /* as wide as the name above, set by reading-ruler.js */
  }
  .reading-ruler span::before {
    background: var(--ink);
    content: "";
    height: 1px;
    transition: width 0.2s ease;
    width: 0.5rem;
  }
  .reading-ruler span.is-heading::before { width: 0.875rem; }
  .reading-ruler span.here::before { width: 1.25rem; }
  .reading-ruler.is-live span { cursor: pointer; }
  .reading-ruler.is-live span:hover::before { width: 0.875rem; }
  .reading-ruler.is-live span.is-heading:hover::before { width: 1rem; }
  .reading-ruler.is-live span.here:hover::before { width: 1.25rem; }

  /* The title of the section under the pointer, beside the ruler, in the
     margin's width at most. */
  .reading-ruler-label {
    font: 400 0.6875rem/1.2 var(--font-ui);
    left: 2.25rem;
    letter-spacing: 0.02em;
    max-width: calc((100vw - var(--measure)) / 2 - var(--gutter) - 3.25rem);
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    position: absolute;
    text-overflow: ellipsis;
    transform: translateY(-50%);
    transition: opacity 0.15s ease;
    white-space: nowrap;
  }
  .reading-ruler-label.is-showing { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .reading-ruler span::before,
  .reading-ruler-label { transition: none; }
}

/* --- footnotes --------------------------------------------------- */

/* markdown-it-footnote puts a rule ahead of the notes; the notes draw their
   own, so the plugin's is hidden. (The build still splits on it.) */
.footnotes-sep { display: none; }

.footnotes {
  border-top: 1px solid var(--rule);
  font-size: var(--size-notes);
  margin-top: 3rem;
  padding-top: 1rem;
}
.footnotes ol { padding-left: 1.25rem; }
.footnotes p { margin-bottom: 0.5rem; }
.footnote-backref { text-decoration: none; }

sup.footnote-ref a { text-decoration: none; }
sup.footnote-ref a:hover { text-decoration: underline; }

/* --- colophon (the credit block that can close a piece) ----------- */

.colophon {
  font-family: var(--font-ui);
  font-size: var(--size-meta);
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.6;
  text-align: center;
}

/* Lifted from a piece's end to sit under its title (see liftColophon). */
.piece-colophon { margin-top: 0.75rem; }
.piece-colophon .colophon { margin-bottom: 0.5rem; text-align: left; }

/* The mark that closes a piece once its colophon has gone to the top.
   On a wide window (where the year shows) it sits at the very foot of the
   page, centred over the text, so it comes into view only at the end --
   where it lands on the year's baseline. It scrolls with the page, so an
   elastic overscroll carries it along. */
.end-mark {
  font-family: var(--font-ui);
  margin: 2.5rem 0 0;
  text-align: center;
}

@media (width > 54rem) {
  /* The page reaches at least the foot of the window, so a short piece's
     mark still lands level with the year. */
  .page-piece { min-height: 100vh; position: relative; }

  .end-mark {
    bottom: 1rem;                /* set like .piece-year, so they share a baseline */
    font-size: var(--size-nav);
    left: 50%;                   /* the body is the text column */
    line-height: var(--rhythm);
    margin: 0;
    position: absolute;
    transform: translateX(-50%);
  }
}

/* --- attached downloads ------------------------------------------ */

.download {
  font-family: var(--font-ui);
  font-size: var(--size-meta);
  margin-top: 1rem;
}

/* A black triangle hovering over its own soft shadow. On hover it bobs
   toward the ground and back, the shadow tightening and darkening as it
   comes near. The mark is the label's cap height (0.714em in Noto Sans)
   and sits on its baseline, so the triangle's top meets the tops of the
   capitals; the shadow is centred on the baseline itself. */
.download a {
  align-items: baseline;
  display: inline-flex;
  gap: 0.4em;
  text-decoration: none;
}

.download-mark {
  display: inline-block;
  height: 0.714em;
  position: relative;
  width: 0.6em;
}
.download-mark::before,
.download-mark::after {
  content: '';
  left: 0;
  position: absolute;
  right: 0;
}
.download-mark::before {               /* the triangle */
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  height: 0.5em;
  top: 0;
  z-index: 1;
}
.download-mark::after {                /* its shadow on the ground */
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.5), transparent);
  bottom: -0.06em;
  height: 0.12em;
  opacity: 0.55;
}

@keyframes download-drop {
  50% { transform: translateY(0.12em); }
}
@keyframes download-shadow {
  50% { opacity: 1; transform: scaleX(0.7); }
}
.download a:hover .download-mark::before,
.download a:focus-visible .download-mark::before {
  animation: download-drop 900ms ease-in-out infinite;
}
.download a:hover .download-mark::after,
.download a:focus-visible .download-mark::after {
  animation: download-shadow 900ms ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .download a:hover .download-mark::before,
  .download a:hover .download-mark::after,
  .download a:focus-visible .download-mark::before,
  .download a:focus-visible .download-mark::after { animation: none; }
}

.download-size { color: var(--ink); }

/* --- piece subtitle (the lede Medium calls a subtitle) ------------ */

.piece-subtitle {
  font-size: var(--size-h3);
  line-height: 1.45;
  margin-bottom: 0.625rem;
}

/* --- authorial asides:  ##@ like this @##  ------------------------- */

.aside { font-style: italic; }

/* --- HDR, switched off for now ---------------------------------------
   Everything HDR on the homepage -- the paper, the board's rules, the
   lift on the covers -- only applies under an `hdr` class on <html>,
   which nothing sets at the moment. Add it to the template to bring it
   all back.

   Where the screen has HDR headroom the homepage's white is brighter than
   CSS white: an HDR image (tools/make-hdr-white.py, 300 nits) pinned to
   the window. Elsewhere it is tone-mapped to the plain white under it.
   Only here: other pages lay paper-coloured bars over the page, which
   would show as grey against it.
   -------------------------------------------------------------------- */

.hdr body.page-home {
  background: var(--paper) url("/images/hdr-page.png") 0 0 / 100% 100% no-repeat fixed;
  dynamic-range-limit: no-limit;
}

/* --- homepage statement -------------------------------------------- */

/* One line, set like the name in the header (see .site-name). As much
   room below it as above: from the name, that's the header's own 1rem of
   padding, the body's 1.25rem past the header, and this 3rem. */
.statement {
  font-family: var(--font-ui);
  font-size: var(--size-nav);
  font-weight: 600;
  line-height: var(--rhythm);
  margin: 3rem 0 calc(1rem + 1.25rem + 3rem);
  /* Full-bleed like the board, then set in from the window's edge by however
     far the board is (the script measures it), so the two share a left edge. */
  margin-left: calc(50% - 50vw);
  padding: 0 var(--gutter) 0 var(--board-x, var(--gutter));
  width: min(100vw, var(--board-x, var(--gutter)) + 46rem);
}

/* --- writing index: the squares ------------------------------------
   Every piece in a square of its own on a board of ruled lines, its
   cover or a plain sheet with its title floating in the middle. Placed,
   swelled and wiped by static/js/listing.js. Progressive enhancement:
   .stage only exists once the script runs.
   ------------------------------------------------------------------ */

.stage {
  background: transparent;
  contain: layout paint;
  margin: 0 0 0.75rem;
  margin-left: calc(50% - 50vw);
  overflow: hidden;
  position: relative;
  width: 100vw;
}

.stage[hidden] { display: none; }

.doc {
  align-items: flex-start;
  background: #1a1a1a;
  /* A plain rectangle: no shadow, no border, no radius. */
  border: 0;
  color: #f7f6f2;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  justify-content: space-between;
  left: 0;
  padding: 0.5em;
  position: absolute;
  text-decoration: none;
  top: 0;
  container-type: inline-size;      /* so page type can scale with the sheet */
  transform-origin: 50% 50%;
  /* Positioned by script; keep them off-screen until the first paint. */
  transform: translate3d(-9999px, -9999px, 0);
  will-change: transform;
}

.doc-title {
  display: -webkit-box;
  /* Scales with the sheet: cqw is a percentage of the page's own width. */
  font-size: clamp(9px, 7.5cqw, 17px);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 7;
  line-height: 1.3;
  overflow: hidden;
}

.doc-year {
  color: #f7f6f2;
  font-size: clamp(8px, 6cqw, 13px);
  letter-spacing: 0.06em;
}

@media (max-width: 30rem) {
  .doc-title { -webkit-line-clamp: 6; }
}

/* Too small to letter: the page becomes a blank sheet with a tooltip. */
.doc-tiny .doc-title,
.doc-tiny .doc-year { display: none; }

/* Sheets are placed before the first paint; fade the board in so it
   arrives rather than snapping into place. */
.stage .doc,
.board { opacity: 0; }
.stage.is-ready .doc,
.stage.is-ready .board { opacity: 1; transition: opacity 0.3s ease; }

@media (prefers-reduced-motion: reduce) {
  .stage.is-ready .doc,
  .stage.is-ready .board { transition: none; }
}

.board {
  pointer-events: none;
  position: absolute;
}
/* The rules: one element per line, placed and sized by the script. A light
   grey, a shade darker than the page's 3%. */
.board > i {
  background: #dedede;
  left: 0;
  position: absolute;
  top: 0;
  will-change: transform;
}

/* With HDR on, white on the white page, but HDR white: a flat white tagged as PQ
   (tools/make-hdr-white.py), which a screen with HDR headroom lights up
   brighter than any CSS colour can go, so the lines glow out of the paper.
   Without HDR -- another browser, or a screen with no headroom left -- they
   are tone-mapped to plain white and the board is simply not drawn. */
.hdr .board > i {
  background: #fff url("/images/hdr-white.png") 0 0 / 100% 100% no-repeat;
  dynamic-range-limit: no-limit;
}

/* A sheet filtered off the board fades where it stands and can't be hit. */
.stage .doc.is-out { opacity: 0; pointer-events: none; }

/* Mid-wipe the script moves the sheets every frame; nothing may ease
   behind it. A sheet's stand-in leaving a square takes no clicks. */
.stage.is-wiping.is-wiping .doc { transition: none; }   /* over .is-morphing's */
.stage .doc.is-ghost { pointer-events: none; }

/* Filters over the board, spanning it: they start where it does (see
   .statement), and the List/Grid switch ends where it does. */
.square-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-left: calc(50% - 50vw);
  padding: 0 var(--board-x, var(--gutter));
  width: 100vw;
}
/* Types on a line of their own; threads, then the switch, on the next. */
.filter-types { flex-basis: 100%; }
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.view-switch { margin-left: auto; }
/* On the list, only the switch. */
.square-filters.is-list .filter-group:not(.view-switch) { display: none; }
/* The type filters are kept but not shown, for now; only threads are. */
.filter-types { display: none; }

/* A thread's note: a square of text on the board between two pieces.
   Set to the sheet's own width (it's a size container), so it reads the
   same at any size of square. */
.doc.doc-note {
  background: transparent;
  color: var(--ink);
  cursor: default;
  justify-content: flex-start;
  overflow: hidden;
  padding: 0;
}
.doc-note-text {
  font: 300 clamp(11px, 5.6cqw, 17px)/1.45 var(--font-body);
}
.doc-note-intro .doc-note-text { font-size: clamp(12px, 7cqw, 22px); line-height: 1.3; }
.doc-note-text strong { display: block; font: 600 1.35em/1.15 var(--font-head); margin-bottom: 0.5em; }
.doc-note-text a { color: inherit; }
.square-filters button {
  background: none;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  font: 400 0.8125rem/1.5 var(--font-mono);
  letter-spacing: 0.04em;
  padding: 0;
  text-transform: uppercase;
}
.square-filters button:hover { text-decoration: underline; text-underline-offset: 3px; }
.square-filters button[aria-pressed="true"] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The board opening out or collapsing after a filter: the rules, the
   sheets and the board's height all travel. On only for the move. */
.stage.is-morphing { transition: height 0.55s cubic-bezier(0.22, 0.61, 0.36, 1); }
.stage.is-morphing .doc,
.stage.is-morphing .board > i {
  transition: transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
              width 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
              height 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
              opacity 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  .stage.is-morphing,
  .stage.is-morphing .doc,
  .stage.is-morphing .board > i { transition: none; }
}

/* --- PDF covers ------------------------------------------------------
   The first page of the PDF, standing in for the document. The sheet's
   ratio is taken from that same PDF, so the image fills it exactly and
   `cover` never actually crops.
   -------------------------------------------------------------------- */

.doc-cover {
  /* No dark paper behind the image: at a fraction of a pixel its edge is
     blended with whatever is underneath, which showed as a dark halo. */
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

/* Lifted into HDR to sit with the board's glowing rules, which otherwise
   make a white poster read as dull. An HDR white (tools/make-hdr-white.py,
   400 nits) is multiplied over the cover: where the browser blends in HDR
   range that scales the whole image up, whites glowing and colours rising
   with them. Where it doesn't, multiplying by white changes nothing. */
.hdr .doc-cover::after {
  background: url("/images/hdr-cover.png") 0 0 / 100% 100% no-repeat;
  content: "";
  dynamic-range-limit: no-limit;
  inset: 0;
  mix-blend-mode: multiply;
  pointer-events: none;
  position: absolute;
}

/* The cover carries the title already. */
.doc-cover .doc-title,
.doc-cover .doc-year { display: none; }


/* Local preview only: opens the page's Markdown in VS Code (see editLink). */
.edit-link {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  padding: 0.25rem 0.5rem;
  background: var(--paper);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-decoration: none;
}

/* Local preview only: a green dot ahead of the title of each piece whose
   editing pass is done (`edits: complete`). The build adds data-edited only
   when serving locally. */
a[data-edited]::before,
.doc-edited::before {
  background: #1fa34a;
  border-radius: 50%;
  content: "";
  display: inline-block;
  height: 0.6em;
  margin-right: 0.4em;
  vertical-align: 0.05em;
  width: 0.6em;
}
/* On the board the dot sits in the square's corner, since a cover hides
   the title. */
.doc-edited::before {
  left: 0.5em;
  position: absolute;
  top: 0.5em;
  z-index: 1;
}

/* Local preview only: an unfinished piece's `edits:` note, after its title
   in the list. Drawn by CSS, so the board -- which takes its titles from the
   links' text -- never picks it up. */
a[data-edits]::after {
  content: " — " attr(data-edits);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* About: the snapshot at the head of the page, half the column, centred. */
.about-portrait { margin: 0 auto 2rem; width: 50%; }

/* The board: the title of the square under the pointer, in its bottom-left
   corner, in the margin around the sheet (listing.js places it). */
.square-label {
  color: var(--ink);
  font: 400 11px/1.25 var(--font-ui);
  letter-spacing: 0.04em;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  text-overflow: ellipsis;
  text-transform: uppercase;
  transform: translateY(-100%);
  white-space: nowrap;
  z-index: 2;
}
.square-label.is-showing { opacity: 1; }

/* The sun that sets the contact line apart on the about page. */
.sun {
  font-family: var(--font-ui);
  text-align: center;
}
