/* THE ANDREW R.C. WYATT COLLECTION — the theme's one stylesheet.
   Linked after the CMS's own sheets (partials/assets.php), and by the
   CMS's own 404 page, so the faces are declared here, not in a sheet of
   their own. */

/* FACES — self-hosted faces (SIL Open Font License 1.1; see fonts/OFL.txt).
   Cormorant Garamond for display and headings, Source Sans Pro for text,
   as the site has always used. Latin and Latin Extended only; the browser
   fetches a file only when a page uses that face and those characters. */

/* Cormorant Garamond 400 500 italic, latin-ext */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url('fonts/cormorant-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Cormorant Garamond 400 500 italic, latin */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400 500;
  font-display: swap;
  src: url('fonts/cormorant-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;
}

/* Cormorant Garamond 400 700 normal, latin-ext */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/cormorant-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Cormorant Garamond 400 700 normal, latin */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/cormorant-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;
}

/* Source Sans Pro 400 italic, latin-ext */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/source-sans-pro-400-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Source Sans Pro 400 italic, latin */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/source-sans-pro-400-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;
}

/* Source Sans Pro 400 normal, latin-ext */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/source-sans-pro-400-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Source Sans Pro 400 normal, latin */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/source-sans-pro-400-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;
}

/* Source Sans Pro 600 normal, latin-ext */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/source-sans-pro-600-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Source Sans Pro 600 normal, latin */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/source-sans-pro-600-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;
}

/* Source Sans Pro 700 normal, latin-ext */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/source-sans-pro-700-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Source Sans Pro 700 normal, latin */
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/source-sans-pro-700-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;
}


/* ════════════════════════════════════════════════════════════════════════════
   TOKENS
   ════════════════════════════════════════════════════════════════════════════
   The collection's own tokens, by the names its first theme gave them; then
   the paint the site has always worn; then the CMS's token vocabulary mapped
   onto both, so every component the CMS draws (a form, a gallery, search, a
   password gate) is drawn in the collection's colours without a rule here. */
:root {
  --yellow: #ffd23f;
  --white:  #f9f9f9;
  --black:  #191514;
  --dark:   #2e2b2b;
  --mid:    #a59e9a;
  --light:  #e2dfdc;
  --primary:   var(--yellow);
  --secondary: var(--mid);

  --paper: #1e1b19;   /* the page */
  --cream: #e8d9c2;   /* type, headings and rules */
  --amber: #ffb53f;   /* links */

  --serif:     'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans: 'Source Sans Pro', Helvetica, Arial, Lucida, sans-serif;

  --bg:            var(--paper);
  --surface:       var(--paper);
  --surface-2:     var(--dark);
  --ink:           var(--cream);
  --ink-2:         #cfc3ae;
  --ink-3:         var(--mid);   /* 6.4:1 on the paper */
  --ink-disabled:  #6b6560;
  --ink-on-strong: var(--black); /* on amber and yellow, dark type reads */
  --border:        #4a443e;
  --border-strong: #6e665e;
  --accent:        var(--amber);
  --accent-strong: var(--yellow);
  --accent-soft:   rgba(255, 181, 63, 0.12);
  --hover:  rgba(232, 217, 194, 0.06);
  --active: rgba(232, 217, 194, 0.10);
  --focus:  rgba(255, 181, 63, 0.65);
  --danger:       #ef8a7a;
  --danger-soft:  rgba(239, 138, 122, 0.14);
  --warning:      #f0b860;
  --warning-soft: rgba(240, 184, 96, 0.14);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  --color-scheme:  dark;
  --picker-invert: 1;
  --surface-hero:  var(--black);
  --ink-hero:      var(--cream);
  --surface-inset: var(--dark);
  --ink-inset:     var(--cream);

  --gutter: clamp(20px, 5vw, 48px);
  --wide:   1080px;   /* the front page's row, and every page's frame */
  --read:   760px;    /* a column of prose, or a letter's page */
}


/* ════════════════════════════════════════════════════════════════════════════
   THE PAGE
   ════════════════════════════════════════════════════════════════════════════ */
html { background: var(--paper); }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--cream);
  background: var(--paper);
  /* The page never scrolls sideways on a phone, even for the moment a
     fallback face is wider than the one it stands in for. `clip`, not
     `hidden`: it makes no scroll box, so the pinned page stays sticky. */
  overflow-x: clip;
}

