/*
 * 一枚漫画（js/comics.js・app.js の「一枚漫画」）。
 * 夜の画面の上に、生成りの紙の1ページを置く。コマは墨の枠線、文はコマの中の白い囲み（ナレーション）。
 * 文は絵に描き込まず、ここで重ねる。結びの一行（.at-end）だけは囲まず、コマの下の端に大きめに出す。
 */

.bp-comic {
  position: fixed;
  inset: 0;
  z-index: 40; /* 拡大表示（20）と開封画面の上 */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  background:
    radial-gradient(ellipse 70% 55% at 50% 30%, rgba(30, 40, 78, 0.6), transparent 72%),
    #05070e;
}

.bp-comic-sheet {
  width: min(100%, 520px);
  margin: 0 auto;
  animation: bp-comic-in 0.6s ease-out both;
}

@keyframes bp-comic-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* 紙の1ページ */
.bp-comic-page {
  --ink: #1d1a16;
  margin: 0;
  padding: 14px 14px 16px;
  border-radius: 4px;
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, rgba(255, 255, 255, 0.5), transparent 60%),
    var(--bp-card);
  box-shadow:
    0 0 0 1px rgba(231, 191, 85, 0.25),
    0 24px 60px rgba(0, 0, 0, 0.6);
  color: var(--ink);
}

.bp-comic.is-ssr .bp-comic-page {
  box-shadow:
    0 0 0 1px rgba(240, 198, 80, 0.6),
    0 0 40px rgba(240, 190, 80, 0.14),
    0 24px 60px rgba(0, 0, 0, 0.6);
}

.bp-comic-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 10px;
}

.bp-comic-title {
  margin: 0;
  font-family: var(--font-mincho);
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

.bp-comic-kind {
  flex: none;
  padding: 1px 8px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

.bp-comic-panels {
  display: grid;
  gap: 10px;
}

/* 1コマ。figure の中に絵の枠と文を重ねる */
.bp-comic-panel {
  position: relative;
  margin: 0;
}

.bp-comic-frame {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: #0c1120;
}

/* 描き下ろしの絵 */
.bp-comic-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

/* 仮の絵：カードの絵から切り出す（位置と大きさは panelCrop が % で決める） */
.bp-comic-crop {
  position: absolute;
  background-size: 100% 100%;
}

/* 静まりかえったコマ：色と明るさを沈める */
.bp-comic-panel.is-hush .bp-comic-art,
.bp-comic-panel.is-hush .bp-comic-crop {
  filter: brightness(0.62) saturate(0.45);
}

/* 結びのコマ：後ろから差す、あたたかい光 */
.bp-comic-panel.is-warm .bp-comic-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 55%, rgba(255, 196, 120, 0.45), transparent 70%),
    linear-gradient(to top, rgba(5, 7, 14, 0.75), transparent 45%);
  mix-blend-mode: normal;
  pointer-events: none;
}

/* ナレーションの囲み */
.bp-comic-text {
  position: absolute;
  z-index: 1;
  max-width: 60%;
  margin: 0;
  padding: 3px 7px;
  border: 1px solid var(--ink);
  background: rgba(252, 249, 241, 0.94);
  color: var(--ink);
  font-family: var(--font-mincho);
  font-size: clamp(12px, 3.2vw, 14.5px);
  line-height: 1.6;
  letter-spacing: 0.03em;
  word-break: auto-phrase; /* 日本語を文節で折り返す（対応していないブラウザでは普通に折り返す） */
}

.bp-comic-text.at-tl {
  top: 6px;
  left: 6px;
}

.bp-comic-text.at-br {
  right: 6px;
  bottom: 6px;
}

/* 結びの一行：囲まず、コマの下の端に */
.bp-comic-text.at-end {
  right: 0;
  bottom: 12px;
  left: 0;
  max-width: none;
  padding: 0 12px;
  border: 0;
  background: none;
  color: #f6ecd0;
  font-size: clamp(15px, 4.4vw, 18px);
  letter-spacing: 0.14em;
  text-align: center;
  text-shadow: 0 0 14px rgba(240, 190, 80, 0.55), 0 1px 3px rgba(0, 0, 0, 0.8);
}

.bp-comic-note {
  margin: 12px 2px 0;
  color: #6b6455;
  font-size: 0.75rem;
  line-height: 1.6;
}

.bp-comic-actions {
  display: flex;
  justify-content: center;
  margin: 18px 0 8px;
}

@media (prefers-reduced-motion: reduce) {
  .bp-comic-sheet {
    animation: none;
  }
}
