/* Supporter extras (js/support.js, js/book.js): the charities panel, the 支持公益 sheet, the lock under shelf cards, and 人生紀錄冊 with its print style.
   Uses the tokens of css/app.css (light and dark). The book's paper is always light, like real paper. */

/* ================= home: the entry sits in the links row ================= */
.links { flex-wrap: wrap; }
.links button { border: 0; background: none; font: inherit; font-size: 15px; color: var(--muted); padding: 10px 8px; text-decoration: underline; cursor: pointer; }

/* ================= shelf: a book button under a life card ================= */
.life-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.life-cell > .life-card { flex: 1; }
.sp-bk { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.3; text-align: left; }
.sp-bk.lock { background: var(--soft); color: var(--muted); font-size: 13px; }
.sp-bk small { display: block; font-size: 12px; }
.sp-ico { flex: none; }

/* ================= death page ================= */
#dr-sp:empty { display: none; }
.dr-bk { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.dr-bk > div { min-width: 0; }
.dr-bk b { display: block; font-family: var(--serif); font-size: 17px; }
.dr-bk span { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; }
.dr-bk .btn { flex: none; min-height: 44px; }
.dr-bk .btn.sp-lock { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.dr-sp .ph { margin-bottom: 4px; }
.sp-open { margin-top: 10px; }
.dr-bk .sp-open { margin-top: 0; }

.sp-list { list-style: none; margin: 0; padding: 0; }
.sp-item { padding: 12px 0; border-top: 1px solid var(--rule); }
.sp-item:first-child { border-top: 0; }
.sp-name { margin: 0; font-size: 16px; line-height: 1.5; }
.sp-name b { font-family: var(--serif); }
.sp-test { display: block; font-style: normal; font-size: 12px; color: var(--red); }
.sp-short { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.sp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.sp-tags span { font-size: 12px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.sp-act { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 12px; margin-top: 2px; }
.sp-go { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; }
.sp-go::after { content: '\00a0↗'; }
.sp-did-wrap { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.sp-did-wrap .btn { min-height: 40px; }
.sp-fine, .sp-gift { margin: 8px 0 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
.sp-unlocked { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--green); border-radius: 0 8px 8px 0; background: var(--soft); font-size: 15px; line-height: 1.7; }
.sp-unlocked:focus { outline: none; }
.sp-unlocked p { margin: 0; }

/* ================= the 支持公益 sheet ================= */
.sp-sheet .sp-lead { margin: 0 0 10px; font-size: 15px; color: var(--muted); }
.sp-gifts { list-style: none; margin: 0 0 4px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sp-gifts li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 10px 12px; border-top: 1px solid var(--rule); }
.sp-gifts li:first-child { border-top: 0; }
.sp-gifts b { font-family: var(--serif); font-size: 16px; }
.sp-gifts span { grid-column: 1 / -1; font-size: 13px; color: var(--muted); line-height: 1.5; }
.sp-gifts em { font-style: normal; font-size: 12px; color: var(--muted); align-self: center; grid-row: 1; grid-column: 2; }
.sp-gifts li.on em { color: var(--green); font-weight: 700; }
.sp-sheet .sp-gift { margin: 8px 0 12px; }
.sp-sheet .sp-gift.on { color: var(--ink); }
.sp-theme { border-top: 1px solid var(--line); }
.sp-theme summary { padding: 12px 0; font-family: var(--serif); font-size: 17px; font-weight: 700; cursor: pointer; }
.sp-theme summary small { margin-left: 8px; font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--muted); }
.sp-theme[open] summary { padding-bottom: 2px; }
.sp-sheet .btn[data-a="close"] { margin-top: 14px; }

/* ================= 人生紀錄冊 ================= */
.book-modal { padding: 0; align-items: stretch; background: var(--bg); }
.book-modal .sheet.book { max-width: 720px; max-height: none; height: 100%; padding: 0 0 28px; border: 0; border-radius: 0; box-shadow: none; background: var(--bg); }
.bk-tools { position: sticky; top: 0; z-index: 3; display: grid; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--line); background: var(--paper); }
.bk-r1, .bk-r2 { display: flex; align-items: center; gap: 10px; }
.bk-r1 h3 { margin: 0; font-size: 19px; }
.bk-tools .btn.mini { min-height: 42px; }
.bk-r2 .btn { flex: 1; }
.bk-sz { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.bk-sz button { min-height: 40px; padding: 0 14px; border: 0; background: var(--paper); color: var(--ink); font-size: 15px; }
.bk-sz button + button { border-left: 1px solid var(--line); }
.bk-sz button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* the paper: fixed light colours inside, whatever the theme */
.bk { --paper: #fff; --ink: #1b1f23; --muted: #59606a; --line: #cdd2cf; --rule: #e4e7e5; --soft: #eef0ee; --accent: #23395B; --red: #B3382C; --blue: #2D5BA8; --green: #2E7D5B; --hi: #FFF2BF; color-scheme: light;
  margin: 14px 12px 0; background: #fff; color: var(--ink); font-family: var(--serif); font-size: 16px; line-height: 1.85; box-shadow: 0 1px 8px rgba(0, 0, 0, .14); }
.bk > section { padding: 24px 20px; }
.bk-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 68vh; min-height: 68dvh; text-align: center; border-bottom: 1px solid var(--rule); }
.bk-brand { margin: 0; font-size: 13px; letter-spacing: 6px; color: var(--muted); }
.bk-kind { margin: 6px 0 36px; font-size: 15px; letter-spacing: 10px; text-indent: 10px; }
.bk-name { margin: 0; font-size: clamp(36px, 11vw, 52px); font-weight: 700; line-height: 1.3; letter-spacing: 12px; text-indent: 12px; }
.bk-years { margin: 12px 0 0; font-size: 20px; letter-spacing: 3px; }
.bk-age { margin: 2px 0 0; color: var(--muted); }
.bk-title { margin: 24px 0 0; }
.bk-title b { display: inline-block; padding: 2px 14px 3px; border: 2px solid var(--red); border-radius: 3px; color: var(--red); font-size: 19px; transform: rotate(-1.5deg); }
.bk-place { margin: 22px 0 0; font-size: 15px; color: var(--muted); }
.bk-fine { margin: 48px 0 0; font-size: 12px; line-height: 1.8; letter-spacing: 1px; color: var(--muted); }
.bk h4 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1.5px solid var(--ink); font-size: 21px; break-after: avoid; }
.bk h4.bk-h2 { margin-top: 24px; border-bottom: 1px solid var(--line); font-size: 17px; }
.bk h4 small, .bk h5 small { font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--muted); }
.bk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; margin: 0; }
.bk-grid > div { min-width: 0; padding: 7px 0; border-bottom: 1px solid var(--rule); break-inside: avoid; }
.bk-grid dt { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.bk-grid dd { margin: 0; font-size: 16px; line-height: 1.6; }
.bk-dots { color: var(--red); letter-spacing: 2px; }
.bk-story { margin: 8px 0 0; text-indent: 2em; }
.bk-p { margin: 8px 0 0; }
.bk-none { margin: 8px 0 0; color: var(--muted); }
.bk-dec h5 { margin: 22px 0 4px; padding-bottom: 3px; border-bottom: 1px dashed var(--line); font-size: 16px; letter-spacing: 2px; color: var(--green); break-after: avoid; }
.bk-dec h5 small { margin-left: 10px; letter-spacing: 0; }
.bk-yr { display: grid; grid-template-columns: 3.4em minmax(0, 1fr); gap: 0 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); break-inside: avoid; }
.bk-a { text-align: right; line-height: 1.25; }
.bk-a b { font-size: 22px; }
.bk-a small { margin-left: 1px; font-size: 12px; color: var(--muted); }
.bk-a i { display: block; font-family: var(--sans); font-size: 11px; font-style: normal; color: var(--muted); }
.bk-b { min-width: 0; }
.bk-l { margin: 0; font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; }
.bk-l.k-ms { color: var(--green); }
.bk-l.k-big { font-weight: 700; }
.bk-l.k-loss { font-weight: 700; color: var(--red); }
.bk-l.k-loss::after { content: ' †'; }
.bk-l.k-pen { color: var(--blue); }
.bk-l.k-choice { font-size: 13px; color: var(--muted); }
.bk-st { font-style: normal; color: #B8860B; }
.bk-f { margin: 0 0 4px; font-family: var(--sans); font-size: 11.5px; line-height: 1.6; color: var(--muted); }
.bk-f::before { content: '註　'; color: var(--green); }
.bk-notes { margin: 0; }
.bk-notes > div { display: grid; grid-template-columns: 3.4em minmax(0, 1fr); gap: 0 10px; padding: 6px 0; border-bottom: 1px solid var(--rule); break-inside: avoid; }
.bk-notes dt { text-align: right; font-size: 13px; color: var(--muted); }
.bk-notes dd { margin: 0; color: var(--blue); }
.bk-obit { margin: 10px 0 0; }
.bk-obit p { margin: 2px 0; }
.bk-obit .bk-q { color: var(--blue); }
.bk-look { margin: 8px 0; padding-left: 12px; border-left: 2px solid var(--red); color: var(--red); break-inside: avoid; }
.bk .lifemap { max-width: 340px; margin: 6px auto 0; break-inside: avoid; }
.bk-last { margin: 28px 0 0; text-align: center; color: var(--muted); }

/* ================= printing: only the book, on A5 or A4 pages ================= */
@page { @bottom-center { content: counter(page); font: 9pt sans-serif; color: #777; } }
@page :first { @bottom-center { content: none; } }
@media print {
  html, body { height: auto !important; min-height: 0 !important; overflow: visible !important; background: #fff !important; }
  body > *:not(.book-modal) { display: none !important; }
  .book-modal { position: static !important; display: block !important; padding: 0 !important; overflow: visible !important; background: #fff !important; animation: none !important; }
  .book-modal .sheet.book { position: static; display: block; width: auto; max-width: none; height: auto; max-height: none; padding: 0; overflow: visible; background: #fff; animation: none; }
  .bk-tools { display: none !important; }
  .bk { margin: 0; box-shadow: none; font-size: 10.5pt; line-height: 1.75; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bk > section { padding: 0; }
  .bk-cover { min-height: 160mm; border: 0; break-after: page; }
  .book-modal[data-paper="A4"] .bk-cover { min-height: 232mm; }
  .bk-end { break-before: page; }
  .bk-log { margin-top: 8mm; }
  .bk-l { font-size: 10pt; }
  .bk-f { font-size: 8pt; }
  .bk-name { font-size: 40pt; }
}
