/* Nick Hakes — Marginalia
   Warm paper. One serif (Spectral). Methylene blue, used only as punctuation. */

@font-face {
  font-family: "Spectral";
  src: url("/assets/fonts/spectral-200.woff2") format("woff2");
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/assets/fonts/spectral-300.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/assets/fonts/spectral-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/assets/fonts/spectral-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/assets/fonts/spectral-300i.woff2") format("woff2");
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/assets/fonts/spectral-400i.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f6f0e3;
  --ink: #1b1a17;
  --mute: #6f685c;
  --rule: #e0d7c6;
  --accent: #2342d6; /* methylene blue */
  --gutter: clamp(20px, 4.2vw, 64px);
  --col-gap: clamp(16px, 2vw, 32px);
  --serif: "Spectral", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --display: var(--serif);
  --w-text: 400;
  --w-name: 500;
  --w-title: 300;
  --w-display: 200;
  --track-display: -0.03em;
  color-scheme: light only;
}
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: var(--w-text);
  font-size: 18px;
  line-height: 1.5;
  font-size-adjust: ex-height 0.47;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: var(--paper); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 1px; }
.stop { color: var(--accent); }

.skip {
  position: absolute; left: var(--gutter); top: 12px;
  padding: 6px 10px; background: var(--ink); color: var(--paper);
  font-size: 15px; transform: translateY(-200%);
}
.skip:focus { transform: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  padding-inline: var(--gutter);
}

/* Display face: the name, titles and headlines. */
.name, .entry a.title, .headline, .article-head h1, .next a { font-family: var(--display); }

/* ---------- Masthead ---------- */
.masthead { padding-top: clamp(28px, 4.5vw, 52px); align-items: baseline; }
.name {
  grid-column: 1 / 6;
  font-size: 21px;
  font-weight: var(--w-name);
  letter-spacing: -0.005em;
  line-height: 1.3;
}
/* The inked full stop: a nib set down once, in methylene blue. */
.ink {
  display: inline-block;
  width: .27em;
  height: .27em;
  margin-left: .045em;
  vertical-align: -.018em;
  fill: var(--accent);
  overflow: visible;
}
.ink path { transform-origin: 50% 50%; transform-box: fill-box; transition: transform .6s var(--ease); }
@media (hover: hover) {
  .name a:hover .ink path, a.name:hover .ink path { transform: scale(1.18) rotate(-8deg); }
}
.portrait {
  grid-column: 1 / 3; grid-row: 3; margin-top: 22px;
  width: 72px; height: 72px; object-fit: cover; border-radius: 50%;
  filter: grayscale(1) contrast(1.05);
}
.elsewhere {
  grid-column: 12 / -1;
  justify-self: end;
  font-size: 16px;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px; background-repeat: no-repeat; background-position: 100% 100%;
  transition: background-size .45s var(--ease), color .3s;
}
.elsewhere:hover { color: var(--accent); background-size: 100% 1px; background-position: 0 100%; }
.masthead .descriptor {
  grid-column: 1 / 6;
  grid-row: 2;
  margin-top: 6px;
  max-width: 21em;
  text-wrap: balance;
  color: var(--mute);
  font-size: 16px;
  line-height: 1.4;
}
.masthead .name, .masthead .elsewhere { grid-row: 1; }


/* ---------- Latest essay: the opening statement ---------- */
.lead { margin-top: clamp(110px, 19vh, 220px); align-items: baseline; }
.lead .kicker { grid-column: 1 / 3; font-size: 15px; color: var(--accent); letter-spacing: .02em; }
.headline {
  grid-column: 3 / 11;
  font-size: clamp(46px, 6.4vw, 98px);
  line-height: 1;
  font-weight: var(--w-display);
  letter-spacing: var(--track-display);
  text-wrap: balance;
}
.headline a { transition: color .45s ease; }
.headline a:hover { color: var(--accent); }
.lead-meta { grid-column: 3 / 9; margin-top: 26px; font-size: 16px; color: var(--mute); }
.lead-summary { grid-column: 3 / 10; margin-top: 4px; font-size: 19px; line-height: 1.4; max-width: 32em; text-wrap: balance; }