::selection {
  background-color: var(--primary);
  color: var(--black);
}

.site-main { flex: 1 0 auto; width: 100%; }
/* The front page is its welcome and then the footer, as it always was: the
   welcome is 80% of the window and the footer follows it, not the window's
   foot. */
.site-main--front { flex: 0 0 auto; display: flex; flex-direction: column; }

/* The CMS's own templates in the CMS's reading column, on this paper: their
   headings and titles in the display face, at the sizes this theme's own
   pages use. Figures are lining: Cormorant's old-style "404" reads "4o4". */
.site-content { padding-top: 56px; padding-bottom: 72px; }
.archive-header h1,
.post-header h1,
.post-list__title,
.notfound__code {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.1;
  color: var(--cream);
  font-variant-numeric: lining-nums;
}
.archive-header h1,
.post-header h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); }
.post-list__title { font-size: 1.6rem; }
.post-list__title a { color: var(--cream); }
.post-list__title a:hover { color: var(--amber); }
.notfound__code { font-size: 5rem; color: var(--mid); }

/* Prose, wherever the CMS's text lands: headings in the display face. */
.page-content h2,
.page-content h3,
.page-content h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
}
.page-content h2 { font-size: 2rem; }
.page-content h3 { font-size: 1.6rem; }
.page-content h4 { font-size: 1.3rem; }
.page-content a:hover { color: var(--yellow); }
.page-content blockquote {
  border-left-color: var(--mid);
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--cream);
}


/* ════════════════════════════════════════════════════════════════════════════
   THE FRONT PAGE
   ════════════════════════════════════════════════════════════════════════════
   The welcome as the collection has always opened: a section 80% of the
   window tall, its row (80% wide, at most 1080px) centred in it; the name on
   the left, set right; the words on the right; the double rule between, which
   is each column's own 2px edge with 10px of paper between them. On a phone
   the columns stack, the name set left, and the double rule lies flat. */
.welcome {
  display: flex;
  flex: 1 0 auto;
  min-height: max(80vh, 512px);
  padding: 50px 0;
}

.welcome__row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 80%;
  max-width: var(--wide);
  margin: auto;
  padding: 30px 0;
}

.welcome-left,
.welcome-right {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.welcome-header {
  margin: 0;
  padding: 0.4em 0;
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 500;
  line-height: 1.02;
  text-align: left;
  color: var(--cream);
}

.welcome-prefix,
.welcome-suffix {
  display: block;
  margin: 0.06em 0;
  font-size: clamp(1.25rem, 1.45vw, 1.75rem);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.welcome-suffix { padding-top: 1.25em; }

.welcome-title {
  display: block;
  margin: 0.03em 0;
  /* On a phone, comfortably inside the column (80vw): "R.C. Wyatt", which
     never breaks, is 4.42em, so 16vw leaves a tenth spare for a phone's own
     rendering and for the moment before the face has loaded. */
  font-size: min(4.4rem, 16vw);
  font-weight: 700;
}

/* The words keep 1em under their last paragraph, as they always had: the
   column is centred on the name, so this is what sets their height. */
.welcome-intro { padding-bottom: 1em; color: var(--cream); }

/* What is already in the collection, under the words. */
.welcome-items { margin-top: 12px; }
.welcome-items__label {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream);
}
.welcome-items__list { margin-top: 8px; }
.welcome-items__item + .welcome-items__item { margin-top: 10px; }
.welcome-items__link {
  color: var(--amber);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.welcome-items__link:hover { color: var(--yellow); }
.welcome-items__note {
  display: block;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.welcome-items__more { margin-top: 10px; }
.welcome-items__more a { color: var(--amber); }

@media (max-width: 767.98px) {
  .welcome-left  { border-bottom: 2px solid currentColor; padding-bottom: 1em; }
  .welcome-right { border-top: 2px solid currentColor; padding-top: 1em; }
}

@media (min-width: 768px) {
  .welcome__row { flex-direction: row; }
  .welcome-left,
  .welcome-right { flex: 1 1 0; }
  .welcome-header { text-align: right; }
  .welcome-title  { font-size: clamp(4.4rem, 7vw, 5.5rem); }
  .welcome-left   { border-right: 2px solid currentColor; padding-right: 3em; }
  .welcome-right  { border-left: 2px solid currentColor; padding-left: 3em; }
}

/* Between a tablet and a laptop the columns are narrow for a 70px name: it
   follows the window down instead, so "R.C. Wyatt" stays inside its column. */
@media (min-width: 768px) and (max-width: 1005.98px) {
  .welcome-title { font-size: 7vw; }
}

@media (min-width: 981px) {
  .welcome      { padding: 54px 0; }
  .welcome__row { padding: 27px 0; }
}


/* ════════════════════════════════════════════════════════════════════════════
   THE MASTHEAD — every page but the front
   ════════════════════════════════════════════════════════════════════════════
   The name in its three tiers on one line, over the front page's double rule
   laid flat: two 2px lines, 10px of paper between. */
.masthead { padding-top: 28px; }

.masthead__inner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 32px;
  width: min(var(--wide), 100% - 2 * var(--gutter));
  margin: 0 auto 12px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--cream);
}
.masthead__inner::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  border-bottom: 2px solid var(--cream);
}

