/* ロンの開発日々エッセイ — 絵本モード（ヘッダーもフッターも無い、本だけのページ） */
:root {
  --desk: #e9dcc6;
  --desk-2: #dccbae;
  --paper: #fbf6ec;
  --ink: #3b3226;
  --ink-soft: #6d6153;
  --accent: #c8735a;
  --band-day: rgba(251, 246, 236, 0.88);
  --band-night: rgba(30, 34, 58, 0.66);
  --ink-night: #f6eedd;
  --shadow: rgba(60, 40, 20, 0.28);
  --turn: 0.85s;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: #1f1b17;
    --desk-2: #2a241e;
    --ink: #ece3d3;
    --ink-soft: #b9ad9b;
    --shadow: rgba(0, 0, 0, 0.55);
  }
}
@media (prefers-reduced-motion: reduce) {
  :root { --turn: 0s; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 40%, var(--desk) 0%, var(--desk-2) 100%);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 上の帯 */
.bk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 14px;
}
.bk-name {
  flex: 1;
  margin: 0;
  text-align: center;
  font-family: "Klee One", serif;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bk-link, .bk-read {
  font: inherit;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
  white-space: nowrap;
}
.bk-read[disabled] { opacity: 0.5; cursor: default; }
.bk-read { cursor: pointer; }
.bk-read[aria-pressed="true"] { color: var(--paper); background: var(--accent); border-color: var(--accent); }

/* 読み上げ中の段落 */
.bp-text .is-reading {
  background: rgba(200, 115, 90, 0.2);
  box-shadow: 0 0 0 0.25em rgba(200, 115, 90, 0.2);
  border-radius: 0.3em;
  transition: background 0.3s;
}
.tone-night .bp-text .is-reading {
  background: rgba(242, 184, 75, 0.22);
  box-shadow: 0 0 0 0.25em rgba(242, 184, 75, 0.22);
}

/* 本 */
.bk-stage {
  /* 本は上に寄せる。下のボタンは本のすぐ下に続ける（縦長の画面で上に空きを作らない） */
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4px 16px 0;
}
.bk-book {
  --bw: min(94vw, calc((100vh - 130px) * 0.75));
  position: relative;
  display: flex;
  width: var(--bw);
  aspect-ratio: 3 / 4;
  perspective: 2400px;
  filter: drop-shadow(0 10px 22px var(--shadow));
  touch-action: pan-y;
}
.bk-slot {
  position: relative;
  flex: 1;
  container-type: inline-size;
  background: var(--paper);
  overflow: hidden;
  border-radius: 6px;
}
.bk-left { display: none; }

/* 見開き（横に広い画面） */
.spread .bk-book {
  --bw: min(96vw, calc((100vh - 130px) * 1.5));
  aspect-ratio: 3 / 2;
}
.spread .bk-left { display: block; border-radius: 8px 0 0 8px; }
.spread .bk-right { border-radius: 0 8px 8px 0; }
.spread .bk-book::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 60px;
  margin-left: -30px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(60, 40, 20, 0.16) 45%, rgba(60, 40, 20, 0.22) 50%, rgba(60, 40, 20, 0.16) 55%, transparent);
  z-index: 5;
}

/* 1 ページ */
.bp {
  position: relative;
  width: 100%;
  height: 100%;
  container-type: inline-size;
}
.bp-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bp-blank {
  background-color: var(--paper);
  background-image: radial-gradient(circle, rgba(200, 115, 90, 0.16) 1.5px, transparent 2px);
  background-size: 26px 26px;
}
.bp-text {
  position: absolute;
  left: 6%;
  right: 6%;
  padding: 2.8cqw 4cqw;
  border-radius: 3cqw;
  font-size: clamp(12px, 3.4cqw, 19px);
  line-height: 1.8;
  letter-spacing: 0.02em;
}
.pos-top .bp-text { top: 5%; }
.pos-bottom .bp-text { bottom: 6%; }
.tone-day .bp-text { background: var(--band-day); color: #3b3226; }
.tone-night .bp-text { background: var(--band-night); color: var(--ink-night); }
.bp-text p { margin: 0 0 0.5em; }
.bp-text p:last-child { margin-bottom: 0; }
.bp-chap {
  font-family: "Klee One", serif;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.92em;
}
.tone-night .bp-chap { color: #f2b84b; }
.bp-quote {
  margin: 0.4em 0 0.6em;
  padding: 0.2em 0 0.2em 0.9em;
  border-left: 0.3em solid var(--accent);
  font-family: "Klee One", serif;
  font-weight: 600;
}
.tone-night .bp-quote { border-left-color: #f2b84b; }
.bp-no {
  position: absolute;
  bottom: 2.4%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Klee One", serif;
  font-size: clamp(11px, 3cqw, 15px);
  color: rgba(59, 50, 38, 0.55);
}
.tone-night .bp-no { color: rgba(246, 238, 221, 0.6); }

/* 表紙 */
.kind-cover .bp-text { text-align: center; top: 8%; background: transparent; font-size: clamp(13px, 4cqw, 22px); }
.bp-series { font-size: 0.8em; opacity: 0.85; }
.bp-epno { font-family: "Klee One", serif; font-size: 0.95em; }
.bp-title {
  font-family: "Klee One", serif;
  font-weight: 600;
  font-size: 1.6em;
  line-height: 1.45;
  margin: 0.2em 0 0.4em;
}
.bp-author { font-family: "Klee One", serif; }

/* おしまい */
.kind-end .bp-text { text-align: center; }
.bp-end { font-family: "Klee One", serif; font-size: 1.5em; font-weight: 600; }
.bp-links a {
  display: inline-block;
  margin: 0.3em 0.4em 0;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* めくる紙 */
.bk-leaf {
  position: absolute;
  top: 0;
  height: 100%;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform var(--turn) cubic-bezier(0.45, 0.05, 0.3, 1);
  z-index: 10;
}
.spread .bk-leaf { width: 50%; }
.bk-leaf.to-next { left: 0; transform-origin: left center; }
.spread .bk-leaf.to-next { left: 50%; }
.bk-leaf.to-prev { left: 0; transform-origin: right center; }
.bk-leaf.single-prev { left: 0; transform-origin: left center; }
.bk-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  background: var(--paper);
  container-type: inline-size;
}
.bk-face.back { transform: rotateY(180deg); }
.bk-face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--turn);
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), transparent 40%);
}
.bk-leaf.turning .bk-face::after { opacity: 1; }