/* ---------- Index ---------- */
.index { margin-top: clamp(80px, 13vh, 150px); padding-bottom: 96px; align-content: start; }
.year {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  padding-top: 22px;
  margin-bottom: clamp(48px, 7vh, 88px);
  border-top: 1px solid var(--rule);
}
.year h2 {
  grid-column: 1 / 3;
  grid-row: 1;
  align-self: start;
  position: sticky;
  top: 28px;
  font-size: 15px;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: 0.02em;
  line-height: 1.5;
  padding-top: 6px;
}
.year ol { list-style: none; grid-column: 3 / -1; grid-row: 1; display: grid; grid-template-columns: subgrid; }
.entry {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  padding-bottom: 34px;
}
.entry:last-child { padding-bottom: 0; }
.entry a.title {
  grid-column: 1 / 7;
  justify-self: start;
  font-size: clamp(25px, 2.35vw, 34px);
  line-height: 1.12;
  font-weight: var(--w-title);
  letter-spacing: -0.012em;
  text-wrap: balance;
  transition: opacity .35s ease, color .45s ease;
}
.entry .meta {
  grid-column: 1 / 7;
  margin-top: 8px;
  font-size: 15px;
  color: var(--mute);
  transition: opacity .35s ease;
}
.entry .note {
  grid-column: 8 / -1;
  grid-row: 1 / span 2;
  align-self: start;
  padding-top: .45em;
  font-size: 16px;
  line-height: 1.42;
  color: var(--accent);
  text-wrap: pretty;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .4s ease, transform .5s var(--ease);
  pointer-events: none;
}
.empty { grid-column: 3 / 10; color: var(--mute); font-size: 21px; }

/* The signature: hovering a title isolates it and writes a note in the margin. */
@media (hover: hover) and (pointer: fine) {
  .index:has(.entry a.title:hover) .entry:not(:has(a.title:hover)) a.title,
  .index:has(.entry a.title:focus-visible) .entry:not(:has(a.title:focus-visible)) a.title { opacity: .26; }
  .index:has(.entry a.title:hover) .entry:not(:has(a.title:hover)) .meta,
  .index:has(.entry a.title:focus-visible) .entry:not(:has(a.title:focus-visible)) .meta { opacity: .35; }
  .entry:has(a.title:hover) .note,
  .entry:has(a.title:focus-visible) .note { opacity: 1; transform: none; }
}

/* Where the summary is already visible (narrower screens), hovering a title turns it blue, like the headline. */
@media (max-width: 900px) and (hover: hover) {
  .entry a.title:hover, .entry a.title:focus-visible { color: var(--accent); }
}

/* ---------- Article ---------- */
.article-head { margin-top: clamp(96px, 15vh, 170px); align-items: baseline; }
.article-head .kicker {
  grid-column: 1 / 3;
  font-size: 15px;
  color: var(--mute);
}
.article-head h1 {
  grid-column: 3 / 11;
  font-size: clamp(40px, 5.4vw, 80px);
  line-height: 1.02;
  font-weight: var(--w-display);
  letter-spacing: var(--track-display);
  text-wrap: balance;
}
.article-body { margin-top: clamp(48px, 7vh, 88px); padding-bottom: 88px; }
.article-body .side {
  grid-column: 10 / -1;
  grid-row: 1;
  align-self: start;
  position: sticky;
  top: 32px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--mute);
  padding-top: .35em;
}
.article-body .side p + p { margin-top: 12px; }
.article-body .side a { color: var(--ink); }

