/*
  LivingPaper base: the fonts, the reading typography, the page and its running head and folio.
  A printed novel: a single centered column, generous margins, a serif for everything.
  Every value comes from tokens.css.
*/

/* EB Garamond (SIL Open Font License 1.1, see /fonts/OFL.txt), variable weight, served by the application itself:
   no CDN, so the application works offline and no request leaves the machine. */
@font-face {
  font-family: "EB Garamond Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 400 800;
  src: url("../fonts/eb-garamond-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "EB Garamond Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 400 800;
  src: url("../fonts/eb-garamond-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-0151, U+0154-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "EB Garamond Variable";
  font-style: italic;
  font-display: swap;
  font-weight: 400 800;
  src: url("../fonts/eb-garamond-latin-wght-italic.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "EB Garamond Variable";
  font-style: italic;
  font-display: swap;
  font-weight: 400 800;
  src: url("../fonts/eb-garamond-latin-ext-wght-italic.woff2") format("woff2-variations");
  unicode-range: U+0100-0151, U+0154-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- Reset ---- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--color-rule-strong) var(--color-paper);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  font-variant-numeric: oldstyle-nums;   /* figures sit in the line like in a printed novel; data uses lining ones */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  hyphens: auto;                         /* needs the lang attribute of the page: English and French break differently */
  overflow-wrap: break-word;
  accent-color: var(--color-ink);
  caret-color: var(--color-ink);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* The parts of the browser nobody draws still belong to the page. */
::selection {
  background: var(--color-ink);
  color: var(--color-paper);
}

::placeholder {
  color: var(--color-ink-faint);
  opacity: 1;
}

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

/* ---- Page ---- */

.page {
  width: 100%;
  max-width: calc(var(--page-width) + (2 * var(--gutter)));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main {
  flex: 1;
  padding-block-end: var(--space-8);
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  inset-block-start: -6rem;
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  background: var(--color-ink);
  color: var(--color-paper);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus-visible {
  inset-block-start: var(--space-3);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Running head ---- */

/* The heavy line under the running head of a printed page. */
.masthead {
  border-block-end: var(--rule-thick) solid var(--color-ink);
}

.masthead__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  padding-block: var(--space-5) var(--space-4);
}

.masthead__brand {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1;
  color: var(--color-ink);
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  max-width: none;   /* a row of links is not running text: it must not be cut at the reading measure */
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav li + li {
  margin-block-start: 0;   /* the spacing between list items is for running lists, not for a row of links */
}

.nav a {
  display: inline-block;
  padding-block: var(--space-2);
  font-size: 1.0625rem;
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: var(--tracking-caps);
  color: var(--color-ink);
  text-decoration: none;
}

.nav a:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--rule-width);
  text-underline-offset: 0.3em;
}

.nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

/* ---- Folio: the page number at the foot of a printed page ---- */

.folio {
  padding-block: var(--space-6) var(--space-7);
  text-align: center;
  color: var(--color-ink-faint);
  font-size: var(--text-sm);
  font-variant-numeric: lining-nums;
}

/* The paragraph keeps the reading measure (a narrow block): centered as a block, not only its text. */
.folio p {
  margin-inline: auto;
}

/* ---- Reading text ---- */

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 500;
  line-height: var(--leading-tight);
  text-wrap: balance;
  hyphens: manual;
}

h1 {
  margin-block: var(--space-8) var(--space-5);
  font-size: var(--text-display);
  letter-spacing: -0.015em;
}

h2 {
  margin-block: var(--space-8) var(--space-4);   /* more space above a heading than below it */
  font-size: var(--text-xl);
  font-weight: 600;
}

h3 {
  margin-block: var(--space-6) var(--space-3);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-caps: all-small-caps;
  letter-spacing: var(--tracking-caps);
}

h4 {
  margin-block: var(--space-5) var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  font-style: italic;
}

p {
  margin-block: 0 var(--space-4);
  max-width: var(--measure);
  text-wrap: pretty;
}

.lead {
  font-size: var(--text-lg);
  font-style: italic;
  line-height: 1.45;
  color: var(--color-ink-soft);
  hyphens: manual;                       /* three large italic lines: a hyphen at each line end reads badly */
}

/* Running text, set like a novel: the lines that follow the first are indented instead of spaced. */
.prose p {
  margin-block: 0;
}

.prose p + p {
  text-indent: 1.5em;
}

.prose p:last-child {
  margin-block-end: var(--space-4);
}

/* The signature of the book: the opening letter of a text that begins something (a profile, a summary). */
.dropcap::first-letter {
  float: left;
  margin-block: 0.04em -0.02em;
  margin-inline: 0 0.08em;
  font-size: 3.7em;
  font-weight: 500;
  line-height: 0.78;
  font-variant-numeric: lining-nums;
}

a {
  color: var(--color-ink);
  text-decoration: underline;
  text-decoration-thickness: var(--rule-width);
  text-underline-offset: 0.18em;
}

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

em,
i {
  font-style: italic;
}

strong,
b {
  font-weight: 700;
}

small {
  font-size: var(--text-sm);
}

blockquote {
  margin: var(--space-5) 0;
  padding-inline: var(--space-5);
  font-style: italic;
  color: var(--color-ink-soft);
}

blockquote p {
  margin-block-end: var(--space-2);
}

ul,
ol {
  margin-block: 0 var(--space-4);
  padding-inline-start: var(--space-5);
  max-width: var(--measure);
}

li + li {
  margin-block-start: var(--space-1);
}

hr {
  margin-block: var(--space-7);
  border: 0;
  border-block-start: var(--rule-width) solid var(--color-rule);
}

/* The printer's ornament between two parts. Drawn in /img/ornament.svg and painted in the ink color. */
.ornament {
  width: 7.5rem;
  height: 1rem;
  margin-block: var(--space-7);
  margin-inline: auto;
  border: 0;
  background: var(--color-ink-faint);
  -webkit-mask: url("../img/ornament.svg") center / contain no-repeat;
  mask: url("../img/ornament.svg") center / contain no-repeat;
}

/* ---- Small capitals: labels, names, the little words that name a thing ---- */

.caps {
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: var(--tracking-caps);
}

/* Figures that must line up (counts, versions, dates in a list) are lining and tabular, not oldstyle. */
.figures {
  font-variant-numeric: lining-nums tabular-nums;
}

/* ---- No motion for people who ask for none ---- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