/* 絵の中で押せるもの（人物・月・ギター・手紙 …）── 押すと動き、ひとことしゃべる */
.bp .tap { cursor: pointer; transform-box: fill-box; transform-origin: center bottom; }
.bp .gl { pointer-events: none; }
.bp .tap.m-hop    { animation: tap-hop 0.7s ease-out; }
.bp .tap.m-wiggle { animation: tap-wiggle 0.6s ease-in-out; transform-origin: center; }
.bp .tap.m-glow   { animation: tap-glow 1.2s ease-in-out; transform-origin: center; }
.bp .tap.m-strum  { animation: tap-strum 0.8s ease-in-out; }
@keyframes tap-hop {
  0% { transform: translateY(0); } 30% { transform: translateY(-18px) scale(1.04, 0.97); }
  55% { transform: translateY(0) scale(1.05, 0.95); } 75% { transform: translateY(-5px); } 100% { transform: translateY(0); }
}
@keyframes tap-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }
@keyframes tap-glow {
  0%, 100% { transform: scale(1); filter: none; }
  40% { transform: scale(1.25); filter: drop-shadow(0 0 10px #fff4cf) drop-shadow(0 0 20px #ffe7a8); }
}
@keyframes tap-strum { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-5deg); } 40% { transform: rotate(4deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }

/* ひとことの吹き出しと、ギターの音符 */
.bk-bubble {
  position: absolute;
  z-index: 8;
  transform: translate(-50%, -100%);
  padding: 0.35em 0.8em;
  border-radius: 1em;
  background: #fffdf6;
  color: #3b3226;
  font-family: "Klee One", serif;
  font-size: clamp(12px, 3.6cqw, 18px);
  width: max-content;      /* 短い台詞は 1 行のまま */
  max-width: 86%;          /* 長い台詞はページの内側で折り返す（左右は book.js の fitBubble が収める） */
  white-space: normal;
  text-wrap: balance;      /* 折り返したとき、2 行の長さをそろえる（1 文字だけの行を作らない） */
  line-height: 1.5;
  box-shadow: 0 3px 10px rgba(60, 40, 20, 0.25);
  pointer-events: none;
  animation: bubble 2.4s ease-out forwards;
}
.bk-bubble::after {
  content: "";
  position: absolute;
  left: calc(50% + var(--tail, 0px));   /* 吹き出しをずらしても、しっぽは押した人物を指す */
  bottom: -7px;
  margin-left: -7px;
  border: 7px solid transparent;
  border-top-color: #fffdf6;
  border-bottom: 0;
}
.bk-note {
  position: absolute;
  z-index: 8;
  font-size: clamp(16px, 5cqw, 26px);
  color: #c8735a;
  pointer-events: none;
  animation: note 1.6s ease-out forwards;
}
@keyframes bubble { 0% { opacity: 0; margin-top: 6px; } 12% { opacity: 1; margin-top: 0; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes note { 0% { opacity: 0; transform: translate(-50%, 0); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 10px)), -60px); } }
@media (prefers-reduced-motion: reduce) {
  .bp .tap.m-hop, .bp .tap.m-wiggle, .bp .tap.m-glow, .bp .tap.m-strum, .bk-note { animation: none; }
  .bk-bubble { animation: bubble-calm 2.4s linear forwards; }
  @keyframes bubble-calm { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
}

/* 下のめくりボタン */
.bk-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 8px 16px 16px;
}
.bk-nav button {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: 0 2px 8px var(--shadow);
  cursor: pointer;
}
.bk-nav button[disabled] { opacity: 0.35; cursor: default; }
.bk-count {
  font-family: "Klee One", serif;
  color: var(--ink-soft);
  min-width: 6em;
  text-align: center;
}

/* JS が動かないときは、ページを縦に並べて読めるようにする */
.bk-store { display: grid; gap: 20px; width: min(94vw, 480px); }
.js .bk-store { display: none; }
.bk-book, .bk-nav { display: none; }
.js .bk-book { display: flex; }
.js .bk-nav { display: flex; }
.js .bk-stage { overflow: hidden; }

@media (max-width: 520px) {
  .bp-text { font-size: clamp(13px, 4cqw, 17px); }
  .bk-name { display: none; }
  .bk-bar { justify-content: space-between; }
}

/* 見開きの表紙の左「とうじょうじんぶつ」（2026-09-30 夜） */
.kind-cast .bp-text { text-align: center; }
.kind-cast .bp-chap { font-size: 1.1em; margin-bottom: 0.2em; }
.bp-cast-note { font-size: 0.8em; opacity: 0.75; }