.masthead__name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.55em;
  font-family: var(--serif);
  line-height: 1.1;
  color: var(--cream);
}
.masthead__tier {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.masthead__title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
}
.masthead__name:hover .masthead__title { color: var(--white); }

.masthead__nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9375rem;
}
.masthead__nav a,
.masthead__lang { color: var(--cream); }
.masthead__nav a:hover,
.masthead__lang:hover { color: var(--amber); }


/* ════════════════════════════════════════════════════════════════════════════
   THE FOOTER
   ════════════════════════════════════════════════════════════════════════════
   As it always read: centred, in the row's width, the licence in amber. */
.colophon {
  flex-shrink: 0;
  width: 80%;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 46px 0;
  font-size: 16px;
  line-height: 1.7;
  text-align: center;
  color: var(--cream);
}
.colophon a { color: var(--amber); }
.colophon a:hover { color: var(--yellow); text-decoration: underline; text-underline-offset: 3px; }
.colophon__note { margin-top: 4px; font-size: 0.9375rem; color: var(--ink-2); }
.colophon__consent {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--ink-3);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.colophon__consent:hover { color: var(--cream); }
.colophon__menus {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-top: 8px;
  font-size: 0.9375rem;
}

@media (min-width: 981px) {
  .colophon { padding: 43px 0; }
}


/* ════════════════════════════════════════════════════════════════════════════
   A PAGE
   ════════════════════════════════════════════════════════════════════════════ */
.sheet {
  width: min(var(--read), 100% - 2 * var(--gutter));
  margin: 0 auto;
  padding: 64px 0 80px;
}
.sheet__title {
  margin-bottom: 28px;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.05;
  color: var(--cream);
}


/* ════════════════════════════════════════════════════════════════════════════
   A LETTER
   ════════════════════════════════════════════════════════════════════════════
   A title page — its kind, its title, its record, its download — then the
   words about it, then the reader: the typed text a page at a time, with the
   handwriting of the page being read pinned beside it on a wide screen, and
   a thumbnail at each page's label on a phone. Everything opens in the
   lightbox; nothing opens a bare file. */
.letter {
  width: min(var(--wide), 100% - 2 * var(--gutter));
  margin: 0 auto;
  padding: 64px 0 88px;
}

.letter__head { text-align: center; }

/* Cormorant's figures are old-style by default: "PAGE 1" set in capitals
   would read "PAGE ı". Capitals take lining figures. */
.letter__kind,
.letter__fact dt,
.rpage__name,
.viewer__where,
.lightbox__where,
.sheet-of-pages__label,
.welcome-items__label { font-variant-numeric: lining-nums; }

.letter__kind {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mid);
}

.letter__title {
  max-width: 22ch;
  margin: 10px auto 0;
  font-family: var(--serif);
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  font-weight: 700;
  line-height: 1.02;
  color: var(--cream);
  text-wrap: balance;
}

/* The record: each label set right against its value, like a catalogue card. */
.letter__facts {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: 6px 20px;
  max-width: 640px;
  margin: 32px auto 0;
  text-align: left;
}
.letter__fact { display: contents; }
.letter__fact dt {
  padding-top: 3px;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: right;
  color: var(--mid);
}
.letter__fact dd { color: var(--cream); }

