@charset "utf-8";

/* ==========================================================================
   自民党 相関図
   配色は日本の選挙・報道の視覚言語から。藍鉄の地に、朱（対立）と藍（支持）。
   ========================================================================== */

:root {
  --ink:        #0E1419;  /* 地。藍鉄 */
  --ink-2:      #141D26;  /* パネル面 */
  --ink-3:      #1B2733;  /* 一段上げた面 */
  --line:       #2A3846;  /* 罫 */
  --paper:      #E9E5DC;  /* 生成り。本文 */
  --paper-dim:  #9AA6B2;  /* 副次テキスト */

  --shu:        #C8442F;  /* 朱 — 対立 */
  --shu-bright: #E85C44;
  --ai:         #4F87BE;  /* 藍 — 支持・推薦 */
  --kincha:     #B08D4F;  /* 金茶 — 人事・後見 */
  --moegi:      #6E9B5B;  /* 萌黄 — 盟友 */
  --murasaki:   #8A6FA8;  /* 紫 — 師弟 */
  --susu:       #55636F;  /* 煤 — 派閥・グループ */

  --f-serif: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --f-sans:  "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;

  --panel-w: 400px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ── レイアウト ───────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr var(--panel-w);
  grid-template-areas: "head head" "stage panel";
  height: 100dvh;
}

/* ── ヘッダ ───────────────────────────────────────────── */
.head {
  grid-area: head;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #121A23, #0E1419);
}

.brand { display: flex; align-items: baseline; gap: 12px; flex: 0 0 auto; }

.brand h1 {
  margin: 0;
  font-family: var(--f-serif);
  font-weight: 900;
  font-size: 21px;
  letter-spacing: .04em;
}
/* 朱の縦罫。新聞の題字脇の罫から */
.brand h1::before {
  content: ""; display: inline-block;
  width: 4px; height: 20px; margin-right: 10px;
  background: var(--shu); vertical-align: -2px;
}
.brand .asof {
  font-size: 12px; color: var(--paper-dim); letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}

.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.search {
  position: relative;
}
.search input {
  width: 190px; padding: 7px 11px 7px 30px;
  background: var(--ink-3); border: 1px solid var(--line); border-radius: 3px;
  outline: none;
}
.search input:focus { border-color: var(--ai); }
.search::before {
  content: "⌕"; position: absolute; left: 10px; top: 5px;
  color: var(--paper-dim); font-size: 15px;
}

.btn {
  padding: 7px 13px;
  background: var(--ink-3); border: 1px solid var(--line);
  border-radius: 3px; cursor: pointer;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--paper-dim); }
