/* Zuhayrium. One paper, one ink, a link blue, and a second ink for dates that say when a
   description was true (as of, account dated, checkpoint). Dates speak in a monospace
   voice; narrative in the serif. The design guidelines are in DESIGN.md. */

/* ---------- Shared ---------- */

:root {
  color-scheme: light;
  --paper: #fbfbf8;
  --paper-deep: #f2f1eb;  /* the latest-update box, a targeted reference */
  --ink: #1c1d1f;
  --ink-soft: #565a60;    /* glosses, edit dates, quiet notes */
  --seen: #9c3b1e;        /* the second ink: observation dates */
  --link: #1f4ea3;
  --rule: #d4d3cc;
  --serif: "Century Schoolbook", C059, "TeX Gyre Schola", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Mono", "DejaVu Sans Mono", monospace;
}

body {
  margin: 0 auto;
  padding: 2.5rem 1.125rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--serif);
  overflow-wrap: break-word;
}

/* Heading sizes are in em so each page type scales them from its own body size. */
h1, h2, h3 {
  line-height: 1.25;
  margin: 2rem 0 0.5rem;
}

/* "Zuhayrium" is about 5.8em wide in this serif. Capping the size at 13vw keeps a one-word
   title whole on a phone with enlarged text instead of breaking it mid-word. */
h1 {
  font-size: min(2.125em, 13vw);
  margin-top: 0;
}

h2 {
  font-size: 1.3em;
  margin-top: 2.75rem;
}

h3 {
  font-size: 1.12em;
}

p, ul, ol, dl, figure {
  margin: 0 0 1rem;
}

img, svg {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

/* Short dates stay on one line in stamps and the dates list; longer dates in headings may wrap. */
.stamp time,
.dates time {
  white-space: nowrap;
}

/* The date voice: monospaced with tabular figures, one format (day month year). */
.stamp,
.period,
.period-link,
.dates dt,
.dates time,
.checkpoint h3 {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums lining-nums;
}

.seen {
  color: var(--seen);
}

.quiet {
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.trail {
  margin-bottom: 2.5rem;
  font-size: 0.9375rem;
}

/* ---------- Record pages: the home page and the writing list ---------- */

/* Dates sit in a margin column left of the words at wide widths and above their entry on
   narrow screens. */
.record {
  --margin: 6.5rem;      /* the date column */
  --gutter: 1rem;
  --measure: 34rem;      /* about 65 characters of the serif at body size */
  max-width: calc(var(--margin) + var(--gutter) + var(--measure));
}

@media (min-width: 48em) {
  .record {
    --margin: 9.5rem;
    --gutter: 1.75rem;
  }

  .column {
    padding-left: calc(var(--margin) + var(--gutter));
  }
}

.routes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  list-style: none;
  padding: 0;
}

.contents {
  margin-top: 2.5rem;
}

.contents h2 {
  font-size: 1.125rem;
  margin-top: 0;
}

.periods,
.periods ul {
  list-style: none;
  padding: 0;
}

.periods > li {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--gutter);
  padding-block: 0.375rem;
  border-top: 1px solid var(--rule);
}

.periods ul {
  flex: 1 1 13rem;
  margin: 0;
}

.period-link {
  flex: 0 0 var(--margin);
  font-size: 0.875rem;
  line-height: 1.85;
}

.period {
  font-size: 1.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--ink);
}

/* Stamps don't repeat their period heading, so a direct link to the first entry of a period
   stops early enough (heading line + padding + rule + margin, about 2.7rem) to keep the
   heading, and with it the year, in view. */
.entry {
  display: grid;
  grid-template-areas: "stamp" "title" "note";
  padding-block: 1.25rem 0.25rem;
  scroll-margin-top: 3rem;
}

.entry + .entry {
  border-top: 1px solid var(--rule);
}

/* Entry titles are h3 under a period heading, or h2 on a page without periods (writing list). */
.entry > :is(h2, h3) {
  grid-area: title;
  margin: 0 0 0.375rem;
  font-size: 1.12em;
}

.entry > .stamp {
  grid-area: stamp;
}

.entry > .note {
  grid-area: note;
}

@media (min-width: 48em) {
  .entry {
    grid-template-columns: var(--margin) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "stamp title" "stamp note";
    column-gap: var(--gutter);
  }

  .entry > .stamp {
    padding-top: 0.25rem;
  }
}

.stamp {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ---------- Article pages: essays and project pages ---------- */

/* At 19px the serif sets about 70 characters across 42rem, so prose, figures and
   apparatus share one column edge. */
.article {
  max-width: 42rem;
  font-size: 1.1875rem;
}

.standfirst {
  font-size: 1.375rem;
  line-height: 1.45;
  margin-bottom: 1.5rem;
}

.dates {
  padding-block: 0.625rem;
  border-block: 1px solid var(--rule);
}

.dates > div {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  align-items: baseline;
  column-gap: 1rem;
  padding-block: 0.25rem;
}

@media (max-width: 30em) {
  .dates > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

.dates dt {
  font-size: 0.875rem;
}

.dates dd {
  margin: 0;
}

.dates time {
  margin-right: 0.5em;
  font-size: 1rem;
  font-weight: 700;
}

.dates a {
  color: inherit;
}

.dates .edited {
  color: var(--ink-soft);
}

.dates .edited time {
  font-weight: 400;
}

.gloss {
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.toc {
  margin-block: 1.75rem;
  font-size: 1.0625rem;
}

.toc-label {
  margin: 0 0 0.25rem;
  font-weight: 700;
}

.toc ul {
  list-style: none;
  padding: 0;
}

/* The newest checkpoint sits above the article, like a dated update on a news story.
   Older checkpoints move, unchanged, to an "Earlier checkpoints" section at the end. */
.update {
  margin-block: 2rem 1rem;
  padding: 1rem 1.25rem 0.125rem;
  border-left: 3px solid var(--seen);
  background: var(--paper-deep);
}

.update-label {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.checkpoint h3 {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.0625rem;
  color: var(--seen);
}

.article figure {
  margin-block: 1.75rem;
}

.article figure img {
  display: block;
  margin-inline: auto;
}

figcaption {
  margin-top: 0.75rem;
  font-size: 1rem;
}

/* References are keyed [1], [2]… from the prose; the hanging indent keeps keys in a column. */
.key {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--ink-soft);
}

a .key {
  color: inherit;
}

.references {
  list-style: none;
  padding: 0;
}

/* The key box (2.5em of its 0.8em text) equals the 2em hanging indent, so wrapped lines
   align with the first line's text. */
.references li {
  padding-left: 2em;
  text-indent: -2em;
}

.references .key {
  display: inline-block;
  width: 2.5em;
  text-indent: 0;
}

.references li:target {
  background: var(--paper-deep);
}

footer {
  margin-top: 3rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--ink);
}
