/* ------------------------------------------------------------------ fonts */
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('fonts/AtkinsonHyperlegible-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('fonts/AtkinsonHyperlegible-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Young Serif';
  src: url('fonts/YoungSerif-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

/* ------------------------------------------------------------------- base */
/* 1440 is the design width. Everything below is expressed in px at that
   width and scales linearly, so the browser matches the mock at any size. */
:root {
  --bg: #171421;
  --snow: #FFFFFF;
  --m: 72;            /* page margin, in design px */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  position: relative;
  margin: 0;
  background: var(--bg);
  color: var(--snow);
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: calc(20 / 1440 * 100vw);
  line-height: 1.6;
  /* room for the drift + nav, which are fixed over the content */
  padding-bottom: calc(250 / 1440 * 100vw);
  /* the mock's minimum page height, so a short page still clears the drift */
  min-height: calc(1040 / 1440 * 100vw);
  overflow-x: hidden;
}

main {
  padding: calc(150 / 1440 * 100vw) calc(var(--m) / 1440 * 100vw) 0;
  max-width: 100%;
}

p, h1, ul { margin: 0; }

/* ------------------------------------------------------------------- type */
/* One role = one size, weight and colour. A block picks a role, never a size. */
.heading {
  font-family: 'Young Serif', Georgia, serif;
  font-weight: 400;
  font-size: calc(76 / 1440 * 100vw);
  line-height: 1.14;
  letter-spacing: 0;
  color: var(--snow);
}
.headline {
  font-size: calc(46 / 1440 * 100vw);
  line-height: 1.2;
  letter-spacing: -0.006em;
  color: var(--snow);
  margin-top: calc(32 / 1440 * 100vw);
}
.category {
  font-size: calc(34 / 1440 * 100vw);
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.88);
  margin-top: calc(14 / 1440 * 100vw);
}
.subhead {
  font-size: calc(26 / 1440 * 100vw);
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.78);
  margin-top: calc(16 / 1440 * 100vw);
}
.entry {
  font-size: calc(26 / 1440 * 100vw);
  line-height: 1.3;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}
.lede {
  font-size: calc(24 / 1440 * 100vw);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.89);
  margin-top: calc(13 / 1440 * 100vw);
}
.body {
  font-size: calc(20 / 1440 * 100vw);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
  margin-top: calc(20 / 1440 * 100vw);
}
.meta {
  font-size: calc(18 / 1440 * 100vw);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.55);
  margin-top: calc(20 / 1440 * 100vw);
}

/* Block measure. Authored in design px at 1440 (`--w`), converted here so a
   block keeps its line length at every viewport instead of only at 1440.
   Falls back to the full column when a block declares no width. */
.heading, .headline, .category, .subhead, .entry, .lede, .body, .meta {
  text-wrap: pretty;
  max-width: calc(var(--w, 9999) / 1440 * 100vw);
}

/* ------------------------------------------------------------------ rules */
.rule {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.125);
  margin: calc(24 / 1440 * 100vw) 0 0;
  width: 100%;
}

.space { width: 100%; }

/* ---------------------------------------------------------------- entries */
.entries { list-style: none; padding: 0; }
.entries li {
  display: grid;
  grid-template-columns: calc(828 / 1440 * 100vw) 1fr;
  align-items: baseline;
  gap: 0;
  padding: calc(16 / 1440 * 100vw) 0;
  border-top: 1px solid rgba(255, 255, 255, 0.125);
}
.entries li:first-child { border-top: 0; }
.entries .meta { margin: 0; }
.more { color: rgba(255, 255, 255, 0.63); }

