/* Newsreader (SIL Open Font License, see /assets/fonts/OFL.txt) */
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-roman.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 400 500;
  font-style: italic;
  font-display: swap;
}

/* Colour: rice paper by day, warm charcoal by night */
:root {
  --bg: #f7f5ef;
  --ink: #26241f;
  --soft: #4a463f;
  --muted: #67625a;
  --accent: #3e6b4e;
  --rule: #e2ded3;
  --wash: #efece4;
  --select: rgba(62, 107, 78, 0.16);
  --grain: 0.06;
  --grain-blend: multiply;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a17;
    --ink: #ece9e2;
    --soft: #cbc6bc;
    --muted: #a39f96;
    --accent: #8cc3a0;
    --rule: #33322d;
    --wash: #24241f;
    --select: rgba(140, 195, 160, 0.22);
    --grain: 0.04;
    --grain-blend: screen;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1a17;
  --ink: #ece9e2;
  --soft: #cbc6bc;
  --muted: #a39f96;
  --accent: #8cc3a0;
  --rule: #33322d;
  --wash: #24241f;
  --select: rgba(140, 195, 160, 0.22);
  --grain: 0.04;
  --grain-blend: screen;
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-size: clamp(1.125rem, 1.04rem + 0.36vw, 1.3125rem);
  line-height: 1.6;
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first;
}

/* A whisper of paper grain */
body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--select); }

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* The small dot */
.mark {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* Theme switch */
.theme {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease;
}
.theme[hidden] { display: none; }
.theme:hover { color: var(--ink); }
.theme svg { transition: transform 0.45s ease; }
:root[data-theme="dark"] .theme svg { transform: rotate(180deg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme svg { transform: rotate(180deg); }
}

/* Home and 404 */
.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(7rem, 22vh, 11.5rem) 1.5rem 6rem;
  text-align: center;
}
.name {
  margin: 1.6rem 0 0;
  font-size: clamp(1.8rem, 1.45rem + 1.1vw, 2.15rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.2;
  letter-spacing: 0.005em;
}
.greeting {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9em;
  text-wrap: balance;
}
.years {
  display: flex;
  flex-direction: column;
  gap: clamp(3rem, 7vh, 4rem);
  margin: clamp(3.5rem, 9vh, 5.5rem) 0 0;
}
.year-label {
  margin: 0 0 1.4rem;
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 400;
  letter-spacing: 0.14em;
  font-variant-numeric: lining-nums;
}
.notes {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  max-width: 32rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.notes li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.notes a {
  color: var(--ink);
  line-height: 1.3;
  text-decoration-color: transparent;
  text-wrap: balance;
}
.notes a:hover { color: var(--accent); text-decoration-color: currentColor; }

time {
  color: var(--muted);
  font-size: 0.62em;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-variant-numeric: lining-nums;
}

/* Note */
.masthead {
  display: flex;
  justify-content: center;
  padding: clamp(1.75rem, 5vh, 4.5rem) 1.5rem 0;
}
.home-link {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 44px;
  color: var(--ink);
  font-size: 0.82em;
  font-style: italic;
  text-decoration: none;
}
.home-link .mark { width: 6px; height: 6px; }
.home-link:hover { color: var(--accent); }

.note {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
}
.title {
  margin: clamp(2.5rem, 8vh, 5rem) 0 0;
  font-size: clamp(2.05rem, 1.5rem + 2.1vw, 2.9rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-align: center;
  text-wrap: balance;
}
.date {
  display: block;
  margin: 0.9rem 0 clamp(2.25rem, 6vh, 3.5rem);
  text-align: center;
}
.end {
  margin: 3rem 0 0;
  color: var(--accent);
  font-size: 1.1em;
  line-height: 1;
  letter-spacing: 0.5em;
  text-align: center;
  text-indent: 0.5em;
}

/* Older and newer notes */
.note:has(+ .pager) { padding-bottom: 0; }
.pager {
  display: grid;
  gap: 1.75rem;
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(3rem, 8vh, 4.5rem) 1.5rem 6rem;
  text-align: center;
}
.pager a {
  color: var(--ink);
  font-size: 0.92em;
  line-height: 1.3;
  text-decoration-color: transparent;
  text-wrap: balance;
}
.pager a:hover { color: var(--accent); text-decoration-color: currentColor; }
.pager-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.68em;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
@media (min-width: 36rem) {
  .pager { grid-template-columns: 1fr 1fr; column-gap: 2.5rem; }
  .older { text-align: left; }
  .newer { grid-column: 2; text-align: right; }
}

/* Note body */
.prose > :first-child { margin-top: 0; }
.prose p,
.prose ul,
.prose ol,
.prose dl,
.prose table,
.prose pre,
.prose figure { margin: 0 0 1.15em; }
.prose p { text-wrap: pretty; }
.prose h2,
.prose h3,
.prose h4 {
  margin: 2em 0 0.6em;
  font-weight: 500;
  line-height: 1.3;
  text-wrap: balance;
}
.prose h2 { font-size: 1.25em; }
.prose h3 { font-size: 1.08em; }
.prose h4 { font-size: 1em; font-style: italic; font-weight: 400; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0.35em 0; }
.prose li::marker { color: var(--muted); }
.prose li > ul, .prose li > ol { margin: 0.35em 0 0; }
.prose blockquote {
  margin: 1.8em 0;
  padding: 0 0 0 1.4em;
  color: var(--soft);
  font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose .verse {
  margin: 0.4em 0 1.15em;
  font-size: 1.12em;
  font-style: italic;
  line-height: 1.75;
  text-align: center;
  text-wrap: balance;
}
.prose ol > li::marker { font-variant-numeric: lining-nums; }
.prose ol > li { padding-left: 0.3em; }
.prose hr {
  margin: 2.6em 0;
  border: 0;
  text-align: center;
}
.prose hr::after {
  content: "· · ·";
  color: var(--accent);
  font-size: 1.1em;
  letter-spacing: 0.5em;
  margin-right: -0.5em;
}
.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2em auto;
}
.prose figure img { margin: 0 auto; }
.prose figcaption {
  margin-top: 0.6em;
  color: var(--muted);
  font-size: 0.82em;
  text-align: center;
}
.prose code,
.prose kbd,
.prose pre {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
.prose code {
  padding: 0.12em 0.32em;
  border-radius: 3px;
  background: var(--wash);
  font-size: 0.8em;
}
.prose pre {
  overflow-x: auto;
  padding: 1em 1.2em;
  border-radius: 6px;
  background: var(--wash);
  font-size: 0.78em;
  line-height: 1.55;
}
.prose pre code { padding: 0; background: none; font-size: 1em; }
.prose table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.88em;
  font-variant-numeric: tabular-nums;
}
.prose th, .prose td {
  padding: 0.45em 0.9em 0.45em 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}
.prose th { font-weight: 500; }
.prose sup a, .prose .reversefootnote { text-decoration: none; }
.prose .footnotes {
  margin-top: 3em;
  padding-top: 1.2em;
  border-top: 1px solid var(--rule);
  color: var(--soft);
  font-size: 0.85em;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

@media print {
  :root { --bg: #fff; --ink: #000; --soft: #222; --muted: #444; --accent: #000; }
  body::before, .theme, .end, .pager { display: none; }
  .note { max-width: none; padding-bottom: 0; }
}
