/* 找碴人生 · 書頁風格 */
:root {
  --desk: #e9e1d1;
  --paper: #fbf7ee;
  --ink: #2f2a23;
  --muted: #877c6b;
  --line: #ddd2bd;
  --accent: #a3402a;      /* 朱砂紅，像印章 */
  --accent-soft: #f1ddd3;
  --shadow: 0 1px 2px rgba(60, 45, 20, .08), 0 8px 30px rgba(60, 45, 20, .10);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", "MingLiU", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #171512; --paper: #221f1a; --ink: #e8e1d2; --muted: #9d927f;
    --line: #3a352c; --accent: #e07a5f; --accent-soft: #3b2a24;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 30px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0; background: var(--desk); color: var(--ink);
  font-family: var(--serif); line-height: 1.95; letter-spacing: .02em;
  -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .2em; }
[hidden] { display: none !important; }

/* ---------- 書名頁頁首 ---------- */
.masthead { text-align: center; padding: 2.6rem 1rem 1.5rem; }
.brand { display: inline-block; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-name { display: inline-flex; align-items: center; gap: .6rem; font-size: 2.4rem; font-weight: 900; letter-spacing: .3em; padding-left: .3em; line-height: 1.3; }
.seal {
  display: inline-flex; flex-direction: column; align-items: center;
  font-size: .78rem; font-weight: 900; letter-spacing: 0; line-height: 1.15;
  color: var(--accent); border: 2px solid var(--accent); border-radius: 4px;
  padding: .25rem .3rem; transform: rotate(-6deg); opacity: .9;
}
.toc-nav { margin-top: 1.2rem; display: flex; justify-content: center; flex-wrap: wrap; gap: .2rem 0; font-size: .95rem; }
.toc-nav a { color: var(--ink); padding: 0 1rem; position: relative; }
.toc-nav a + a::before { content: "·"; position: absolute; left: -.2rem; color: var(--muted); }
.toc-nav a[aria-current] { color: var(--accent); }

main { padding: 0 1rem 2rem; }

/* ---------- 紙張 ---------- */
.sheet, .leaf { background: var(--paper); box-shadow: var(--shadow); border-radius: 2px; }
.sheet { max-width: 46rem; margin: 0 auto; padding: 3.5rem 4rem 3rem; }

/* 首頁：攤開的兩頁 */
.spread { max-width: 70rem; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; }
.leaf { padding: 3rem 3.2rem; }
.leaf-left { border-right: 1px solid var(--line); box-shadow: var(--shadow), inset -18px 0 24px -20px rgba(60,45,20,.18); }
.leaf-right { box-shadow: var(--shadow), inset 18px 0 24px -20px rgba(60,45,20,.18); }
.leaf-title { font-size: .85rem; letter-spacing: .6em; color: var(--muted); text-align: center; margin: 0 0 2rem; font-weight: 600; }

.contents { list-style: none; margin: 0; padding: 0; }
.contents li { margin-bottom: 1.4rem; }
.contents a { display: flex; align-items: baseline; gap: .6rem; color: var(--ink); }
.contents a:hover { text-decoration: none; color: var(--accent); }
.ch-no { font-size: .8rem; color: var(--muted); letter-spacing: .15em; }
.ch-name { font-size: 1.35rem; font-weight: 600; }
.ch-count { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.leader { flex: 1; border-bottom: 1px dotted var(--muted); transform: translateY(-.35em); opacity: .7; min-width: 1rem; }
.contents p { margin: .1rem 0 0; font-size: .85rem; color: var(--muted); line-height: 1.7; }

.preface { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.preface h3 { font-size: 1rem; letter-spacing: .4em; margin: 0 0 .6rem; }
.preface p { margin: 0 0 .8rem; font-size: .92rem; text-indent: 2em; }
.random { text-align: center; margin: 1.8rem 0 0; }
.random button, .chip {
  font: inherit; font-size: .9rem; cursor: pointer; color: var(--accent);
  background: transparent; border: 1px solid var(--accent); border-radius: 999px; padding: .3rem 1.1rem;
}
.random button:hover { background: var(--accent-soft); }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li { padding: 0 0 1.1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--line); }
.entries li:last-child { border-bottom: 0; }
.entry-meta { margin: 0; font-size: .78rem; color: var(--muted); }
.entries h3 { margin: .1rem 0 .15rem; font-size: 1.08rem; font-weight: 600; line-height: 1.5; }
.entries h3 a { color: var(--ink); }
.entry-desc { margin: 0; font-size: .85rem; color: var(--muted); line-height: 1.7; }

/* ---------- 章節頁 ---------- */
.chapter-head { text-align: center; margin-bottom: 2.2rem; }
.chapter-head h1 { font-size: 2.3rem; font-weight: 900; letter-spacing: .4em; padding-left: .4em; margin: .2rem 0 .6rem; }
.chapter-desc { color: var(--muted); margin: 0; }
.chapter-count { font-size: .8rem; color: var(--muted); margin: .3rem 0 0; letter-spacing: .1em; }
.filters { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin: 0 0 2rem; }
.chip { font-size: .8rem; padding: .15rem .9rem; color: var(--muted); border-color: var(--line); }
.chip[aria-pressed="true"] { color: var(--paper); background: var(--accent); border-color: var(--accent); }
.year { margin-bottom: 2rem; }
.year-title { font-size: .95rem; letter-spacing: .3em; color: var(--accent); margin: 0 0 .5rem; padding-bottom: .3rem; border-bottom: 1px solid var(--line); }
.index { list-style: none; margin: 0; padding: 0; }
.index a { display: flex; align-items: baseline; gap: .6rem; color: var(--ink); padding: .28rem 0; }
.index a:hover { color: var(--accent); text-decoration: none; }
.index time { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 文章頁 ---------- */
.post-head { text-align: center; margin-bottom: 2.5rem; }
.post-head .ch-no a { color: var(--muted); }
.post-head h1 { font-size: 1.85rem; font-weight: 900; line-height: 1.45; margin: .4rem 0 .8rem; letter-spacing: .05em; }
.post-sub { margin: -.4rem 0 .8rem; font-size: .9rem; color: var(--muted); letter-spacing: .05em; }
.post-meta { font-size: .82rem; color: var(--muted); margin: 0; }
.tag { display: inline-block; font-size: .75rem; color: var(--accent); border: 1px solid var(--accent-soft); background: var(--accent-soft); border-radius: 999px; padding: 0 .6rem; margin-left: .4rem; line-height: 1.7; }
.content { font-size: 1.02rem; }
.content p { margin: 0 0 1.3rem; }
.content p.ext-link, .content p.note { text-indent: 0; font-size: .85rem; color: var(--muted); word-break: break-all; }
.content blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 3px solid var(--line); color: var(--muted); }
.figure, .gallery { margin: 2rem 0; }
.figure img { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; border-radius: 2px; cursor: zoom-in; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; margin-left: -1.5rem; margin-right: -1.5rem; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 2px; cursor: zoom-in; background: var(--line); }
.fleuron { text-align: center; color: var(--muted); font-size: 1.2rem; margin: 2.5rem 0 1.5rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; border-top: 1px solid var(--line); padding-top: 1.2rem; font-size: .92rem; line-height: 1.6; }
.pager a { color: var(--ink); }
.pager small { display: block; font-size: .75rem; color: var(--muted); letter-spacing: .2em; }
.pager .next { text-align: right; grid-column: 2; }

.lightbox { position: fixed; inset: 0; background: rgba(20,16,10,.9); display: flex; align-items: center; justify-content: center; z-index: 10; cursor: zoom-out; padding: 1rem; }
.lightbox img { max-width: 100%; max-height: 100%; }

.colophon { text-align: center; font-size: .78rem; color: var(--muted); padding: 1rem 1rem 3rem; }
.colophon .fleuron { margin: 1rem 0 .3rem; }

/* 關於我等一般頁面 */
.page h1 { text-align: center; font-size: 2rem; letter-spacing: .3em; }

/* ---------- 手機 ---------- */
@media (max-width: 860px) {
  .spread { grid-template-columns: 1fr; gap: 1rem; }
  .leaf-left, .leaf-right { box-shadow: var(--shadow); border-right: 0; }
}
@media (max-width: 600px) {
  html { font-size: 17px; }
  .masthead { padding: 2rem 1rem 1rem; }
  .brand-name { font-size: 1.9rem; }
  .toc-nav { font-size: .88rem; }
  .toc-nav a { padding: 0 .5rem; }
  main { padding: 0 0 1.5rem; }
  .sheet, .leaf { padding: 2.2rem 1.25rem; border-radius: 0; }
  .gallery { margin-left: 0; margin-right: 0; grid-template-columns: repeat(2, 1fr); gap: .35rem; }
  .post-head h1 { font-size: 1.5rem; }
  .chapter-head h1 { font-size: 1.9rem; }
}

/* ---------- 留言區 ---------- */
.comments { margin: 0 0 2.5rem; }
.comments-title { font-size: .9rem; letter-spacing: .5em; color: var(--muted); text-align: center; font-weight: 600; margin: 0 0 1.2rem; }
#waline {
  --waline-font-size: .95rem;
  --waline-theme-color: var(--accent);
  --waline-active-color: var(--accent);
  --waline-color: var(--ink);
  --waline-bg-color: var(--paper);
  --waline-bg-color-light: var(--desk);
  --waline-border-color: var(--line);
  --waline-info-color: var(--muted);
  --waline-badge-color: var(--accent);
  font-family: var(--serif);
}
#waline .wl-btn.primary { color: var(--paper); }

/* 瀏覽次數 */
.views { margin: 0 0 .3rem; letter-spacing: .1em; }
.views-inline { margin-left: .3rem; }
.waline-pageview-count { font-variant-numeric: tabular-nums; }

/* ---------- 書架 ---------- */
.shelf-sec { margin-bottom: 2.4rem; }
.shelf-year { font-size: .85rem; color: var(--muted); letter-spacing: .2em; margin: 1.4rem 0 .4rem; font-weight: 600; }
.books { list-style: none; margin: 0; padding: 0; }
.book { padding: .7rem 0 .75rem; border-bottom: 1px dotted var(--line); }
.book:last-child { border-bottom: 0; }
.book p { margin: 0; line-height: 1.6; }
.b-title { font-weight: 600; font-size: 1.02rem; }
.b-title.small { font-weight: 400; font-size: .92rem; }
.b-sub { font-size: .85rem; color: var(--muted); }
.b-en { font-size: .8rem; color: var(--muted); font-style: italic; letter-spacing: 0; }
.b-meta { font-size: .78rem; color: var(--muted); margin-top: .15rem !important; letter-spacing: .05em; }
.award { display: inline-block; margin-left: .5rem; font-size: .72rem; font-weight: 600; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 3px; padding: 0 .35rem; line-height: 1.6; transform: rotate(-3deg) translateY(-.1em); }
.book.awarded { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); padding-left: .6rem; border-radius: 2px; }