/* -------------------------------------------------------------------- log */
.log { list-style: none; padding: 0; }
.log li {
  display: flex;
  gap: calc(48 / 1440 * 100vw);
  padding: calc(24 / 1440 * 100vw) 0;
  border-top: 1px solid rgba(255, 255, 255, 0.133);
}
.log li:first-child { border-top: 0; }
.log .date {
  flex: 0 0 calc(200 / 1440 * 100vw);
  margin: 0;
  color: rgba(255, 255, 255, 0.63);
  padding-top: calc(6 / 1440 * 100vw);
}
.logbody { flex: 1 1 auto; max-width: calc(820 / 1440 * 100vw); }
.logbody .entry { color: rgba(255, 255, 255, 0.86); }
.logbody .body { margin-top: calc(16 / 1440 * 100vw); }

/* ---------------------------------------------------------------- columns */
.columns {
  display: flex;
  gap: calc(40 / 1440 * 100vw);
  margin-top: calc(32 / 1440 * 100vw);
}
.columns .col { flex: 1 1 0; min-width: 0; }
.columns .col > *:first-child { margin-top: 0; }

/* ------------------------------------------------------------------- mark */
/* Once per page, behind everything, bleeding off an edge by design. */
/* The mark bleeds off the page by design, so it has to be clipped or it
   stretches the scroll height. The wrapper is the page box; the glyph lives
   outside it and gets cut. */
.markwrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
/* Opt-in (page JSON: mark.fixed = true): the mark is pinned to the viewport and
   content scrolls over it. The wrapper becomes the viewport, so overflow:hidden
   still does the clipping. Note: `mark.x` / `mark.y` then mean position from the
   viewport corner, not the document corner. */
.markwrap.is-fixed {
  position: fixed;
  inset: 0;
}
/* The glyph itself stays absolute inside the wrapper, so the wrapper's
   overflow:hidden still clips the bleed. Do not make the glyph fixed — a
   fixed child escapes its parent's overflow clip. */
.mark {
  position: absolute;
  font-family: 'DejaVu Sans', sans-serif;
  font-weight: 700;
  line-height: 0.78;
  pointer-events: none;
  user-select: none;
  white-space: pre;
}
main { position: relative; z-index: 1; }

/* ------------------------------------------------------------------ drift */
/* Fixed to the viewport foot. Content scrolls *under* it — that's the design,
   not a bug. The nav sits on the snow, so it takes the page colour. */
#foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(200 / 1440 * 100vw);
  pointer-events: none;
  z-index: 10;
}
#foot .drift {
  display: block;
  width: calc(1483 / 1440 * 100vw);
  height: calc(200 / 1440 * 100vw);
  margin-left: calc(-19.5 / 1440 * 100vw);
}
#foot .line { fill: #FFFFFF; }
#foot .band { fill: var(--bg); fill-opacity: 0.08; }

#foot nav {
  position: absolute;
  left: calc(72 / 1440 * 100vw);
  bottom: calc(74 / 1440 * 100vw);
  display: flex;
  gap: calc(10 / 1440 * 100vw);
  font-size: calc(22 / 1440 * 100vw);
  line-height: 1.2;
  color: var(--bg);
  pointer-events: auto;
}
#foot nav a {
  color: var(--bg);
  text-decoration: none;
}
/* hover: plucked string. A fast horizontal shiver, no scale, no reflow.
   The link thickens with text-stroke rather than font-weight — Bold would
   change the glyph advance and shove the neighbouring links sideways
   (measured: +8.97px on every following link). */
#foot nav a:hover {
  animation: pluck 220ms ease-in-out infinite;
  -webkit-text-stroke: 0.55px currentColor;
  text-stroke: 0.55px currentColor;
}
@keyframes pluck {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-1.5px); }
  40%  { transform: translateX(1.5px); }
  60%  { transform: translateX(-1px); }
  80%  { transform: translateX(0.8px); }
  100% { transform: translateX(0); }
}
/* damping: the shake softens out rather than looping forever at full tilt */
@media (prefers-reduced-motion: reduce) {
  #foot nav a:hover {
    animation: none;
    -webkit-text-stroke: 0.55px currentColor;
    text-stroke: 0.55px currentColor;
  }
}
#foot nav a + a::before {
  content: '·';
  margin-right: calc(10 / 1440 * 100vw);
  opacity: 0.55;
}

