/* 深淵書架 相関星図 ── 立体表示(3D)・神格一覧・情報パネル(2026-10-21)
   色の変数 --shn-k3d-c は overlay.js が層の色(PHPが渡す、サイトの層バッジと同じ値)を入れる。
   オーバーレイ自体は常に暗い画面なので、OSのライト/ダーク設定では配色を変えない
   (2D版の shinen-kinship-overlay.css と同じ扱い)。 */

.shn-kinship-overlay [hidden] { display: none !important; }

.shn-kinship-overlay-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.shn-kinship-overlay-list-btn,
.shn-kinship-overlay-mode {
  background: none;
  border: 1px solid var(--shn-gold-dim);
  color: var(--shn-gold);
  border-radius: 2px;
  font-size: 11px;
  letter-spacing: .12em;
  padding: 6px 13px;
  cursor: pointer;
  font-family: inherit;
}
.shn-kinship-overlay-list-btn:hover,
.shn-kinship-overlay-mode:hover,
.shn-kinship-overlay-list-btn[aria-expanded="true"] { background: var(--shn-gold); color: var(--shn-abyss); }
.shn-kinship-overlay button:focus-visible,
.shn-kinship-overlay a:focus-visible,
.shn-k3d-canvas:focus-visible {
  outline: 2px solid var(--shn-phos);
  outline-offset: 2px;
}

/* 3Dのときは2D専用の凡例を隠す */
.shn-kinship-overlay.is-3d .shn-kinship-overlay-legend,
.shn-kinship-overlay.is-3d .shn-kinship-overlay-faction-legend,
.shn-kinship-overlay.is-3d .shn-kinship-overlay-element-legend { display: none !important; }