/* On a phone a label column would squeeze the values: each label sits over
   its value instead. */
@media (max-width: 559.98px) {
  .letter__facts { grid-template-columns: minmax(0, 1fr); gap: 0; max-width: 420px; }
  .letter__fact dt { padding-top: 0; text-align: left; }
  .letter__fact + .letter__fact dt { margin-top: 10px; }
}

/* The whole letter to keep, at its foot: one button, saying what it is
   before it is pressed. */
.letter__actions {
  margin-top: 64px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.letter__download {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 11px 24px 12px;
  border: 1px solid var(--amber);
  color: var(--amber);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.letter__download-verb { font-weight: 600; }
.letter__download-meta { font-size: 0.8125rem; color: var(--ink-2); }
.letter__download:hover { background: var(--amber); color: var(--black); }
.letter__download:hover .letter__download-meta { color: var(--black); }

.letter__intro {
  max-width: 640px;
  margin: 36px auto 0;
  font-size: 1.0625rem;
}


/* ── The reader ──────────────────────────────────────────────────────────── */
/* --bar-h is the sticky bar's height (letter.js measures it): the pinned page
   sits below it, and a page jumped to lands below it. */
.reader { margin-top: 52px; --bar-h: 58px; }

/* The bar stays at the top while the letter is read: how to read it, and
   where in it the reader is. One line on any screen: the page links on a wide
   one, the page picker on a narrow one. */
.reader__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 28px;
  padding: 10px 0;
  background: var(--paper);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* The switch keeps its size; the picker gives way to it on the narrowest
   phones, rather than pushing the bar past the screen's edge. */
.reader__modes { flex: none; }
.reader__jump { display: block; flex: 0 1 auto; min-width: 0; }
.reader__jump select {
  width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  height: 34px;
  padding: 0 30px 0 10px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--cream);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23e8d9c2' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center / 10px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
}
@media (min-width: 1000px) {
  .reader__jump { display: none; }
}
@media (max-width: 999.98px) {
  .reader.has-jump .reader__index { display: none; }
  .reader__bar { flex-wrap: nowrap; gap: 10px; }
}
@media (max-width: 379.98px) {
  .reader__modes button { padding: 6px 10px; }
  .reader__jump select { padding-right: 26px; background-position: right 9px center; }
}

.reader__modes {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
}
.reader__modes button {
  padding: 6px 14px;
  font-size: 0.875rem;
  color: var(--ink-2);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.reader__modes button + button { border-left: 1px solid var(--border-strong); }
.reader__modes button:hover { color: var(--cream); }
.reader__modes button[aria-pressed="true"] { background: var(--cream); color: var(--black); }

.reader__index ol {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.reader__index a {
  display: inline-block;
  min-width: 2em;
  padding: 2px 6px;
  font-size: 0.9375rem;
  text-align: center;
  color: var(--amber);
  font-variant-numeric: lining-nums tabular-nums;
}
.reader__index a:hover { color: var(--yellow); text-decoration: underline; text-underline-offset: 3px; }
.reader__index a[aria-current="true"] { background: var(--accent-soft); color: var(--yellow); }

.reader__body { margin-top: 40px; }

/* A page of the letter: its label, then his words. */
.rpage {
  /* Arriving from the links or the picker, the label lands below the bar. */
  scroll-margin-top: calc(var(--bar-h) + 16px);
}
.rpage + .rpage {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

.rpage__label {
  margin-bottom: 14px;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mid);
  transition: color var(--t);
}
.rpage.is-current .rpage__label { color: var(--amber); }

/* On a phone, each page's handwriting sits beside its text, the text wrapping
   round it, one tap from the lightbox. */
.rpage__thumb {
  float: right;
  width: 84px;
  margin: 2px 0 10px 18px;
  cursor: zoom-in;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}
.rpage__thumb-img { width: 100%; height: auto; }
.rpage::after { content: ''; display: block; clear: both; }

.rpage__none { font-style: italic; color: var(--ink-3); }

/* His words, set to be read: the display face at a reading size. Lining
   figures: Cormorant's old-style "1st" reads "ıst", and his dates and sums
   ("29-12-42", "Dec 19/42", "$550") should read at a glance. */
.transcript {
  font-family: var(--serif);
  font-size: 1.3125rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--cream);
  font-variant-numeric: lining-nums;
}
.transcript p + p { margin-top: 0.7em; }
.transcript .text-right { text-align: right; }
.transcript .text-center { text-align: center; }

/* Flowing: lines run on, a hyphen that split a word across two lines goes. */
.transcript .ln { display: inline; }
.transcript .hy { display: none; }
/* An address, a date, a signature keep their lines either way. */
.transcript .text-right .ln { display: block; }

/* As written: the page's own lines, numbered every fifth line down the page. */
.reader.is-written .transcript { padding-left: 2.4em; line-height: 1.55; }
.reader.is-written .transcript .ln { display: block; position: relative; }
.reader.is-written .transcript .hy { display: inline; }
.reader.is-written .transcript .ln[data-n$="0"]::before,
.reader.is-written .transcript .ln[data-n$="5"]::before {
  content: attr(data-n);
  position: absolute;
  left: -3.6em;
  width: 2.6em;
  top: 0.55em;
  font-family: var(--font-sans);
  font-size: 0.6em;
  line-height: 1;
  text-align: right;
  color: var(--ink-3);
}
.reader.is-written .transcript ins {
  font-size: 0.85em;
  vertical-align: 0.4em;
  line-height: 0;
}

.transcript del { color: var(--ink-3); text-decoration-thickness: 1px; }
.transcript ins { text-decoration: none; }
.transcript u { text-decoration-thickness: 1px; text-underline-offset: 0.18em; }

/* Our marks, not his: small, quiet and plainly not part of the letter. */
.unsure,
.illegible {
  font-family: var(--font-sans);
  font-size: 0.68em;
  font-style: normal;
  letter-spacing: 0.02em;
  vertical-align: 0.25em;
  color: var(--ink-3);
}
.illegible { font-style: italic; }

/* A word with a note: a fine amber dotted line, its note showing while the
   word is pointed at or focused (letter.js). The cursor stays the text's own. */
.term {
  text-decoration: underline dotted rgba(255, 181, 63, 0.85);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.term:focus { outline: none; }
.term:focus-visible { outline: 1px dotted var(--amber); outline-offset: 2px; }

.reader__key {
  margin-top: 36px;
  font-size: 0.875rem;
  color: var(--ink-3);
}
.reader__key .unsure,
.reader__key .illegible { font-size: 0.8125rem; vertical-align: baseline; }

/* The pinned page: from a wide screen up, beside the text it is the
   handwriting of, the height of the window, turning as the reader scrolls. */
@media (max-width: 999.98px) {
  .reader__view { display: none; }
}
@media (min-width: 1000px) {
  .reader.has-viewer .reader__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 460px;
    gap: 56px;
    align-items: start;
  }
  .reader.has-viewer .rpage__thumb { display: none; }
  .reader__view {
    position: sticky;
    top: calc(var(--bar-h) + 20px);
  }
  /* The last page, at least as tall as its pinned picture (the picture's
     height, as .viewer__img sizes it, from its shape in --end-ratio; 50px
     for the arrows below it; 4px for the 20px it pins at against the 16px a
     page lands at). Else a short last page ends the column, and the picture
     with it, before the page is read: pushed up under the bar, never whole. */
  .reader.has-viewer .rpage:last-child {
    min-height: calc(min(100vh - var(--bar-h) - 124px, 460px * var(--end-ratio, 1.4)) + 54px);
  }
}

.viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.viewer__open {
  display: block;
  cursor: zoom-in;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.viewer__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - var(--bar-h) - 124px);
  transition: opacity 160ms ease;
}
.viewer__img.is-turning { opacity: 0.25; }

.viewer__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.viewer__step,
.viewer__zoom {
  height: 36px;
  border: 1px solid var(--border-strong);
  color: var(--cream);
  transition: border-color var(--t-fast), color var(--t-fast);
}
.viewer__step { width: 36px; font-size: 1.35rem; line-height: 1; }
.viewer__zoom { margin-left: 10px; padding: 0 14px; font-size: 0.875rem; }
.viewer__step:hover:not(:disabled),
.viewer__zoom:hover { border-color: var(--amber); color: var(--amber); }
.viewer__step:disabled { opacity: 0.3; cursor: default; }
.viewer__where {
  min-width: 10.5em;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: var(--mid);
}

@media (prefers-reduced-motion: reduce) {
  .viewer__img { transition: none; }
}


/* ── The notes ───────────────────────────────────────────────────────────── */
/* A note opened from its word: beside the word on a wide screen (letter.js
   places it), rising from the foot of the screen on a phone. */
.note-pop {
  width: min(340px, calc(100vw - 24px));
  margin: 0;
  padding: 14px 18px 16px;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--cream);
  background: #2a2624;
  border: 1px solid var(--border-strong);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}