/* ------------------------------------------------------------------- hero */
/* The front door. A block, not a special case: it takes a screen and centres
   what it is given, so the same block works in flow on any other page.
   Height = viewport minus what is already taken: main's top padding and the
   fixed drift at the foot. Nothing is hard-coded twice — the two numbers here
   are the same two the page itself uses. */
.hero {
  min-height: calc(100vh - 350 / 1440 * 100vw);
  display: flex;
  align-items: center;
}
/* Rotation: every nugget is in the HTML, CSS shows only the first. JS may move
   the .on to another one; with JS off the newest stays up. */
.hero .nug { display: none; width: 100%; }
.hero .nug.on { display: block; }

.hero .nugget,
.nuggets .nugget {
  font-size: calc(76 / 1440 * 100vw);
  line-height: 1.16;
  letter-spacing: -0.018em;
  color: var(--snow);
  text-wrap: pretty;
  max-width: calc(1160 / 1440 * 100vw);
}
.hero .nugget { margin: 0 auto; }

/* The date is the quiet line under it, and nothing else. */
.nugdate {
  margin-top: calc(28 / 1440 * 100vw);
  max-width: calc(1040 / 1440 * 100vw);
}
.hero .nugdate { margin-left: auto; margin-right: auto; }

/* --------------------------------------------------------------- archive */
.nuggets { list-style: none; padding: 0; }
.nuggets li {
  padding: calc(32 / 1440 * 100vw) 0;
  border-top: 1px solid rgba(255, 255, 255, 0.125);
}
.nuggets li:first-child { border-top: 0; padding-top: 0; }
.nuggets .nugdate { margin: 0 0 calc(10 / 1440 * 100vw); }
.nuggets .nugget { font-size: calc(40 / 1440 * 100vw); line-height: 1.32; letter-spacing: -0.008em; }

/* --------------------------------------------------------------- narrow */
/* Below the design width the type stops shrinking and the layout reflows.
   Legibility floor: 18px, no matter what. */
@media (max-width: 900px) {
  body {
    font-size: 18px;
    padding-bottom: 190px;
  }
  main { padding: 100px 28px 0; }
  .heading { font-size: 44px; }
  .headline { font-size: 30px; margin-top: 20px; }
  .category { font-size: 26px; }
  .subhead { font-size: 22px; }
  .entry { font-size: 22px; }
  .lede { font-size: 21px; }
  .body { font-size: 19px; }
  .meta { font-size: 18px; }
  .columns { flex-direction: column; gap: 32px; }
  .columns .col { flex: 1 1 auto; min-width: 0; }

  /* The type below 900px is no longer a fraction of 1440, so a vw-derived
     measure would be wrong too. Pin the boxes to the design measure at the
     floor size, which holds the same character count. */
  .heading, .headline, .category, .subhead, .entry, .lede, .body, .meta {
    max-width: calc(var(--w, 9999) * 1px);
  }
  .entries li { grid-template-columns: 1fr; gap: 4px; }
  .entries .meta { margin: 0; }
  .log { }
  .log li { flex-direction: column; gap: 6px; }
  .log .date { flex: 0 0 auto; padding-top: 0; }
  #foot { height: 140px; }
  #foot .drift { width: 100%; height: 140px; margin-left: 0; }
  #foot nav { left: 28px; bottom: 26px; font-size: 18px; gap: 6px; }
  #foot nav a + a::before { margin-right: 6px; }
  /* hero: the same screen-filling idea at the floor size */
  .hero { min-height: calc(100vh - 240px); }
  .hero .nugget { font-size: 34px; line-height: 1.22; max-width: none; }
  .hero .nugdate { margin-top: 18px; max-width: none; }
  .nuggets li { padding: 26px 0; }
  .nuggets .nugget { font-size: 25px; line-height: 1.32; max-width: none; }
  .markwrap { display: none; }
}
