/* kame — warm, quiet, turtle-green. */

:root {
  --bg: #FDFBF7;
  --surface: #FFFFFF;
  --text: #24312A;
  --muted: #7C8A80;
  --accent: #4E8560;
  --accent-text: #FFFFFF;
  --accent-soft: #E9F2EC;
  --highlight: #FBEECB;
  --highlight-edge: #E8C766;
  --border: #E8E3D8;
  --shadow: 0 1px 2px rgba(36, 49, 42, .05), 0 8px 24px rgba(36, 49, 42, .06);
  --radius: 14px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141815;
    --surface: #1C221E;
    --text: #E7E3D8;
    --muted: #8FA096;
    --accent: #7FBF93;
    --accent-text: #10160F;
    --accent-soft: #22302A;
    --highlight: #3B3620;
    --highlight-edge: #6E6231;
    --border: #2A322C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- home ---------- */

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.hero {
  width: 100%;
  max-width: 560px;
  text-align: center;
  margin-top: -8vh;
}

.logo { width: 132px; height: 132px; display: block; margin: 0 auto; }

.wordmark {
  font-size: 46px;
  font-weight: 600;
  letter-spacing: -.03em;
  margin: 2px 0 0;
}
.wordmark span {
  font-size: 20px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 10px;
  vertical-align: 9px;
  letter-spacing: 0;
}

.tagline { color: var(--muted); margin: 6px 0 26px; font-size: 15px; }

.search { display: flex; gap: 8px; }

.search input {
  flex: 1;
  min-width: 0;
  padding: 15px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
}
.search input::placeholder { color: var(--muted); }

.search button {
  padding: 15px 26px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, opacity .15s;
}
.search button:hover:not(:disabled) { transform: translateY(-1px); }
.search button:disabled { opacity: .6; cursor: default; }

.options {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}
.options select {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
}
.options select:hover { border-color: var(--border); background: var(--surface); }

.notice {
  margin: 20px auto 0;
  max-width: 460px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.notice.bad { border-color: #D98A7B; color: #B4513E; background: #FDF3F1; }
@media (prefers-color-scheme: dark) {
  .notice.bad { background: #2B1D1A; color: #E7A493; border-color: #5A342C; }
}

/* ---------- reader ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; }
.brand img { width: 30px; height: 30px; }

.reader { max-width: 720px; margin: 0 auto; padding: 40px 24px 190px; }
.reader h1 { font-family: var(--serif); font-size: 36px; line-height: 1.2; margin: 0 0 10px; }
.meta { color: var(--muted); font-size: 14px; margin: 0 0 34px; }
.meta a { color: var(--muted); }

#body { font-family: var(--serif); font-size: 20px; line-height: 1.75; }
/* The Latin serif stack has no Han glyphs; name real CJK faces so the browser
   does not fall back to something inconsistent mid-paragraph. */
#body:lang(zh), #body:lang(ja) {
  font-family: "PingFang TC", "PingFang SC", "Hiragino Sans", "Hiragino Mincho ProN",
               "Noto Serif CJK TC", "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.95;
}
h1:lang(zh), h1:lang(ja) {
  font-family: "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK TC", sans-serif;
}
#body h2 {
  font-size: 24px; line-height: 1.3;
  margin: 38px 0 10px; font-family: var(--serif);
}
#body p { margin: 0 0 22px; }

.s {
  border-radius: 5px;
  padding: 1px 0;
  cursor: pointer;
  transition: background-color .18s ease, box-shadow .18s ease;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.s:hover { background: var(--accent-soft); }
.s.on {
  background: var(--highlight);
  box-shadow: 0 0 0 3px var(--highlight);
}
.s.done { color: color-mix(in srgb, var(--text) 62%, transparent); }

/* ---------- player ---------- */

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.player .mascot { width: 42px; height: 42px; flex: none; }
.player.playing .mascot { animation: bob 1.9s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-5px) rotate(-3deg); }
}
@media (prefers-reduced-motion: reduce) {
  .player.playing .mascot { animation: none; }
  .s { transition: none; }
}

.controls { display: flex; align-items: center; gap: 4px; flex: none; }
.icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: transparent; cursor: pointer;
  color: var(--muted);
  transition: background-color .14s, color .14s;
}
.icon:hover { background: var(--accent-soft); color: var(--text); }
.icon.primary {
  width: 46px; height: 46px;
  background: var(--accent); color: var(--accent-text);
}
.icon.primary:hover { background: var(--accent); filter: brightness(1.06); }
.icon svg { width: 18px; height: 18px; fill: currentColor; }
.icon.primary svg { width: 20px; height: 20px; }

.track { flex: 1; min-width: 60px; }
.rail {
  height: 5px; border-radius: 999px;
  background: var(--border); overflow: hidden;
  cursor: pointer;
}
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .25s linear; }
.status { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11.5px; color: var(--muted); }

.player .options { margin: 0; gap: 4px; }
.dl {
  text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.dl:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 720px) {
  .reader { font-size: 18px; padding-top: 26px; }
  .reader h1 { font-size: 28px; }
  .player { gap: 8px; padding: 10px 12px; flex-wrap: wrap; }
  .player .mascot, .status, .dl { display: none; }
  .logo { width: 104px; height: 104px; }
  .wordmark { font-size: 38px; }
}

/* ---------- cookie consent ---------- */

.consent {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(680px, calc(100vw - 32px));
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.consent-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.consent-actions { display: flex; gap: 8px; margin-left: auto; }

.consent-btn {
  padding: 9px 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
/* Declining must be no harder than accepting, so it is a peer button rather
   than a buried link. */
.consent-btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.consent-btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* The reader's player bar already occupies the bottom edge. */
body:has(.player:not([hidden])) .consent { bottom: 84px; }

@media (max-width: 620px) {
  .consent { flex-direction: column; align-items: stretch; gap: 12px; }
  .consent-actions { margin-left: 0; }
  .consent-btn { flex: 1; }
}