.note-pop__term {
  margin-bottom: 4px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.25;
}
.note-pop__text { color: var(--ink-2); }

@media (max-width: 699.98px) {
  .note-pop {
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
  }
}


/* ── Before a transcript: the pages as a contact sheet ───────────────────── */
.sheet-of-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 28px 20px;
  margin-top: 52px;
}
.sheet-of-pages__open {
  display: block;
  width: 100%;
  cursor: zoom-in;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}
.sheet-of-pages__open img { width: 100%; height: auto; }
.sheet-of-pages__label {
  display: block;
  margin-top: 10px;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: var(--mid);
}


/* ── The lightbox ────────────────────────────────────────────────────────── */
/* Its box is measured, not declared: letter.js sets its top, left, width and
   height in pixels from what the screen shows (`visualViewport`), and again
   whenever that changes. 100vh and 100dvh can include the strip under a
   phone browser's own bars, which put the page under the address bar and
   the controls below the screen. The 100% here only holds until then. */
html.has-lightbox { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: auto;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  /* Every gesture stays in here: none reaches the page, so the browser's
     bars do not slide while a page is open. */
  touch-action: none;
  overscroll-behavior: contain;
  color: var(--cream);
  background: #100d0c;   /* opaque: the page behind must not ghost through */
}
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: #100d0c; }
.lightbox:focus { outline: none; }