.shn-k3d-stage { position: absolute; inset: 0; overflow: hidden; background: #03090f; }
.shn-k3d-canvas { display: block; touch-action: none; outline: none; }
.shn-k3d-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.shn-k3d-label {
  position: absolute; left: 0; top: 0;
  font-family: var(--shn-font-display);
  font-size: 13px;
  letter-spacing: .06em;
  white-space: nowrap;
  color: var(--shn-bone);
  text-shadow: 0 0 6px #000, 0 0 2px #000;
  opacity: 0;
  transform: translate(-9999px, 0);
  display: none;
  will-change: transform, opacity;
}
.shn-k3d-label.is-on { display: block; }
.shn-k3d-label.is-selected {
  font-size: 15px;
  color: #fff;
  padding: 2px 8px;
  border: 1px solid rgba(232, 227, 213, .35);
  background: rgba(6, 8, 12, .65);
  border-radius: 2px;
}
.shn-k3d-shell-label {
  position: absolute; left: 0; top: 0;
  font-family: var(--shn-font-display);
  font-size: 13px;
  letter-spacing: .3em;
  padding: 1px 8px;
  border-bottom: 1px solid currentColor;
  opacity: 0;
  white-space: nowrap;
  text-shadow: 0 0 10px #000, 0 0 3px #000;
  transition: opacity .4s;
}
.shn-k3d-shell-label[data-layer="original"] { color: #c9a45c; }
.shn-k3d-shell-label[data-layer="derleth"] { color: #7fa8b8; }
.shn-k3d-shell-label[data-layer="trpg"] { color: #9b8fb5; }
.shn-k3d-shell-label[data-layer="none"] { color: #8a8f99; }

.shn-k3d-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--shn-k3d-c, #8a8f99);
  box-shadow: 0 0 6px var(--shn-k3d-c, #8a8f99);
  margin-right: 7px; vertical-align: middle; flex: none;
}

/* ---------- 凡例 ---------- */
.shn-k3d-legend { position: absolute; left: 14px; bottom: 14px; z-index: 4; max-width: 270px; }
.shn-k3d-legend-box {
  font-size: 11.5px;
  color: var(--shn-bone-dim);
  background: rgba(8, 11, 16, .82);
  border: 1px solid var(--shn-hairline);
  border-radius: 3px;
  padding: 8px 12px;
  line-height: 1.85;
  backdrop-filter: blur(3px);
}
.shn-k3d-legend-box summary { cursor: pointer; color: var(--shn-gold); letter-spacing: .14em; }
.shn-k3d-legend-h { margin: 6px 0 0; color: var(--shn-bone); font-size: 11.5px; }
.shn-k3d-legend-row { display: flex; align-items: center; }
.shn-k3d-legend-note { margin: 6px 0 0; line-height: 1.6; opacity: .85; }
.shn-k3d-line { display: inline-block; width: 26px; height: 2px; margin-right: 8px; background: var(--shn-bone-dim); flex: none; }
.shn-k3d-line-thick { height: 3px; }
.shn-k3d-line-long { background: repeating-linear-gradient(90deg, var(--shn-bone-dim) 0 8px, transparent 8px 12px); }
.shn-k3d-line-dash { background: repeating-linear-gradient(90deg, var(--shn-bone-dim) 0 5px, transparent 5px 9px); }
.shn-k3d-line-dot { background: repeating-linear-gradient(90deg, var(--shn-bone-dim) 0 2px, transparent 2px 5px); }

.shn-k3d-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 4;
  font-size: 11.5px; letter-spacing: .08em;
  color: var(--shn-bone-dim);
  background: rgba(8, 11, 16, .7);
  border: 1px solid var(--shn-hairline-soft);
  padding: 5px 12px; border-radius: 2px;
  pointer-events: none;
  animation: shn-k3d-hint-fade 9s ease forwards;
  white-space: nowrap;
}
@keyframes shn-k3d-hint-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

.shn-kinship-notice {
  position: absolute; left: 50%; top: 48px; transform: translateX(-50%);
  z-index: 6; margin: 0;
  font-size: 12.5px; color: var(--shn-bone);
  background: rgba(20, 26, 38, .95);
  border: 1px solid var(--shn-gold-dim);
  padding: 8px 14px; border-radius: 3px;
  max-width: calc(100% - 32px);
}
.shn-kinship-live {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- 情報パネル(選んだ神格の関係と出典) ---------- */
.shn-k3d-info {
  position: absolute; right: 14px; top: 14px; bottom: 14px;
  width: min(360px, calc(100% - 28px));
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(9, 12, 18, .9);
  border: 1px solid var(--shn-hairline);
  border-top: 2px solid var(--shn-k3d-c, var(--shn-gold));
  border-radius: 3px;
  padding: 14px 16px 16px;
  backdrop-filter: blur(5px);
  box-shadow: 0 0 30px rgba(0, 0, 0, .5), 0 0 22px color-mix(in srgb, var(--shn-k3d-c, #c9a45c) 18%, transparent);
  animation: shn-k3d-in .35s ease;
}
@keyframes shn-k3d-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.shn-k3d-info-close {
  float: right;
  background: none; border: 1px solid var(--shn-gold-dim); color: var(--shn-gold);
  font: inherit; font-size: 11px; letter-spacing: .1em;
  padding: 4px 10px; border-radius: 2px; cursor: pointer;
}
.shn-k3d-info-close:hover { background: var(--shn-gold); color: var(--shn-abyss); }
.shn-k3d-info-layer { margin: 2px 0 6px; font-size: 11.5px; letter-spacing: .1em; color: var(--shn-k3d-c, var(--shn-gold)); display: flex; align-items: center; }
.shn-k3d-info-name { font-family: var(--shn-font-display); font-size: 21px; letter-spacing: .08em; margin: 0; color: #fff; outline: none; }
.shn-k3d-info-en { margin: 2px 0 10px; font-family: var(--shn-font-mono); font-size: 11.5px; color: var(--shn-bone-dim); letter-spacing: .06em; }
.shn-k3d-info-summary { margin: 0 0 12px; font-size: 13px; line-height: 1.85; color: var(--shn-bone); }
.shn-k3d-info-h { font-size: 12px; letter-spacing: .14em; color: var(--shn-gold); margin: 12px 0 6px; font-weight: 500; border-bottom: 1px solid var(--shn-hairline-soft); padding-bottom: 4px; }
.shn-k3d-info-empty { font-size: 12.5px; color: var(--shn-bone-dim); margin: 4px 0; }
.shn-k3d-rels { list-style: none; margin: 0; padding: 0; }
.shn-k3d-rel { padding: 8px 0 8px 10px; border-left: 2px solid var(--shn-k3d-c, #8a8f99); margin: 0 0 6px; }
.shn-k3d-rel-btn {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--shn-bone);
}
.shn-k3d-rel-btn:hover .shn-k3d-rel-dir { text-decoration: underline; }
.shn-k3d-rel-kind { display: inline-block; font-size: 11px; letter-spacing: .08em; color: var(--shn-bone-dim); margin-right: 8px; }
.shn-k3d-rel-dir { font-size: 13.5px; }
.shn-k3d-rel-src { margin: 3px 0 0; font-size: 11.5px; color: var(--shn-k3d-c, var(--shn-bone-dim)); display: flex; align-items: center; }
.shn-k3d-rel-src .shn-k3d-dot { width: 6px; height: 6px; margin-right: 6px; }
.shn-k3d-rel-note { margin: 3px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--shn-bone-dim); }
.shn-k3d-info-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.shn-k3d-info-sheet,
.shn-k3d-info-page {
  font: inherit; font-size: 12px; letter-spacing: .08em;
  padding: 7px 12px; border-radius: 2px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--shn-gold-dim); color: var(--shn-gold); background: none;
}
.shn-k3d-info-page { background: var(--shn-gold); color: var(--shn-abyss); border-color: var(--shn-gold); }
.shn-k3d-info-sheet:hover { background: rgba(201, 162, 39, .14); }

/* ---------- 神格一覧(2D・3D共通) ---------- */
.shn-kinship-list {
  position: absolute; left: 14px; top: 14px; bottom: 14px;
  width: min(330px, calc(100% - 28px));
  z-index: 6;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(9, 12, 18, .94);
  border: 1px solid var(--shn-hairline);
  border-radius: 3px;
  padding: 12px 14px 16px;
  backdrop-filter: blur(5px);
}
.shn-kinship-list-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; position: sticky; top: -12px; background: rgba(9, 12, 18, .98); padding: 4px 0 6px; margin-top: -4px; }
.shn-kinship-list-title { font-family: var(--shn-font-display); font-size: 15px; letter-spacing: .12em; margin: 0; color: var(--shn-bone); font-weight: 600; }
.shn-kinship-list-close {
  background: none; border: 1px solid var(--shn-gold-dim); color: var(--shn-gold);
  font: inherit; font-size: 11px; padding: 4px 10px; border-radius: 2px; cursor: pointer;
}
.shn-kinship-list-note { font-size: 11.5px; line-height: 1.7; color: var(--shn-bone-dim); margin: 4px 0 8px; }
.shn-kinship-list-group { margin-top: 12px; }
.shn-kinship-list-layer { display: flex; align-items: center; font-size: 13px; margin: 0; color: var(--shn-k3d-c); font-weight: 600; letter-spacing: .06em; }
.shn-kinship-list-count { margin-left: 6px; font-weight: 400; font-size: 11.5px; color: var(--shn-bone-dim); }
.shn-kinship-list-crit { font-size: 11px; color: var(--shn-bone-dim); margin: 2px 0 6px 16px; line-height: 1.6; }
.shn-kinship-list ul { list-style: none; margin: 0; padding: 0; }
.shn-kinship-list-item {
  display: flex; align-items: baseline; gap: 8px; width: 100%;
  background: none; border: none; border-left: 2px solid transparent;
  padding: 6px 8px; cursor: pointer; text-align: left;
  font: inherit; color: var(--shn-bone);
}
.shn-kinship-list-item:hover,
.shn-kinship-list-item:focus-visible { background: rgba(232, 227, 213, .06); border-left-color: var(--shn-k3d-c); }
.shn-kinship-list-name { font-size: 13.5px; }
.shn-kinship-list-en { font-family: var(--shn-font-mono); font-size: 10.5px; color: var(--shn-bone-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.shn-kinship-list-deg { font-size: 10.5px; color: var(--shn-bone-dim); flex: none; }

/* ---------- スマートフォン幅 ---------- */
@media (max-width: 700px) {
  .shn-kinship-overlay-bar { padding: 8px 10px; gap: 6px; }
  .shn-kinship-overlay-title { font-size: 13px; }
  .shn-kinship-overlay.is-3d .shn-kinship-overlay-toggles { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .shn-kinship-overlay.is-3d .shn-kinship-overlay-toggles button { flex: none; }
  .shn-kinship-overlay-list-btn,
  .shn-kinship-overlay-mode,
  .shn-kinship-overlay-theme,
  .shn-kinship-overlay-close { padding: 6px 9px; letter-spacing: .06em; }
  .shn-k3d-legend { left: 8px; bottom: 8px; max-width: calc(100% - 16px); }
  .shn-k3d-hint { top: 8px; bottom: auto; font-size: 10.5px; white-space: normal; width: calc(100% - 32px); text-align: center; }
  /* 情報パネルは下から出す。上半分で星図が見えるように */
  .shn-k3d-info {
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; max-height: 52%;
    border-radius: 10px 10px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    animation-name: shn-k3d-up;
  }
  .shn-kinship-list { left: 0; right: 0; top: 0; bottom: 0; width: 100%; border-radius: 0; border: none; }
}
@keyframes shn-k3d-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .shn-k3d-info, .shn-k3d-hint, .shn-k3d-shell-label { animation: none !important; transition: none !important; }
}
