/* WO-D: book page extras + chapter reader preferences. Loaded on book and chapter pages. */

/* sepia: a full palette, wins over the OS dark palette (same specificity, loaded later) */
:root[data-theme="sepia"] {
  --page: #E8DDC6; --panel: #F7F0DF; --line: #E6DAC0; --line-strong: #D3C3A2;
  --ink: #3A2E1F; --muted: #6E5E48; --soft: #8D7C63;
  --menu: #4B3C2B; --menu-ink: #E7DCC6; --menu-hover: #5B4A36; --menu-input: #3D3123;
  --red: #B04A3C; --red-hover: #963B2F; --red-soft: #A9533F;
  --link: #8A4B1F; --link-hover: #6A3714;
  --tag-bg: #EADCBF; --tag-ink: #3A2E1F; --ai: #2F6A5E; --ai-bg: #DDE5CF;
  --top: #F7F0DF; --foot: #4B3C2B; --foot-ink: #CDBFA5; --focus: rgb(138 75 31 / 40%);
  color-scheme: light;
}
:root[data-rfont="sans"] { --f-read: "Open Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
:root[data-rw="0"] .ms { max-width: 58ch; }
:root[data-rw="2"] .ms { max-width: 92ch; }

/* reader preferences panel (hidden without JS: it needs JS to do anything) */
.prefs { display: none; margin: 12px auto 18px; max-width: 72ch; border: 1px solid var(--line-strong); background: var(--panel); font: 400 13px/1.4 var(--f-ui); }
.js .prefs { display: block; }
.prefs summary { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 9px 12px; font-weight: 600; color: var(--muted); list-style: none; user-select: none; }
.prefs summary::-webkit-details-marker { display: none; }
.prefs summary::after { content: "▾"; margin-left: auto; font-size: 11px; }
.prefs[open] summary::after { content: "▴"; }
.prefs summary:hover { color: var(--ink); }
.prefs[open] summary { border-bottom: 1px solid var(--line); }
.prefs-body { display: grid; gap: 10px; padding: 12px; }
.pref { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pref-l { width: 58px; flex: none; font-weight: 700; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pref button { font: 600 13px/1 var(--f-ui); color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); min-height: 34px; padding: 0 12px; cursor: pointer; }
.pref button:hover { background: var(--page); }
.pref button[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.pref .f-serif { font-family: "Lora", Georgia, serif; }
.pref .s0 { font-size: 11px; } .pref .s1 { font-size: 13px; } .pref .s2 { font-size: 15px; } .pref .s3 { font-size: 17px; } .pref .s4 { font-size: 19px; }
.pref .s0, .pref .s1, .pref .s2, .pref .s3, .pref .s4 { width: 38px; padding: 0; font-family: "Lora", Georgia, serif; }
.pref .t-light:not([aria-pressed="true"]) { background: #FFFFFF; color: #333; }
.pref .t-dark:not([aria-pressed="true"]) { background: #1F2328; color: #DDE2E7; border-color: #3A4149; }
.pref .t-sepia:not([aria-pressed="true"]) { background: #F7F0DF; color: #3A2E1F; border-color: #D3C3A2; }

/* chapter page bits */
.ch-header-row { grid-template-columns: 60px minmax(0, 1fr) auto; }
.fic-page-btn { align-self: center; }
.ch-report { max-width: 72ch; margin: 18px auto 0; text-align: right; font-size: 12.5px; }
.ch-report a { color: var(--muted); }
.kbd-hint { justify-content: center; width: 100%; font-size: 12px; color: var(--soft); margin: 4px 0 0; }
.kbd-hint kbd { font: 600 11px var(--f-ui); border: 1px solid var(--line-strong); border-bottom-width: 2px; padding: 1px 5px; margin: 0 3px; background: var(--page); }
@media (hover: none) { .js .kbd-hint { display: none !important; } }

/* book page: RSS link, Others also liked, author's other books */
.toc-meta { display: inline-flex; align-items: center; gap: 12px; }
.rss-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: #E0782B; border: 1px solid currentColor; padding: 3px 7px; }
.rss-link:hover { color: #C4621C; text-decoration: none; }
.also-row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.also-row li { min-width: 0; }
.also-card { display: block; color: var(--ink); }
.also-card:hover { text-decoration: none; color: var(--red); }
.also-cover .cover { transition: transform .15s; }
.also-card:hover .cover { transform: translateY(-2px); }
.also-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font: 700 13px/1.3 var(--f-ui); margin-top: 7px; }
.also-genre { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.ab-more { font: 700 12px/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.ab-books { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.ab-books li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; align-items: center; }
.ab-books li a:not(.ab-thumb) { font-weight: 600; font-size: 13.5px; line-height: 1.3; display: block; }
.ab-books .muted { font-size: 12px; }
.ab-thumb .cover.typo { padding: 4px; }
.ab-thumb .c-orn, .ab-thumb .c-author, .also-cover .c-author { display: none; }
.ab-all { display: inline-block; }

@media (max-width: 991px) {
  .also-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 639px) {
  .also-row { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 38%; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
  .also-row li { scroll-snap-align: start; }
  .ch-header-row { grid-template-columns: 44px minmax(0, 1fr); }
  .fic-page-btn { grid-column: 1 / -1; justify-self: start; padding: 8px 12px; font-size: 13px; }
  .pref-l { width: 100%; }
  .toc-meta .muted { display: none; }
}