/* The page, drawn whole: its size in pixels is letter.js's (`size()`). */
.lightbox__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.lightbox__img {
  flex: none;
  max-width: none;
  max-height: none;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
}
/* Zoomed: the page scrolls inside the stage, by finger or by drag, and the
   scroll never carries on to the page behind. */
.lightbox__stage.is-zoomed {
  display: block;
  overflow: auto;
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
}
.lightbox__stage.is-zoomed .lightbox__img {
  margin: 16px auto;
  cursor: grab;
}
.lightbox__stage.is-panning .lightbox__img { cursor: grabbing; }

.lightbox__bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(30, 27, 25, 0.94);
  border-top: 1px solid var(--border);
}
.lightbox__btn {
  min-width: 44px;
  height: 40px;
  border: 1px solid var(--border-strong);
  font-size: 1.4rem;
  line-height: 1;
  color: var(--cream);
  transition: border-color var(--t-fast), color var(--t-fast);
}
.lightbox__btn--text { padding: 0 14px; font-size: 0.875rem; }
.lightbox__btn:hover:not(:disabled) { border-color: var(--amber); color: var(--amber); }
.lightbox__btn:disabled { opacity: 0.3; cursor: default; }
.lightbox__btn[aria-pressed="true"] { background: var(--cream); color: var(--black); border-color: var(--cream); }
.lightbox__where {
  min-width: 9.5em;
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: var(--mid);
}
@media (max-width: 479.98px) {
  .lightbox__where { min-width: 0; font-size: 0.8125rem; letter-spacing: 0.08em; }
  .lightbox__bar { gap: 6px; }
}


/* ════════════════════════════════════════════════════════════════════════════
   ON PAPER
   ════════════════════════════════════════════════════════════════════════════
   Printed, the letter is its transcript in ink on white: the pinned page, the
   controls and the thumbnails stay on screen. */
@media print {
  :root { --paper: #fff; --cream: #111; --ink-2: #333; --ink-3: #555; --mid: #555; --amber: #111; --border: #bbb; }
  .skip-link, .reader__bar, .reader__view, .rpage__thumb, .letter__actions,
  .lightbox, .note-pop, .masthead__nav, .colophon__consent { display: none !important; }
  .reader.has-viewer .reader__body { display: block; }
  .rpage { break-inside: avoid-page; }
  .term { text-decoration-color: #777; }
}
