/* ============================================================
   MELT VERSE ― 詳細ページ共通スタイル
   全プロットの詳細ページ（plot-01.html 〜）がこの1ファイルを共有します。
   色・フォントを変えたい場合はこの :root だけ直せば全ページに反映されます。
   ============================================================ */

:root {
  --bg:        #232323;
  --text:      #ffffff;
  --muted:     #929699;
  --surface:   #2b2b2b;
  --surface-2: #343434;
  --surface-3: #3c3c3c;
  --border:    rgba(255,255,255,0.10);
  --border-2:  rgba(255,255,255,0.22);
  --border-strong: rgba(255,255,255,0.34);

  --font-display: "Archivo", "Zen Kaku Gothic New", sans-serif;
  --font-body:    "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 22px 0;
}

/* ============ 一覧に戻る ============ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 24px;
  transition: color .15s ease;
}
.back-link:hover { color: var(--text); }

/* ============ ヒーロー（バナー〜あらすじ） ============ */
.detail-hero { margin-bottom: 40px; }

/* メインバナー：画像全体が必ず見えるよう object-fit: contain。
   余白はページ背景色（--bg）で埋め、境界が目立たないようにする。極端な縦横比でも
   破綻しないよう高さを固定。 */
.detail-banner-link {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 320px;
  height: 380px;
  margin: 0 auto 10px;
  background: var(--bg);
  overflow: hidden;
  text-decoration: none;
}
.detail-banner-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.placeholder-banner-lg {
  width: 100%;
  height: 100%;
  border: 1px dashed var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}
.detail-banner-cap {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 28px;
  transition: color .15s ease;
}
.detail-banner-cap:hover { color: var(--text); }

.detail-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(26px, 7vw, 32px);
  letter-spacing: 0.01em;
  line-height: 1.3;
  margin: 0 0 14px;
  text-align: center;
}

/* 長いタイトル用：1行に収まるよう文字サイズを画面幅に合わせて縮める */
.detail-title.is-long {
  font-size: clamp(15px, 4.3vw, 28px);
  white-space: nowrap;
}

.detail-synopsis {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.9;
  margin: 0 auto;
  max-width: 34em;
}

/* ============ タブ（純CSS切り替え／JS不使用） ============ */
.tabs { margin-bottom: 8px; }

.tab-input { position: absolute; opacity: 0; pointer-events: none; }

.tab-nav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tab-label {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
  user-select: none;
}
.tab-label:hover { color: var(--text); }

.tab-panel { display: none; }

#tab-character:checked ~ .tab-nav label[for="tab-character"],
#tab-world:checked     ~ .tab-nav label[for="tab-world"],
#tab-novel:checked     ~ .tab-nav label[for="tab-novel"],
#tab-gallery:checked   ~ .tab-nav label[for="tab-gallery"] {
  color: var(--text);
  border-bottom-color: var(--text);
}
#tab-character:checked ~ .tab-panels #panel-character,
#tab-world:checked     ~ .tab-panels #panel-world,
#tab-novel:checked     ~ .tab-panels #panel-novel,
#tab-gallery:checked   ~ .tab-panels #panel-gallery {
  display: block;
}

.tab-input:focus-visible ~ .tab-nav label[for="tab-character"],
.tab-input:focus-visible ~ .tab-nav label[for="tab-world"],
.tab-input:focus-visible ~ .tab-nav label[for="tab-novel"],
.tab-input:focus-visible ~ .tab-nav label[for="tab-gallery"] {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

.tab-panels { padding-bottom: 24px; }

/* ============ キャラクタータブ ============ */

/* ページ内アンカーナビ：各キャラクターへジャンプ。タブ切り替えと混同しないよう
   ピル型の控えめなリンクにする（タブの見た目とは明確に区別） */
.char-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.char-nav-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color .15s ease, border-color .15s ease;
}
.char-nav-link:hover {
  color: var(--text);
  border-color: var(--border-2);
}

.char-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.char-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

/* 挿絵サムネイルグリッド（キャラクタータブ／ギャラリータブ共通。JS: js/detail.js）
   クリックで共通ライトボックスを開く。 */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 14px;
}
@media (max-width: 460px) {
  .thumb-grid { grid-template-columns: repeat(3, 1fr); }
}
.thumb-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: none;
  padding: 0;
  background: var(--surface-2);
  cursor: pointer;
}
.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s ease, filter .2s ease;
}
.thumb-item .thumb-hover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.28);
  opacity: 0;
  transition: opacity .15s ease;
}
.thumb-item .thumb-hover svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.thumb-item:hover img { transform: scale(1.06); filter: brightness(1.1); }
.thumb-item:hover .thumb-hover { opacity: 1; }

.char-body { padding: 18px 18px 20px; }
.char-name {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 14px;
}

/* 基本設定／裏設定 共通：項目名｜内容のシンプルなリスト（罫線・背景は使わない）。
   行（.char-stat-row）を増減すれば項目を自由に追加・削除できます。 */
