/* code poem: a poetry book on a screen. One column, paper and ink, the
   house serif (Centurion, lab/coelacanth) for everything that is not a
   poem, and each poem in the monospaced face its poet chose
   (src/faces.ts, /faces.css). */

@font-face {
  font-family: "Centurion";
  src: url("/static/fonts/Centurion-Roman.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Centurion";
  src: url("/static/fonts/Centurion-Italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f6f2ea;
  --ink: #1f1b16;
  --muted: #6d655a;
  --faint: #d8d0c2;
  --accent: #8a3b2a;
  --caret: #8a3b2a;
  --serif: "Centurion", "Iowan Old Style", Georgia, serif;
  --poem-font: "cp-atkinson";
  /* Readability first on a phone: a full 54-column line scrolls inside its
     poem rather than shrinking every poem to fit it. */
  --poem-size: clamp(0.8rem, 2.35vw, 1rem);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171512;
    --ink: #e9e3d8;
    --muted: #9c9387;
    --faint: #39342d;
    --accent: #e08a6d;
    --caret: #e08a6d;
    color-scheme: dark;
  }
}

* { 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: 1.125rem;
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
}

a { color: inherit; text-decoration-color: var(--faint); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

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

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

.masthead {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 0;
  text-align: center;
}
.mark {
  font-style: italic;
  font-size: 1.6rem;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.masthead nav {
  margin-top: 0.4rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.masthead nav a { margin: 0 0.45rem; text-decoration: none; }
.masthead nav a:hover { color: var(--ink); }

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 6rem;
}

/* ---- poems ----------------------------------------------------------- */

.poem {
  font-family: var(--poem-font), ui-monospace, monospace;
  font-size: var(--poem-size);
  line-height: 1.5;
  tab-size: 2;
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0;
}
pre.poem {
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  padding: 0.25rem 0;
}

.leaf {
  margin: 0 auto 5rem;
  width: fit-content;
  max-width: 100%;
}
.leaf h1, .leaf h2, .byline { overflow: clip; }
.leaf h1, .leaf h2 {
  font-weight: 400;
  font-style: italic;
  font-size: 1.35rem;
  margin: 0 0 1.25rem;
}
.leaf h2 a { text-decoration: none; }
.leaf h2 a:hover { text-decoration: underline; text-decoration-color: var(--faint); }
.leaf + .leaf::before {
  content: "";
  display: block;
  width: 3rem;
  margin: -2.5rem auto 5rem;
  border-top: 1px solid var(--faint);
}

.byline {
  margin: 1.25rem 0 0;
  text-align: right;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}
.byline .lang { color: var(--muted); margin-left: 0.6em; font-style: italic; font-variant: normal; letter-spacing: 0; }
.byline .lang::before { content: "in "; }

.single { margin-top: 2rem; }
.single h1 { font-size: 1.6rem; }

.colophon {
  margin-top: 3rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.colophon p { margin: 0.15rem 0; }
.keeps:empty { display: none; }

/* ---- replay ---------------------------------------------------------- */

.watch { margin: 2rem 0 0; }
.watch button, .player button, .keep button, .withdraw button, .actions button {
  font: inherit;
  font-style: italic;
  color: var(--ink);
  background: none;
  border: 1px solid var(--faint);
  border-radius: 2px;
  padding: 0.15rem 0.8rem;
  cursor: pointer;
}
.watch button:hover, .player button:hover, .keep button:hover, .actions button:hover:enabled { border-color: var(--ink); }
button:disabled { color: var(--muted); cursor: default; }

.player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.player[hidden] { display: none; }
.player .scrub { flex: 1; min-width: 6rem; accent-color: var(--accent); }
.player select { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--faint); }
.clock { font-variant-numeric: tabular-nums lining-nums; min-width: 5.5rem; text-align: right; }

.gap { min-height: 1.5em; margin: 0.4rem 0 0; color: var(--muted); font-style: italic; text-align: center; }

.caret {
  display: inline-block;
  width: 0;
  border-left: 2px solid var(--caret);
  margin-right: -2px;
  height: 1.2em;
  vertical-align: text-bottom;
}
.playing .caret { animation: none; }
.paused .caret { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { border-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .paused .caret { animation: none; } }

.keep { display: inline; }
.keep button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.keep-note { font-style: italic; }
.withdraw { margin-top: 0.6rem; }
.withdraw summary { cursor: pointer; }
.withdraw p { margin: 0.4rem 0; }

/* ---- the desk -------------------------------------------------------- */

.desk { display: flex; flex-direction: column; }
.desk .rule { color: var(--muted); font-style: italic; margin: 0 0 2rem; }

.title {
  font: italic 1.6rem/1.3 var(--serif);
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  width: 100%;
  padding: 0.2rem 0;
  margin-bottom: 1.25rem;
}
.title:focus { outline: none; border-bottom-color: var(--faint); }
.title::placeholder { color: var(--faint); }

/* The sheet is exactly the measure wide: 54 columns of whichever face is
   chosen, plus the textarea's own padding. Longer lines run off the edge
   of the page and the note under it says so. */
.sheet { position: relative; }
textarea.poem {
  display: block;
  width: calc(54ch + 2rem + 2px);
  max-width: 100%;
  min-height: 14em;
  padding: 1rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 70%, white);
  border: 1px solid var(--faint);
  border-radius: 2px;
  resize: none;
  overflow: auto;
  caret-color: var(--caret);
  white-space: pre;
}
@media (prefers-color-scheme: dark) {
  textarea.poem { background: color-mix(in srgb, var(--paper) 85%, white); }
}
textarea.poem:focus { outline: none; border-color: var(--muted); }

.where, .measure-note, .tab-note {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.where { font-variant-numeric: tabular-nums lining-nums; }
.measure-note.over { color: var(--accent); }
.tab-note { font-style: italic; }
.tab-note.released { color: var(--accent); }

.settings { margin: 2rem 0 0; display: grid; gap: 0.75rem; }
.settings label, .settings summary { color: var(--muted); }
.language {
  font: inherit;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px solid var(--faint);
  padding: 0 0.2rem;
  width: 16rem;
  max-width: 60%;
}
.language:focus { outline: none; border-bottom-color: var(--muted); }

.faces summary { cursor: pointer; }
.faces summary .face-name { color: var(--ink); }
.faces fieldset { border: none; padding: 0.75rem 0 0; margin: 0; display: grid; gap: 0.15rem; }
.face-choice { display: flex; align-items: baseline; gap: 0.6rem; cursor: pointer; padding: 0.15rem 0; }
.face-choice .sample, .face-list .sample {
  font-family: var(--poem-font), ui-monospace, monospace;
  color: var(--ink);
  font-size: 0.95rem;
}
.face-choice .by { font-size: 0.85rem; color: var(--muted); font-style: italic; }
.face-choice input { accent-color: var(--accent); }

.sign { margin: 2rem 0 0; }
.grant { margin: 1rem 0 0; display: flex; gap: 0.6rem; align-items: baseline; }
.grant input { accent-color: var(--accent); }
.draft-note { margin: 0.25rem 0 0 1.6rem; font-size: 0.85rem; color: var(--accent); font-style: italic; }
.actions { display: flex; gap: 1rem; margin: 2rem 0 0; }
.actions .over { margin-left: auto; border-color: transparent; color: var(--muted); }
.message { min-height: 1.5em; margin: 1rem 0 0; }
.message.error { color: var(--accent); }
.notice { color: var(--accent); }

/* ---- the rest -------------------------------------------------------- */

.order { text-align: center; color: var(--muted); font-variant: small-caps; letter-spacing: 0.05em; margin: 0 0 3.5rem; }
.order a, .order span { margin: 0 0.5rem; }
.order span { color: var(--ink); }
.order a { text-decoration: none; }

.pages { display: flex; justify-content: space-between; font-style: italic; }
.empty { text-align: center; margin-top: 4rem; font-style: italic; }

.prose { max-width: 34rem; margin: 2rem auto 0; hyphens: auto; }
.prose h1 { font-weight: 400; font-style: italic; font-size: 1.6rem; }
.prose h2 { font-weight: 400; font-variant: small-caps; letter-spacing: 0.05em; font-size: 1.1rem; margin-top: 2.5rem; }
.face-list { list-style: none; padding: 0; }
.face-list li { margin: 0.3rem 0; color: var(--muted); }
.face-list .lic { font-size: 0.85rem; }