.prose {
  grid-column: 3 / 9;
  grid-row: 1;
  font-size: 21px;
  line-height: 1.58;
  hanging-punctuation: first allow-end;
  hyphens: manual;
  text-wrap: pretty;
  overflow-wrap: break-word;
}
.prose > p + p, .prose > ul + p, .prose > ol + p { text-indent: 1.4em; }
.prose h2, .prose h3 {
  font-size: 1em;
  font-weight: 400;
  font-style: italic;
  margin: 1.7em 0 0.35em;
  line-height: 1.4;
}
.prose h2 + p, .prose h3 + p { text-indent: 0; }
.prose blockquote {
  margin: 1.3em 0 1.3em -1.4em;
  padding-left: calc(1.4em - 1px);
  border-left: 1px solid var(--accent);
  font-style: italic;
  font-size: 1.14em;
  line-height: 1.4;
}
.prose blockquote p + p { margin-top: .6em; }
.prose blockquote + p, .prose ul + p, .prose ol + p, .prose figure + p, .prose hr + p { text-indent: 0; }
.prose ul, .prose ol { margin: .8em 0; padding-left: 1.2em; }
.prose li + li { margin-top: .35em; }
.prose ul { list-style: none; }
.prose ul li::before { content: "\2013"; position: absolute; margin-left: -1.2em; color: var(--mute); }
.prose ol li::marker { color: var(--mute); }
.prose a, .side a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  text-decoration-color: var(--rule);
  transition: text-decoration-color .3s, color .3s;
}
.prose a:hover, .side a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.prose em { font-style: italic; }
.prose strong { font-weight: 500; }
.prose hr { border: 0; text-align: center; margin: 1.6em 0; }
.prose hr::after { content: "\2042"; color: var(--mute); }
.prose img { display: block; max-width: 100%; height: auto; margin: 1.6em 0; }
.prose figure { margin: 1.6em 0; }
.prose figcaption { font-size: 15px; color: var(--mute); margin-top: .6em; font-style: italic; }
.prose sup { font-size: .65em; line-height: 0; }
.prose .stop { font-weight: 700; }

.next {
  border-top: 1px solid var(--accent);
  padding-block: 26px 64px;
  align-items: baseline;
}
.next .label { grid-column: 1 / 3; font-size: 15px; color: var(--mute); }
.next a { grid-column: 3 / 10; font-size: 26px; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; transition: color .3s; }
.next a:hover { color: var(--accent); }

/* ---------- 404 ---------- */
.lost { margin-top: clamp(96px, 16vh, 180px); }
.lost p { grid-column: 3 / 10; font-size: clamp(25px, 2.35vw, 34px); line-height: 1.2; font-weight: 380; }
.lost a { color: var(--accent); }

/* ---------- Entrance ---------- */
@media (prefers-reduced-motion: no-preference) {
  .fade { animation: rise .9s var(--ease) both; animation-delay: calc(min(var(--i, 0), 10) * 45ms + 120ms); }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}

/* ---------- Tablet ---------- */
@media (max-width: 900px) {
  .lead .kicker { grid-column: 1 / -1; margin-bottom: 14px; }
  .headline, .lead-meta, .lead-summary { grid-column: 1 / -1; }
  .masthead .descriptor { grid-column: 1 / 9; }
  .entry a.title, .entry .meta { grid-column: 1 / -1; }
  .entry .note {
    grid-column: 1 / -1; grid-row: auto;
    opacity: 1; transform: none; padding-top: 6px;
    font-size: 15.5px; color: var(--mute);
  }
  .article-head h1 { grid-column: 1 / -1; }
  .article-head .kicker { grid-column: 1 / -1; grid-row: 1; padding: 0 0 18px; }
  .prose { grid-column: 1 / -1; grid-row: 2; }
  .article-body .side {
    grid-column: 1 / -1; grid-row: 1; position: static;
    margin-bottom: 40px; padding-bottom: 18px; border-bottom: 1px solid var(--accent);
  }
  .article-body .side p + p { margin-top: 2px; }
  .prose blockquote { margin-left: 0; }
  .empty, .lost p { grid-column: 1 / -1; }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .name { grid-column: 1 / -1; }
  .masthead .descriptor { grid-column: 1 / -1; margin-top: 10px; max-width: 22em; }
  .index { margin-top: 72px; }
  .lead { margin-top: 96px; }
  .headline { font-size: clamp(40px, 11.5vw, 56px); line-height: 1.02; }
  .year h2 { grid-column: 1 / -1; position: static; margin-bottom: 16px; padding-top: 0; }
  .year ol { grid-column: 1 / -1; grid-row: 2; }
  .entry { padding-bottom: 30px; }
  .entry a.title { font-size: 25px; }
  .article-head { margin-top: 88px; }
  .prose { font-size: 19px; line-height: 1.6; }
  .next .label, .next a { grid-column: 1 / -1; }
  .name { grid-column: 1 / 5; }
  .elsewhere { grid-column: 5 / -1; font-size: 15px; }
  .masthead .descriptor { grid-row: 2; }
  .next a { margin-top: 6px; font-size: 23px; }
}

@media print {
  .masthead .descriptor, .elsewhere, .next, .skip { display: none; }
  body { background: #fff; color: #000; }
  .prose { grid-column: 1 / -1; }
}