.char-stats {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
}
.char-stat-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 4px 12px;
}
.char-stat-row dt {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.char-stat-row dd {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
}
/* 設定内の箇条書き（項目ごとに行を分け、先頭に小さな点を付ける） */
.char-bullets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.char-bullets li {
  position: relative;
  padding-left: 14px;
}
.char-bullets li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}
.char-bullets-note {
  margin: 10px 0 0;
}
/* 設定内のコード表記（改行・字下げを保持。長い行は枠内で横スクロール） */
.char-code {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow-x: auto;
  font-family: ui-monospace, "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

/* イメージソング：任意セクション。イメージソングがあるキャラクターだけ
   <div class="char-song"> ごと記述してください（無いキャラはブロックごと省略、
   または <div class="char-song" hidden> とすればセクション全体が非表示になります）。
   プレーヤーはカード幅いっぱいにせず、340pxを上限に16:9のまま中央寄せで表示します。 */
.char-song { margin-top: 18px; }
.char-song[hidden] { display: none; }
.char-song-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
  margin: 0 0 12px;
}
.char-song-frame {
  width: 100%;
  max-width: 340px;   /* ここを320〜360pxの範囲で調整できます */
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}
.char-song-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* 裏設定：クリックで開閉するアコーディオン（純CSS／checkbox+label方式） */
.char-secret { margin-top: 16px; }
.secret-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.secret-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: color .15s ease;
}
.secret-toggle-btn:hover { color: var(--text); }
.secret-toggle-btn .icon-lock,
.secret-toggle-btn .icon-chevron {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* 矢印はSVG自体ではなく囲みの <span> を回転させる（SVG要素への直接transformは
   環境によって適用されない場合があるため、通常のHTML要素で確実に回転させる） */
.icon-chevron-wrap {
  display: inline-flex;
  transition: transform .2s ease;
}
.secret-toggle:focus-visible ~ .secret-toggle-btn {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 3px;
}

.secret-content { display: none; margin-top: 12px; }
.secret-toggle:checked ~ .secret-content { display: block; }
.secret-toggle:checked ~ .secret-toggle-btn .icon-chevron-wrap { transform: rotate(180deg); }

/* ============ 世界観タブ ============ */
.world-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 36px;
}
.world-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.world-img,
.placeholder-world {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  margin-bottom: 14px;
}
.placeholder-world {
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.world-heading {
  font-size: 15.5px;
  font-weight: 700;
  margin: 0 0 8px;
}
.world-body {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.85;
  margin: 0;
  white-space: pre-line;
}

/* 用語集：各項目を左アクセントバー＋下区切り線で独立したブロックに見せる */
.glossary {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.glossary-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.03em;
  margin: 0 0 16px;
}
.glossary dl { margin: 0; }
.glossary-item {
  border-left: 3px solid var(--border-2);
  border-bottom: 1px solid var(--border);
  padding: 2px 0 14px 12px;
  margin-bottom: 14px;
}
.glossary-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.glossary-item dt {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.glossary-item dd {
  font-size: 13px;
  color: var(--text);
  line-height: 1.8;
  margin: 4px 0 0;
}

/* ============ 小説タブ ============ */
.novel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.novel-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.novel-ep {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.novel-title {
  font-size: 14.5px;
  font-weight: 700;
  margin: 0 0 6px;
}
.novel-synopsis {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 10px;
}
.novel-meta {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0.8;
}

.novel-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 48px 0;
}

/* ============ ギャラリータブ ============
   表示は .thumb-grid（キャラクタータブと共通コンポーネント）を使用します。 */

/* ============ Fan Works ページ（plot-0N-fanworks.html） ============ */
.fw-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(22px, 6vw, 27px);
  letter-spacing: 0.01em;
  line-height: 1.3;
  margin: 0 0 36px;
  text-align: center;
}

.fw-section { margin-bottom: 40px; }
.fw-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.fw-novel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fw-novel-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  text-decoration: none;
  transition: border-color .15s ease;
}
.fw-novel-item:hover { border-color: var(--border-2); }
.fw-novel-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.fw-novel-author {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.fw-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 48px 0;
}

/* ============ ライトボックス（キャラクター／ギャラリー両タブ共通／JS: js/detail.js） ============ */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}
.lightbox.is-open { display: flex; }
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text);
  background: rgba(255,255,255,0.12);
  padding: 4px 12px;
  border-radius: 12px;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.lightbox-close:hover { background: rgba(255,255,255,0.24); }
.lightbox-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.lightbox-btn:hover { background: rgba(255,255,255,0.24); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

@media (max-width: 460px) {
  .lightbox-btn { width: 34px; height: 34px; font-size: 15px; }
}

/* ============ フォーカス表示 ============ */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ============ フッター（トップページと共通デザイン） ============ */
.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
  text-align: center;
}
.owner-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 0 0 8px;
}
.owner-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.owner-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.03em;
  color: var(--text);
}
.footer-email {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 10px;
}
.footer-meta {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  margin: 0;
}

/* ============ ページ上部に戻るボタン ============ */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  z-index: 500;
}
.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover { border-color: var(--text); }
.back-to-top svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
