/* 配色取自 banner：米白紙、灰藍蠟筆、夜空黑、沙金 */
:root {
  --bg: #f8f0e1;
  --surface: #fdf8ef;
  --ink: #26292a;
  --muted: #6b675f;
  --line: #e4d6bf;
  --blue: #5d7595;
  --blue-soft: #e3e6ea;
  --gold: #d8ba90;
  --gold-deep: #9c7a45;
  --night: #26292a;
  --night-ink: #f3eadb;
  --swoosh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14'%3E%3Cpath d='M3 9 C 40 4, 70 5, 98 8 S 150 12, 170 6 L 150 9 C 165 8, 185 7, 197 5' fill='none' stroke='%235d7595' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --shadow: 0 8px 22px rgb(38 41 42 / 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #272a2b;
    --surface: #313536;
    --ink: #f3eadb;
    --muted: #ada699;
    --line: #454a4d;
    --blue: #93aacb;
    --blue-soft: #2f3943;
    --gold: #d8ba90;
    --gold-deep: #d8ba90;
    --night: #161819;
    --swoosh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14'%3E%3Cpath d='M3 9 C 40 4, 70 5, 98 8 S 150 12, 170 6 L 150 9 C 165 8, 185 7, 197 5' fill='none' stroke='%2393aacb' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
    --shadow: 0 8px 22px rgb(0 0 0 / 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #272a2b;
  --surface: #313536;
  --ink: #f3eadb;
  --muted: #ada699;
  --line: #454a4d;
  --blue: #93aacb;
  --blue-soft: #2f3943;
  --gold: #d8ba90;
  --gold-deep: #d8ba90;
  --night: #161819;
  --swoosh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14'%3E%3Cpath d='M3 9 C 40 4, 70 5, 98 8 S 150 12, 170 6 L 150 9 C 165 8, 185 7, 197 5' fill='none' stroke='%2393aacb' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --shadow: 0 8px 22px rgb(0 0 0 / 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.8;
}
a { color: var(--blue); text-underline-offset: 3px; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { font-family: "Iansui", "LXGW WenKai TC", serif; font-weight: 400; }
.doodle { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

/* 滿版 banner */
.banner { margin: 0; background: var(--night); }
.banner img { width: 100%; }

/* 自介 */
.intro { padding-top: 40px; padding-bottom: 36px; text-align: center; }
.intro h1 { margin: 0; font-size: clamp(34px, 6vw, 46px); line-height: 1.3; letter-spacing: 0.08em; }
.intro h1 span { font-size: 0.5em; color: var(--muted); margin-left: 8px; letter-spacing: 0.04em; }
.intro p { margin: 10px auto 0; max-width: 40em; font-size: 17px; }
.intro p span { display: inline-block; } /* 在逗號處換行，不把詞拆開 */
.site-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.site-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 16px; color: var(--ink); text-decoration: none;
  font-family: "Iansui", "LXGW WenKai TC", serif; font-size: 18px;
  border: 1.6px solid var(--ink); border-radius: 16px 12px 18px 11px / 12px 17px 11px 16px;
  background: var(--surface);
  transition: transform 0.15s, background 0.15s, color 0.15s;
}
.site-nav a .doodle { color: var(--gold-deep); }
.site-nav a:hover { background: var(--blue); color: #fdf8ef; transform: rotate(-1.5deg); }
.site-nav a:hover .doodle { color: var(--gold); }

section { padding-top: 40px; padding-bottom: 40px; }
section > h2 {
  position: relative; display: flex; align-items: center; gap: 10px; width: fit-content;
  margin: 0 0 12px; padding-bottom: 10px; font-size: 32px; letter-spacing: 0.06em;
}
section > h2 .doodle { color: var(--gold-deep); font-size: 26px; }
/* 標題底下一道手繪弧線，同 banner 標題下那條 */
section > h2::after {
  content: ""; position: absolute; left: 30px; right: -36px; bottom: 0; height: 12px;
  background: var(--swoosh) no-repeat left center / 100% 100%;
}
section > .lead { margin: 0 0 28px; color: var(--muted); }

/* 共用卡片：略不規則的圓角，像手剪的紙片 */
.card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 20px 14px 22px 12px / 14px 22px 12px 20px;
}

/* 作品 */
.books { display: grid; gap: 24px; }
.book {
  display: grid; grid-template-columns: 150px 1fr; grid-template-rows: auto 1fr;
  grid-template-areas: "cover head" "cover body"; gap: 0 26px;
  padding: 22px;
}
.book .cover { grid-area: cover; align-self: start; }
.book .head { grid-area: head; }
.book .body { grid-area: body; }
.cover {
  width: 150px; aspect-ratio: 5 / 7; object-fit: cover;
  border-radius: 3px; box-shadow: var(--shadow);
}
.cover.text {
  writing-mode: vertical-rl; padding: 20px 16px;
  background:
    radial-gradient(circle at 22% 78%, #d8ba90 0 1.5px, transparent 2px),
    radial-gradient(circle at 70% 88%, #f3eadb 0 1px, transparent 1.6px),
    radial-gradient(circle at 30% 20%, #f3eadb 0 1px, transparent 1.6px),
    radial-gradient(circle at 15% 45%, #93aacb 0 1.2px, transparent 1.8px),
    #26292a;
  color: #f3eadb;
  border: 1px solid rgb(216 186 144 / 0.4);
}
.cover.text b { display: block; font-family: "Iansui", "LXGW WenKai TC", serif; font-weight: 400; font-size: 22px; letter-spacing: 0.1em; line-height: 1.5; }
.cover.text small { display: block; margin-right: 10px; text-align: end; font-size: 12px; letter-spacing: 0.3em; color: #d8ba90; }
.book .meta { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.06em; }
.book h3 { margin: 0 0 2px; font-size: 28px; line-height: 1.35; }
.book .cp { margin: 0 0 12px; font-size: 15px; color: var(--blue); font-weight: 500; }
.book .blurb { margin: 0 0 12px; }
.book .lines {
  margin: 0 0 14px; padding: 8px 14px;
  border-left: 2px dashed var(--gold); color: var(--muted); font-size: 15px;
}
.book .lines p { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.tags li { background: var(--blue-soft); color: var(--blue); border-radius: 999px; padding: 1px 11px; font-size: 13px; }
.tags li.shop { background: var(--gold); color: #26292a; font-weight: 500; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links a {
  display: inline-block; padding: 3px 15px;
  border: 1.5px solid var(--ink); border-radius: 12px 9px 13px 8px / 9px 13px 8px 12px;
  color: var(--ink); text-decoration: none; font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.links a:hover { background: var(--blue); border-color: var(--blue); color: #fdf8ef; }

/* 輿圖 */
.map-card {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; align-items: center;
  padding: 22px; color: var(--ink); text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.map-card img { border-radius: 8px; border: 1.5px solid var(--line); }
.map-card h3 { margin: 0 0 6px; font-size: 26px; }
.map-card p { margin: 0 0 12px; color: var(--muted); }
.map-card .go { color: var(--blue); font-family: "Iansui", "LXGW WenKai TC", serif; font-size: 18px; }
.map-card:hover { border-color: var(--blue); transform: translateY(-2px); }

/* 找到我 */
.contact { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.contact a {
  display: flex; align-items: center; gap: 12px; height: 100%; padding: 14px 16px;
  color: var(--ink); text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.contact a:hover { border-color: var(--blue); transform: translateY(-2px); }
.contact .doodle { font-size: 26px; color: var(--blue); }
.contact li:nth-child(even) .doodle { color: var(--gold-deep); }
.contact b { display: block; font-family: "Iansui", "LXGW WenKai TC", serif; font-weight: 400; font-size: 21px; line-height: 1.4; }
.contact span { font-size: 13px; color: var(--muted); }

/* 關於我：底下一行小字，點開是彈出視窗 */
.about-more { margin: 22px 0 0; font-size: 14px; }
.about-more a { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 4px; }
.about-more a:hover { color: var(--blue); }
.about {
  width: min(580px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; color: var(--ink); box-shadow: var(--shadow);
  overflow: auto; overscroll-behavior: contain;
}
.about::backdrop { background: rgb(22 24 25 / 0.6); }
.about:focus { outline: none; } /* 打開時焦點落在視窗本身，不畫焦點框 */
.about[open] { animation: about-in 0.18s ease-out; }
@keyframes about-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
html:has(.about[open]) { overflow: hidden; }
.about-body { position: relative; display: grid; grid-template-columns: 136px 1fr; gap: 26px; align-items: start; padding: 30px 30px 32px; }
.about .avatar { width: 136px; height: 136px; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold); }
.about h2 { margin: 2px 0 10px; font-size: 32px; line-height: 1.3; letter-spacing: 0.06em; }
.about h2 span { font-size: 0.5em; color: var(--muted); margin-left: 8px; letter-spacing: 0.04em; }
.about p { margin: 0; line-height: 1.9; }
.about-close {
  display: block; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 17px; cursor: pointer;
}
.about-close:hover { background: var(--blue-soft); color: var(--ink); }
.about-close:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.about form { position: absolute; top: 12px; right: 14px; margin: 0; } /* 關閉鈕浮在右上角，不佔版面 */
@media (prefers-reduced-motion: reduce) { .about[open] { animation: none; } }

/* 頁尾：夜空 */
footer {
  margin-top: 40px; padding: 44px 16px 52px; text-align: center;
  background:
    radial-gradient(circle at 8% 30%, #f3eadb 0 1.4px, transparent 2px),
    radial-gradient(circle at 18% 70%, #d8ba90 0 2px, transparent 2.6px),
    radial-gradient(circle at 34% 40%, #f3eadb 0 1px, transparent 1.6px),
    radial-gradient(circle at 62% 75%, #93aacb 0 1.6px, transparent 2.2px),
    radial-gradient(circle at 78% 25%, #d8ba90 0 1.4px, transparent 2px),
    radial-gradient(circle at 92% 60%, #f3eadb 0 1.2px, transparent 1.8px),
    var(--night);
  color: var(--night-ink);
}
footer small { color: #ada699; font-size: 13px; }

/* 明暗切換 */
.theme-switch {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 18px; font-family: "Iansui", "LXGW WenKai TC", serif; font-size: 15px; color: #ada699;
}
#theme-toggle {
  position: relative; width: 58px; height: 30px; padding: 0; cursor: pointer;
  border: 1.5px solid #f3eadb; border-radius: 999px; background: #f8f0e1;
  transition: background 0.2s;
}
#theme-toggle:focus-visible { outline: 2px solid #93aacb; outline-offset: 3px; }
#theme-toggle .knob {
  position: absolute; top: 2px; left: 2px; width: 23px; height: 23px; border-radius: 50%;
  display: grid; place-items: center; background: #d8ba90;
  transition: transform 0.2s;
}
#theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: #26292a; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; grid-area: 1 / 1; }
#theme-toggle .moon { display: none; }
#theme-toggle[aria-checked="true"] { background: #5d7595; }
#theme-toggle[aria-checked="true"] .knob { transform: translateX(28px); }
#theme-toggle[aria-checked="true"] .sun { display: none; }
#theme-toggle[aria-checked="true"] .moon { display: block; }
@media (prefers-reduced-motion: reduce) { #theme-toggle, #theme-toggle .knob { transition: none; } }

/* 寬螢幕：作品卡片每排兩張 */
@media (min-width: 960px) {
  .books { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book { grid-template-columns: 124px 1fr; gap: 0 22px; }
  .book .cover { width: 124px; }
  .cover.text b { font-size: 19px; }
}

@media (max-width: 640px) {
  .intro { padding-top: 28px; padding-bottom: 24px; }
  section { padding-top: 28px; padding-bottom: 28px; }
  section > h2 { font-size: 28px; }
  .book { grid-template-columns: 96px 1fr; grid-template-areas: "cover head" "body body"; gap: 14px 16px; padding: 16px; }
  .book .head { align-self: end; }
  .cover { width: 96px; }
  .cover.text { padding: 12px 8px; }
  .cover.text b { font-size: 15px; }
  .cover.text small { display: none; }
  .book h3 { font-size: 24px; }
  .map-card { grid-template-columns: 1fr; padding: 16px; }
  .about-body { grid-template-columns: 1fr; justify-items: center; gap: 16px; padding: 30px 20px 26px; }
  .about .avatar { width: 116px; height: 116px; }
  .about h2 { text-align: center; }
}