.btn:focus-visible { outline: 2px solid var(--ai); outline-offset: 1px; }
.btn.on { background: var(--shu); border-color: var(--shu); color: #fff; }

/* 並べ方の切り替え（連結ボタン） */
.seg { display: flex; }
.seg .seg-btn { border-radius: 0; }
.seg .seg-btn:first-child { border-radius: 3px 0 0 3px; }
.seg .seg-btn:last-child { border-radius: 0 3px 3px 0; margin-left: -1px; }
.seg .seg-btn.on {
  background: var(--ink-3); border-color: var(--paper-dim);
  color: var(--paper); box-shadow: inset 0 -2px 0 var(--shu);
}

/* 地雷モードのボタンだけ質感を変える */
.btn.danger { border-color: #5A2A24; color: var(--shu-bright); }
.btn.danger:hover { border-color: var(--shu); }
.btn.danger.on { background: var(--shu); color: #fff; border-color: var(--shu); }

/* ── グラフ面 ─────────────────────────────────────────── */
.stage { grid-area: stage; position: relative; min-width: 0; }
#cy { width: 100%; height: 100%; background: var(--ink); }

/* 凡例 */
.legend {
  position: absolute; left: 12px; bottom: 12px;
  background: rgba(20, 29, 38, .9);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 8px 10px; max-width: 268px;
  backdrop-filter: blur(6px);
}
.legend > summary {
  margin: 0; font-size: 10px; letter-spacing: .1em;
  color: var(--paper-dim); font-weight: 700; cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.legend > summary::-webkit-details-marker { display: none; }
.legend > summary::before {
  content: "▾"; font-size: 9px; transition: transform .15s;
}
.legend:not([open]) > summary::before { transform: rotate(-90deg); }
.legend[open] > summary { margin-bottom: 6px; }
.legend > summary:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
.legend .rows { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.legend .row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; cursor: pointer; user-select: none;
  padding: 1px 0; opacity: .95; white-space: nowrap;
}
.legend .row.off { opacity: .32; }
.legend .row:hover { opacity: 1; }
.legend .swatch { width: 20px; height: 0; border-top-width: 3px; border-top-style: solid; }
.legend .swatch.dash { border-top-style: dashed; }

.hint {
  position: absolute; right: 14px; bottom: 14px;
  font-size: 11.5px; color: var(--paper-dim);
  background: rgba(20, 29, 38, .9);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 11px;
}
kbd {
  background: var(--ink-3); border: 1px solid var(--line);
  border-radius: 3px; padding: 0 5px; font-size: 11px;
  font-family: var(--f-sans);
}

/* カーソルを合わせたときの吹き出し */
.tip {
  position: fixed; top: 0; left: 0; z-index: 60;
  max-width: 320px; padding: 9px 12px;
  background: rgba(11, 17, 22, .97);
  border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .12s;
}
.tip.on { opacity: 1; }
.tip-h {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-bottom: 5px;
}
.tip-h .k { font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.tip-h .p { font-size: 12.5px; font-weight: 700; color: var(--paper); }
.tip-b { font-size: 12.5px; line-height: 1.6; color: #CFC9BF; }
.tip-f {
  margin-top: 6px; font-size: 10.5px; color: var(--paper-dim);
  letter-spacing: .04em;
}

@media (hover: none) {
  .tip { display: none; }   /* 触って操作する画面では邪魔になる */
}

/* ── サイドパネル ─────────────────────────────────────── */
.panel {
  grid-area: panel;
  border-left: 1px solid var(--line);
  background: var(--ink-2);
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }

.pad { padding: 18px 20px; }

.empty { color: var(--paper-dim); font-size: 13.5px; line-height: 1.9; }
.empty strong { color: var(--paper); font-weight: 500; }
.empty ul { padding-left: 1.1em; margin: 10px 0; }
.empty li { margin: 5px 0; }

/* 人物ヘッダ */
.person { display: flex; gap: 14px; align-items: flex-start; }
.person .face {
  width: 76px; height: 76px; border-radius: 50%;
  object-fit: cover; flex: 0 0 auto;
  border: 2px solid var(--line);
  background: var(--ink-3);
}
.person .face.ph {
  display: grid; place-items: center;
  font-family: var(--f-serif); font-size: 26px; color: var(--paper-dim);
}
.person .meta { min-width: 0; flex: 1; }
.person h2 {
  margin: 2px 0 4px;
  font-family: var(--f-serif); font-weight: 900; font-size: 22px;
  letter-spacing: .03em; line-height: 1.25;
}
.person .role { font-size: 13px; color: var(--shu-bright); line-height: 1.5; }
.person .sub {
  margin-top: 6px; font-size: 12px; color: var(--paper-dim); line-height: 1.7;
  font-variant-numeric: tabular-nums;
}

/* 党籍が通常と異なる場合の但し書き */
.party-note {
  margin-top: 12px; padding: 9px 11px;
  border: 1px solid var(--line); border-left: 3px solid var(--kincha);
  border-radius: 3px; background: var(--ink-3);
  font-size: 12px; line-height: 1.7; color: #C9C3B8;
}
.party-note .lbl {
  display: inline-block; margin-right: 8px;
  color: var(--kincha); font-weight: 700; font-size: 11px;
  letter-spacing: .08em;
}

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 2px;
  border: 1px solid var(--line); color: var(--paper-dim);
}
.tag.fac { border-color: currentColor; }

.links { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.links a {
  font-size: 12px; color: var(--ai); text-decoration: none;
  border-bottom: 1px solid rgba(79, 135, 190, .4); padding-bottom: 1px;
}
.links a:hover { border-bottom-color: var(--ai); }

/* 見出し */
.sec-title {
  margin: 22px 0 10px; font-size: 11px; letter-spacing: .14em;
  color: var(--paper-dim); font-weight: 700;
  display: flex; align-items: center; gap: 9px;
}
.sec-title::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.sec-title .n {
  font-variant-numeric: tabular-nums; color: var(--paper);
  background: var(--ink-3); border-radius: 2px; padding: 1px 6px;
  letter-spacing: 0;
}

/* 関係カード */
.rel {
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: 3px; padding: 11px 13px; margin-bottom: 9px;
  background: var(--ink-3);
  cursor: pointer; transition: border-color .15s, transform .1s;
}
.rel:hover { transform: translateX(2px); }
.rel:focus-visible { outline: 2px solid var(--ai); outline-offset: 1px; }
.rel .who {
  font-size: 13px; font-weight: 700; margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.rel .arrow { color: var(--paper-dim); font-size: 11px; }
.rel .kind {
  font-size: 10px; padding: 1px 6px; border-radius: 2px;
  border: 1px solid currentColor;
}
.rel .lab { font-size: 12.5px; color: var(--paper-dim); line-height: 1.65; }

/* 関係の詳細 */
.detail-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-head .kind-badge {
  font-size: 11px; padding: 3px 9px; border-radius: 2px;
  border: 1px solid currentColor; font-weight: 700;
}
.detail-head .period {
  font-size: 12px; color: var(--paper-dim); font-variant-numeric: tabular-nums;
}
.pair {
  display: flex; align-items: center; gap: 10px; margin: 14px 0;
}
.pair .p {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 1; min-width: 0; cursor: pointer;
}
.pair img, .pair .ph {
  width: 54px; height: 54px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--line); background: var(--ink-3);
}
.pair .ph { display: grid; place-items: center; font-family: var(--f-serif); }
.pair .nm { font-size: 12px; text-align: center; line-height: 1.3; }
.pair .mid { font-size: 20px; flex: 0 0 auto; }

.detail-label {
  font-family: var(--f-serif); font-weight: 700; font-size: 16px;
  line-height: 1.55; margin: 14px 0 8px;
}
.detail-text { font-size: 13.5px; line-height: 1.9; color: #D3CEC4; }

/* 出典 */
.src {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: 3px;
  padding: 10px 12px; margin-bottom: 8px;
  transition: border-color .15s, background .15s;
}
.src:hover { border-color: var(--ai); background: var(--ink-3); }
.src:focus-visible { outline: 2px solid var(--ai); outline-offset: 1px; }
.src .t { font-size: 12.5px; line-height: 1.6; color: var(--paper); }
.src .m {
  font-size: 11px; color: var(--paper-dim); margin-top: 5px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.src .m .pub { color: var(--ai); }
.src .m .arch {
  border: 1px solid var(--kincha); color: var(--kincha);
  border-radius: 2px; padding: 0 5px; font-size: 10px;
}
.src .m .host {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 200px; opacity: .7;
}

/* 地雷パネル */
.mine {
  border: 1px solid #5A2A24; border-radius: 4px;
  background: linear-gradient(180deg, rgba(200,68,47,.10), rgba(200,68,47,.03));
  padding: 13px 14px; margin-top: 6px;
}
.mine h3 {
  margin: 0 0 9px; font-size: 12px; letter-spacing: .1em;
  color: var(--shu-bright); font-weight: 700;
  display: flex; align-items: center; gap: 7px;
}
.mine ul { margin: 0; padding-left: 1.15em; }
.mine li { font-size: 12.5px; line-height: 1.75; margin: 7px 0; }
.mine li b { color: var(--paper); font-weight: 700; }
.mine .none { font-size: 12.5px; color: var(--paper-dim); line-height: 1.7; }
.mine li { cursor: pointer; }
.mine li:hover b { color: var(--shu-bright); }

/* 相手のいない論点 */
.topic {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed rgba(200, 68, 47, .28);
}
.topic .tp {
  font-size: 12px; font-weight: 700; color: var(--shu-bright);
  margin-bottom: 4px;
}
.topic .tp::before { content: "◆ "; opacity: .7; }
.topic .tn { font-size: 12.5px; line-height: 1.75; color: #C9C3B8; }
.topic .ts { margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }
.topic .ts a {
  font-size: 11px; color: var(--ai); text-decoration: none;
  border-bottom: 1px solid rgba(79, 135, 190, .35);
}
.topic .ts a:hover { border-bottom-color: var(--ai); }

/* 注記 */
.note {
  margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--paper-dim); line-height: 1.85;
}
.note a { color: var(--ai); }

/* ── 読み込み ─────────────────────────────────────────── */
.boot {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--ink); z-index: 20; transition: opacity .4s;
}
.boot .t { font-family: var(--f-serif); font-size: 15px; letter-spacing: .1em; color: var(--paper-dim); }
.boot.gone { opacity: 0; pointer-events: none; }

.boot-err {
  max-width: 520px; padding: 26px 30px; text-align: left;
  border: 1px solid var(--line); border-left: 3px solid var(--shu);
  border-radius: 4px; background: var(--ink-2);
}
.boot-err .ttl {
  font-family: var(--f-serif); font-weight: 900; font-size: 18px;
  margin-bottom: 12px;
}
.boot-err p { font-size: 13.5px; line-height: 1.9; color: #C9C3B8; margin: 0 0 10px; }
.boot-err pre {
  background: var(--ink); border: 1px solid var(--line); border-radius: 3px;
  padding: 11px 13px; font-size: 12.5px; color: var(--paper);
  overflow-x: auto; margin: 12px 0;
}

/* ── 応答（狭い画面） ─────────────────────────────────── */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "head" "stage" "panel";
  }
  /* ヘッダは2段にして、操作系を横いっぱいに置く */
  .head { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .brand { width: 100%; }
  .brand h1 { font-size: 18px; }
  .brand h1::before { height: 17px; margin-right: 8px; }
  .tools { margin-left: 0; width: 100%; gap: 6px; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .btn { padding: 7px 10px; font-size: 13px; }
  .seg { flex: 1; }
  .seg .seg-btn { flex: 1; }

  .panel { border-left: none; border-top: 1px solid var(--line); max-height: 48dvh; }
  .pad { padding: 15px 16px; }
  .legend { max-width: 62vw; }
  .legend .rows { grid-template-columns: 1fr; }
  .hint { display: none; }
}

/* 画面が狭いときは凡例をたたんでおく（JSで open を外す） */
@media (max-width: 640px) {
  .wide { display: none; }   /* ボタンの語尾を落として1行に収める */
  .brand .asof { font-size: 11px; }
  .person .face { width: 62px; height: 62px; }
  .person h2 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 注記の下のリンク列 */
.note-links {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 9px;
}
.note-links a {
  font-size: 11.5px; color: var(--ai); text-decoration: none;
  border-bottom: 1px solid rgba(79, 135, 190, .35); padding-bottom: 1px;
}
.note-links a:hover { border-bottom-color: var(--ai); }