.shelf-contact { text-align: center; font-size: .88rem; color: var(--muted); margin: 2rem 0 0; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.page h2 { font-size: 1.05rem; letter-spacing: .2em; color: var(--accent); margin: 2.4rem 0 .8rem; }

.reveal-mail { font: inherit; font-size: .9rem; cursor: pointer; color: var(--accent); background: transparent; border: 1px dashed var(--accent); border-radius: 999px; padding: .15rem .9rem; }
.reveal-mail:hover { background: var(--accent-soft); }
.page .mail-line { text-align: left; }

/* ---------- 足跡地圖 ---------- */
.trip-map { margin: 0 -1.5rem 2.2rem; }
#trip-map { height: 380px; border-radius: 2px; border: 1px solid var(--line); background: #e4dccb; z-index: 0; }
.trip-pin span { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #fbf7ee; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.trip-pin:hover span { transform: scale(1.25); }
.trip-map-note { text-align: center; font-size: .8rem; color: var(--muted); margin: .6rem 0 0; }
.leaflet-popup-content { font-family: var(--serif); font-size: .9rem; line-height: 1.6; }
#trip-map .leaflet-popup-content a, #trip-map .leaflet-control-attribution a { color: var(--accent); }
.pop-meta { color: #877c6b; font-size: .8rem; }
@media (max-width: 600px) { .trip-map { margin: 0 0 1.8rem; } #trip-map { height: 300px; } }

.trip-pin.many span { display: flex; align-items: center; justify-content: center; color: #fbf7ee; font: 600 10px/1 var(--serif); }
.pop-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.pop-list li { padding: .1rem 0; border-top: 1px dotted #ddd2bd; font-size: .85rem; }
