@font-face {
  font-family: "Chomsky";
  src: url("fonts/Chomsky.woff2") format("woff2");
  font-display: block; /* a blank nameplate for an instant beats the page jumping when the font swaps in */
}

:root {
  --paper: #ece3cd;
  --ink: #1f1a14;
  --faded: #6a5f4e;
  --rule: #a3957c;
  --serif: "Old Standard TT", "Times New Roman", serif;
  --display: "Playfair Display", Georgia, serif;
  --nameplate: "Chomsky", "Old English Text MT", serif;
  --bar: 3.5rem;
  --edge: 2.25rem; /* how far the worn edge comes in; everything sits inside it */
  --pad: clamp(1rem, 4vw, 3rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar) + var(--edge)); }

body {
  position: relative; /* the worn edge is drawn round the whole page, not the window */
  margin: 0;
  padding: var(--edge);
  color: var(--ink);
  font: 400 1.2rem/1.45 var(--serif);
  /* Aged newsprint: warm paper, darker toward the edges, with a faint grain */
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(80, 50, 10, 0.18)),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.025) 0 1px, transparent 1px 3px),
    var(--paper);
  background-attachment: fixed;
}

a { color: inherit; }

p, h1, h2, h3, figure { margin: 0; }

/* Small-caps labels: the newspaper furniture */
.menu, .kicker, .when, .facts span, footer, .elsewhere, figcaption {
  font: 700 0.75rem/1.2 var(--serif);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* The site is one sheet: a darkened, worn edge all the way round the page, over everything; it scrolls with the paper */
.edge {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow:
    inset 0 0 clamp(2rem, 6vw, 5rem) rgba(70, 45, 15, 0.45),
    inset 0 0 6px rgba(40, 25, 5, 0.6);
}

.edge::before {
  content: "";
  position: absolute;
  inset: 0.75rem;
  border: 2px solid rgba(70, 45, 15, 0.55);
  filter: url(#rough);
}

/* One bar across the top of the whole paper */
.bar { position: relative; padding: 0 var(--pad); text-align: center; }

/* The ears: small ruled boxes either side of the nameplate, like the ears on an old front page */
.ear {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 15.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ink);
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.3;
}
.ear.cramped { visibility: hidden; } /* pages.js: it would run into the nameplate */
.ear.loading > :not(.label) { visibility: hidden; } /* frame and label from the first paint; the contents when they arrive */
.ear .label { font: 700 0.7rem/1.2 var(--serif); text-transform: uppercase; letter-spacing: 0.14em; color: var(--faded); border-bottom: 1px solid var(--rule); padding-bottom: 0.3rem; margin-bottom: 0.35rem; }

.weather {
  left: var(--pad);
  min-width: 15.5rem;
  width: max-content; /* grows for a long city name */
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 0.75rem;
  align-items: center;
}
.weather .label { grid-column: 1 / -1; }
.weather .icon { grid-column: 2; grid-row: 2; justify-self: center; width: 2.1rem; height: 2.1rem; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.weather .cond { grid-column: 2; grid-row: 3; font-style: italic; font-size: 0.75rem; text-align: center; }

.briefing { right: var(--pad); display: flex; flex-direction: column; } /* pages.js gives it the weather box's height */
.story { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0.2rem; text-decoration: none; min-height: 0; }
.story .headline { font-size: 0.85rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story .summary { font-size: 0.75rem; line-height: 1.3; color: var(--faded); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story:hover .headline { text-decoration: underline; }
.weather .place { font-size: 1.15rem; font-weight: 700; display: flex; gap: 0.5rem; align-items: baseline; white-space: nowrap; }
.weather .city { text-transform: uppercase; letter-spacing: 0.04em; }
.weather .temps { color: var(--faded); font-size: 0.8rem; }

.tagline { font-style: italic; color: var(--faded); margin-top: 0.1em; }
/* Only the nav sticks; the nameplate scrolls away above it */
.menu {
  position: sticky;
  top: var(--edge);
  z-index: 1;
  background: inherit; /* the page's own grain and vignette (fixed to the window), so the bar melts into the paper */
  display: flex;
  justify-content: center;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  margin: 0.75rem var(--pad) 0;
  padding: 0.6rem 0;
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
  font-size: 0.8125rem;
}
.menu a { text-decoration: none; }
.menu a:hover { text-decoration: underline; }
/* While stuck (pages.js sets the class), paper above the nav so nothing scrolls past in the strip between it and the edge */
.menu.stuck::before { content: ""; position: absolute; left: 0; right: 0; bottom: calc(100% + 1px); height: var(--edge); background: inherit; }

/* Every page is exactly one screen under the bar; pages.js scales a page's contents down to fit */
.sheet {
  height: calc(100svh - var(--bar) - 2 * var(--edge));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(0.75rem, 3svh, 2rem) var(--pad);
  container-type: inline-size; /* sizes below use cqi: the page's width, not the window's */
}

.sheet + .sheet { border-top: 3px double var(--rule); }

/* A running head: thin rule, text, thick rule */
.kicker {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 0.4rem 0;
  color: var(--faded);
}

.nameplate {
  display: block;
  font: 400 clamp(2.75rem, min(9vw, 10svh), 6.5rem)/1.05 var(--nameplate);
  letter-spacing: 0.02em;
  padding: 0.1em 0 0;
  text-decoration: none;
}

/* Front page */

.front { height: calc(100svh - var(--head, 0px) - var(--bar) - 2 * var(--edge)); } /* first screen: nameplate + nav + this page, exactly */

.front-story {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(1.5rem, 3cqi, 3rem);
  padding-top: clamp(1rem, 3svh, 2rem);
  max-width: 78rem;
  width: 100%;
  margin: 0 auto;
}

.front h1 {
  font: 900 clamp(2.75rem, min(7.5cqi, 11svh), 6.5rem)/1 var(--display);
  letter-spacing: -0.02em;
}

.deck {
  font-size: clamp(1.2rem, min(2cqi, 3.4svh), 1.75rem);
  line-height: 1.45;
  max-width: 24em;
  margin-top: clamp(1rem, 3svh, 2rem);
  text-align: justify;
  hyphens: auto;
}

/* Drop cap */
.deck::first-letter {
  font: 700 3.1em/0.8 var(--display);
  float: left;
  padding: 0.08em 0.1em 0 0;
}

.facts {
  list-style: none;
  margin: clamp(1.5rem, 4svh, 2.5rem) 0 0;
  padding: 0;
  max-width: 34rem;
  font-size: clamp(1rem, min(1.5cqi, 2.5svh), 1.25rem);
}

.facts li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); align-items: baseline; border-top: 1px dotted var(--rule); padding: 0.7em 0; }
.facts li:last-child { border-bottom: 1px dotted var(--rule); }
.facts span { color: var(--faded); }

.headshot { width: min(40cqi, 41svh); position: relative; }

/* Halftone dots over the photo, like a printed plate */
.headshot::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  aspect-ratio: 4 / 5;
  pointer-events: none;
  background: radial-gradient(circle, rgba(60, 40, 10, 0.28) 0.6px, transparent 1.1px) 0 0 / 3px 3px;
  mix-blend-mode: multiply;
}

.headshot img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 20%;
  /* Muted colour, warmed to match the paper */
  filter: saturate(0.8) contrast(1.05);
  mix-blend-mode: multiply;
  border: 1px solid var(--ink);
  padding: 3px;
}

