/* Quiet Stanza — what has been written, given back (Pages/Keepsake.razor): the favourites as a
   commonplace book, and a volume to print. On screen each entry is a sheet of the journal's
   dotted paper lying on the letter paper; printed, each is an A5 page after a title page.

   The pieces are set as text in the hand they were written in (--keep-hand) and a flat ink
   (--keep-ink), not as the procedural ink's canvases: text prints crisp at any resolution in
   Chrome and Safari alike, needs nothing painted first, and stays selectable in a saved PDF.
   A canvas prints only what it last drew at the screen's size, and the twins draw only the
   spreads in view. */

.keep-page { max-width: 980px; }

.keep-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 28px;
}
.keep-sub { margin: 6px 0 0; color: var(--text-secondary); }
.keep-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.keep-actions .btn { text-decoration: none; }
.keep-empty { max-width: 36rem; }

.keep-book {
  display: grid;
  justify-items: center;
  gap: 28px;
}

/* A leaf of the journal: A5 in proportion, its dot grid, a margin each side. */
.keep-sheet {
  box-sizing: border-box;
  width: min(148mm, 100%);
  aspect-ratio: 148 / 210;
  padding: 12mm 11mm 10mm;
  display: flex;
  flex-direction: column;
  background-color: var(--sheet);
  background-image: radial-gradient(circle, rgba(31, 40, 51, .2) .55px, transparent .9px);
  background-size: 5mm 5mm;
  background-position: 2.5mm 2.5mm;
  border: 1px solid var(--sheet-edge);
  border-radius: 2px 6px 6px 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 8px 22px rgba(60, 45, 20, .14);
  color: var(--text-primary);
}

.keep-title-page {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.keep-house {
  margin: 0 0 18mm;
  font-size: 11px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.keep-book-title {
  margin: 0;
  font-family: var(--hand);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
}
.keep-book-volume { margin: 4px 0 0; font-family: var(--serif); font-size: 1.15rem; }
.keep-book-dates { margin: 0; font-family: var(--serif); font-style: italic; color: var(--text-secondary); }
.keep-book-count { margin: 14mm 0 0; font-size: 12px; color: var(--text-secondary); }

/* An entry: the day at the top right, as the journal dates its pages; the title and the lines in
   the sitting's own hand and ink; the writer's notes in the margin's serif; where it lies. */
.keep-entry { --keep-hand: var(--hand); --keep-ink: var(--ink); }
.keep-date {
  margin: 0 0 6mm;
  align-self: flex-end;
  font-family: var(--keep-hand);
  font-size: 12.5px;
  color: var(--keep-ink);
}
.keep-title {
  margin: 0;
  font-family: var(--keep-hand);
  font-size: 19px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--keep-ink);
}
.keep-author {
  margin: 0 0 6mm;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-secondary);
}
.keep-author::before { content: "— "; }
.keep-lines {
  font-family: var(--keep-hand);
  font-size: 14.5px;
  line-height: 2;
  color: var(--keep-ink);
}
.keep-line { margin: 0; overflow-wrap: anywhere; }
.keep-line.is-gap { line-height: 1.2; }
.keep-notes {
  display: block;
  margin-top: 7mm;
  padding-top: 3mm;
  border-top: 1px solid var(--rule-line);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
}
.keep-notes-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.keep-notes-text { white-space: pre-line; }
.keep-where {
  margin-top: auto;
  padding-top: 6mm;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--serif);
  font-size: 12px;
  color: var(--text-secondary);
}
.keep-heart { --journal-ink: var(--favourite); width: 14px; height: 14px; }

@media (max-width: 520px) {
  .keep-sheet { aspect-ratio: auto; min-height: 120vw; padding: 9mm 7mm 8mm; }
}

/* ── printed: A5 pages, the title page first, nothing of the app around them ── */
@media print {
  /* No margin on the page itself, so the browser has no room to print its own header and
     footer (the address and the date); each sheet carries its own, and a long piece running
     onto a second page takes its padding with it (box-decoration-break). */
  @page { size: A5 portrait; margin: 0; }

  html.qs-keeping, html.qs-keeping body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }
  html.qs-keeping body > :not(#app),
  html.qs-keeping #app > :not(.shell),
  html.qs-keeping .shell > :not(main),
  html.qs-keeping main.content > :not(.keep-page),
  html.qs-keeping .keep-head { display: none !important; }
  html.qs-keeping .shell,
  html.qs-keeping main.content {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  html.qs-keeping .keep-page {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    box-shadow: none !important;
  }
  html.qs-keeping .keep-page::before,
  html.qs-keeping .keep-page::after { display: none !important; }

  .keep-book { display: block; }
  .keep-sheet {
    width: 148mm;
    min-height: 0;
    aspect-ratio: auto;
    padding: 15mm 14mm 12mm;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    break-after: page;
    page-break-after: always;
  }
  .keep-sheet:last-child { break-after: auto; page-break-after: auto; }
  /* The title page fills its sheet, its words in the middle (a hair short of the page, so
     rounding never spills it onto a blank second one). */
  .keep-title-page { height: 206mm; break-inside: avoid; }
  /* A stanza is kept together where it can be, and the notes with the last of it. */
  .keep-line { break-inside: avoid; orphans: 2; widows: 2; }
  .keep-notes { break-inside: avoid; }
  /* The ink is the sitting's own: printed as it is, not lightened to save toner. */
  .keep-entry, .keep-heart { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
