/* EB Garamond (SIL Open Font License, see fonts/OFL.txt), self-hosted.
   One file per script; unicode-range means a browser fetches only what a page uses. */

@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-greek-ext.woff2") format("woff2");
  unicode-range: U+1F00-1FFF;
}

@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: "EB Garamond";
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-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";
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-italic-latin.woff2") format("woff2");
  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";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-greek-ext.woff2") format("woff2");
  unicode-range: U+1F00-1FFF;
}

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-greek.woff2") format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

@font-face {
  font-family: "EB Garamond";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-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";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/eb-garamond-latin.woff2") format("woff2");
  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;
}

/* A manuscript leaf: a text block, a margin for notes beside it, and
   rubric red for the few words a scribe would have marked. */

:root {
  --paper:  #ffffff;
  --ink:    #23201c;
  --soft:   #6b655d;
  --rule:   #e3ded5;
  --rubric: #9a3324;

  --margin: 11rem;   /* the notes column */
  --text:   34rem;   /* the text block */
  --gutter: 2.75rem;
  --gap:    clamp(3.25rem, 2rem + 4vw, 5.5rem);   /* between sections */
  --serif:  "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:  #1b1a18;
    --ink:    #e8e4dc;
    --soft:   #a39c92;
    --rule:   #3a3631;
    --rubric: #d9826b;
  }
}
:root[data-theme="dark"] {
  --paper:  #1b1a18;
  --ink:    #e8e4dc;
  --soft:   #a39c92;
  --rule:   #3a3631;
  --rubric: #d9826b;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.125rem, 1rem + 0.4vw, 1.3125rem);
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
}

p { margin: 0; text-wrap: pretty; }
p + p { margin-top: 1.1rem; }

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: currentColor; }
a:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

::selection { background: color-mix(in srgb, var(--rubric) 18%, transparent); }

/* ---------- the leaf ----------
   Every row shares one grid: notes on the left, text on the right.
   The leaf is centred, so the empty space on a wide screen is even. */

.leaf {
  max-width: calc(var(--margin) + var(--gutter) + var(--text) + 8rem);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) 1.25rem clamp(2.5rem, 6vw, 4.5rem);
}

.row {
  display: grid;
  grid-template-columns: var(--margin) minmax(0, var(--text)) minmax(0, 1fr);
  column-gap: var(--gutter);
  align-items: baseline;
}

.row + .row { margin-top: var(--gap); }

.row > .note { grid-column: 1; text-align: right; }
.row > .body { grid-column: 2; }
.row > .wide { grid-column: 2 / 4; }

/* the voice of the margin: small, italic, a step quieter */
.note {
  font-size: 0.875em;
  line-height: 1.5;
  font-style: italic;
  color: var(--soft);
}

/* rubric: small capitals in red, only for labels */
.rubric {
  font-size: 1em;
  font-style: normal;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.09em;
  color: var(--rubric);
}

/* ---------- masthead ---------- */

.mast { align-items: baseline; }

.wordmark {
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  line-height: 1;
  text-decoration: none;
  font-style: normal;
  color: var(--ink);
}

.mast nav {
  display: flex;
  gap: 1.75rem;
}

.mast nav a {
  text-decoration: none;
  color: var(--soft);
}

.mast nav a:hover,
.mast nav a[aria-current="page"] { color: var(--ink); }

/* ---------- opening ---------- */

.opening { margin-top: clamp(4rem, 3rem + 6vw, 8rem); }

h1 {
  font-size: clamp(2.5rem, 1.4rem + 4.2vw, 4.25rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

/* the gloss sits beside the headline, top-aligned like a marginal note */
.opening { align-items: start; }
.opening .note { padding-top: 0.9rem; }
.grc { font-style: normal; color: var(--ink); }

/* inner pages: same opening, a quieter title */
.opening.inner h1 { font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.25rem); }

/* ---------- work ---------- */

.piece + .piece { margin-top: 2.25rem; }

.piece h3 {
  font-size: inherit;
  font-weight: 500;
  margin: 0 0 0.15rem;
}

/* status rides on the title line, in the margin's voice */
.status {
  margin-left: 0.6rem;
  font-size: 0.875em;
  font-weight: 400;
  font-style: italic;
  color: var(--soft);
}

/* ---------- colophon ---------- */

.colophon {
  margin-top: var(--gap);
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.colophon .body { font-size: 0.875em; color: var(--soft); }

/* ---------- one column ----------
   The margin folds into the text: each note comes first, left-aligned. */

@media (max-width: 52rem) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .row > .note,
  .row > .body,
  .row > .wide { grid-column: 1; text-align: left; }
  .row > .note { margin-bottom: 0.5rem; }

  .mast { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 1.5rem; }
  .mast nav { gap: 1.25rem; }

  /* on a phone the gloss reads after the headline, not before it */
  .opening { display: flex; flex-direction: column-reverse; }
  .opening .note { padding-top: 0; margin: 1.5rem 0 0; }
}