figcaption { margin-top: 0.5rem; color: var(--faded); text-align: center; letter-spacing: 0.08em; }


/* Inside pages */

.page-body { flex: 1; min-height: 0; width: 100%; max-width: 64rem; margin: 0 auto; overflow: hidden; }
.fit { padding-bottom: 1rem; }

.section-head {
  font: 900 clamp(2.5rem, min(7cqi, 10svh), 4.5rem)/1.05 var(--display);
  text-align: center;
  margin: 0.75rem 0;
  padding-bottom: 0.3em;
  border-bottom: 3px double var(--ink);
}

.entries { list-style: none; margin: 0; padding: 0; }
.entries li { padding: 1rem 0; border-bottom: 1px dotted var(--rule); }
.entries li:last-child { border-bottom: 0; }
.entries li > p:last-child { text-align: justify; hyphens: auto; }

.entry-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1rem;
}

.entries h3 { font: 700 clamp(1.375rem, 2.8cqi, 1.75rem)/1.15 var(--display); }

.gh { display: inline-flex; vertical-align: 0.05em; margin-left: 0.3em; color: var(--faded); }
.gh:hover { color: var(--ink); }
.gh svg { width: 0.7em; height: 0.7em; }
.when { color: var(--faded); }
.role { font-style: italic; color: var(--faded); margin: 0.1rem 0 0.35rem; }
.entries li > p:last-child { margin-top: 0.35rem; }

/* Projects: two columns with a hairline between, like a broadsheet */
@media (min-width: 800px) {
  .columns { columns: 2; column-gap: 3rem; column-rule: 1px solid var(--rule); }
  .columns li { break-inside: avoid; }
}

.notice { margin-top: 1.5rem; font-style: italic; text-align: center; color: var(--faded); }

.email {
  display: block;
  text-align: center;
  margin-top: 0.75rem;
  font: 900 clamp(1.75rem, 5.5cqi, 3.25rem)/1.1 var(--display);
  letter-spacing: -0.01em;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  overflow-wrap: anywhere;
}

.elsewhere { display: flex; justify-content: center; gap: 2rem; margin-top: 1.5rem; }
.elsewhere a { text-underline-offset: 0.25em; }

footer {
  margin-top: 1rem;
  border-top: 3px double var(--ink);
  padding-top: 0.75rem;
  text-align: center;
  color: var(--faded);
}

/* Narrow screens */

@media (max-width: 720px) {
  :root { --bar: 3rem; }
  .menu { gap: 1rem; }
  .tagline { font-size: 1rem; }
  .kicker span:nth-child(3) { display: none; }
  .front-story { grid-template-columns: 1fr; align-content: safe center; gap: 2.5svh; }
  .headshot { order: -1; width: 22svh; justify-self: center; }
  figcaption { display: none; }
  .front h1 { font-size: clamp(2.25rem, min(13cqi, 8svh), 4rem); }
  .deck { font-size: clamp(1.0625rem, min(4.6cqi, 3svh), 1.25rem); margin-top: 2svh; text-align: left; }
  .facts { font-size: clamp(0.9375rem, 2.4svh, 1.0625rem); margin-top: 2svh; }
  .facts li { padding: 0.4em 0; grid-template-columns: 1fr; gap: 0.15rem; }
}

/* Short phones: smaller photo so the headline and facts keep their size */
@media (max-width: 720px) and (max-height: 700px) {
  .headshot { width: 15svh; }
}

/* Phones turned sideways: photo beside the headline again, sized to the short screen */
@media (max-width: 960px) and (max-height: 500px) {
  :root { --bar: 2.75rem; }
  .tagline { display: none; }
  .nameplate { font-size: 7svh; }
  .front-story { grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem; padding-top: 0; }
  .headshot { order: 0; width: 40svh; }
  .front h1 { font-size: 13svh; }
  .deck { font-size: 5svh; }
  .facts { display: none; }
}
