/* Guildrun Wiki — 共通スタイル */
:root {
  --bg: #12141c;
  --bg2: #1a1d29;
  --bg3: #232738;
  --panel: #1e2230;
  --border: #363c52;
  --text: #e8e6df;
  --text-dim: #9aa0b5;
  --accent: #e8b34b;
  --accent2: #7ec4e8;
  --link: #8ecbff;

  /* レア度 */
  --rar-common: #b8bdc9;
  --rar-rare: #5da9ff;
  --rar-epic: #c47aff;
  --rar-legendary: #ffb43a;
  --rar-unique: #ff7a5c;

  /* キーワード色 (ゲーム内準拠のイメージ) */
  --kw-attack: #ff9c6b;
  --kw-magic: #c99bff;
  --kw-maxhp: #7ee081;
  --kw-defense: #ffd97a;
  --kw-attackspeed: #ffe37a;
  --kw-crit: #ff8181;
  --kw-mana: #7ab8ff;
  --kw-hps: #8fe89b;
  --kw-shield: #bfe3ff;
  --kw-rush: #ffca6b;
  --kw-stall: #a9b6ff;
  --kw-poison: #9ee86b;
  --kw-frost: #8ae2ff;
  --kw-burn: #ff9c5c;
  --kw-shard: #6be8d8;
  --kw-stun: #ffd76b;
  --kw-stealth: #c9c9e8;
  --kw-omnivamp: #ff9cd8;
  --kw-debuff: #d88aff;
  --kw-taunt: #ffb08a;
  --kw-backup: #9cdbff;
  --kw-class: #e8b34b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
}
:lang(en) body, body:lang(en) {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== header ===== */
.site-header {
  background: linear-gradient(180deg, #1c2030, #161927);
  border-bottom: 2px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-height: 56px;
}
.site-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.site-title a { color: var(--accent); }
.site-title .sub { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-left: 6px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}
.nav a:hover { background: var(--bg3); text-decoration: none; }
.nav a.active { background: var(--bg3); color: var(--accent); }
.lang-switch { margin-left: auto; font-size: 13px; color: var(--text-dim); }
.lang-switch a { padding: 4px 8px; border-radius: 4px; }
.lang-switch a.active { color: var(--accent); font-weight: 700; }

/* ===== layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 24px; margin: 8px 0 4px; }
h2 { font-size: 19px; margin: 26px 0 10px; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.page-desc { color: var(--text-dim); font-size: 13.5px; margin-bottom: 14px; }

/* クラスへ移動（クラス一覧ページ先頭・アイコン+名前の横並びチップ） */
.class-jump { position: sticky; top: 58px; z-index: 20; background: var(--bg); padding: 12px 0 10px; margin-bottom: 8px; box-shadow: 0 6px 8px -8px rgba(0,0,0,.6); }
.class-jump-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.class-jump-chips .chip { text-decoration: none; }
/* sticky なジャンプ先アンカーが固定ヘッダ+選択バーに隠れないよう余白を確保 */
#app > [id^="class-"] { scroll-margin-top: 150px; }

/* ===== filters ===== */
.filters {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.filter-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 5.5em;
  padding-top: 5px;
}
.chiplist { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all .12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #1a1505; font-weight: 700; }
.chip img { width: 18px; height: 18px; object-fit: contain; }
.search-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  width: 240px;
  max-width: 100%;
}
.result-count { font-size: 12.5px; color: var(--text-dim); margin-left: auto; align-self: center; }
.filter-reset {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.filter-reset:hover { color: var(--text); border-color: var(--text-dim); }

/* ===== hero cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  gap: 12px;
  color: var(--text);
  transition: border-color .12s, transform .12s;
}
.hero-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.hero-card .portrait {
  width: 72px; height: 72px;
  border-radius: 8px;
  background: var(--bg3);
  object-fit: cover;
  flex-shrink: 0;
}
.hero-card .info { min-width: 0; }
.hero-card .name { font-weight: 800; font-size: 16px; }
.hero-card .classes { font-size: 12.5px; color: var(--accent2); margin: 1px 0 5px; }
/* 職業名の先頭に付く職業アイコン（ヒーロー一覧カード・詳細ヘッダ共通） */
.classes .cls-ic { width: 16px; height: 16px; object-fit: contain; vertical-align: -3px; margin-right: 3px; }
.hero-head .classes .cls-ic { width: 18px; height: 18px; vertical-align: -4px; }
.hero-card .tags { display: flex; gap: 4px; flex-wrap: wrap; }

.tagchip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* ===== tables ===== */
.table-wrap { overflow-x: auto; }
table.stats {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
}
table.stats th, table.stats td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: right;
  white-space: nowrap;
}
table.stats th { background: var(--bg3); font-weight: 700; text-align: center; }
table.stats td:first-child, table.stats th:first-child { text-align: left; }
table.stats tr:hover td { background: rgba(255,255,255,0.025); }

/* ===== rank badges ===== */
.rank-badge {
  display: inline-block;
  width: 26px; height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 6px;
  font-weight: 800;
  font-size: 14px;
}
.rank-C { background: #4a5165; color: #d8dce8; }
.rank-B { background: #3e6e4e; color: #c9f2d4; }
.rank-A { background: #7a5ec4; color: #e8dcff; }
.rank-S { background: #c49a3a; color: #fff3d1; }

/* ===== ability / skill blocks ===== */
.ability {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 8px 0;
  display: flex;
  gap: 12px;
}
.ability .icon { width: 48px; height: 48px; border-radius: 8px; background: var(--bg3); object-fit: contain; flex-shrink: 0; }
.ability .body { min-width: 0; }
.ability .name { font-weight: 700; font-size: 15px; }
.ability .kind { font-size: 11.5px; color: var(--text-dim); margin-left: 8px; }
.ability .desc { font-size: 13.5px; color: var(--text); margin-top: 3px; }

/* 永続強化ページ */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; margin: 10px 0 24px; }
.perm-item { position: relative; }
.perm-item > .ability { margin: 0; height: 100%; cursor: pointer; }
.perm-item:hover > .ability, .perm-item.open > .ability { border-color: var(--accent); }
.perm-pop {
  display: none; position: absolute; z-index: 40; left: 0; top: calc(100% - 4px);
  min-width: 220px; max-width: 340px;
  background: var(--bg2); border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px; box-shadow: 0 10px 24px -6px rgba(0,0,0,.7);
}
.perm-item:hover .perm-pop, .perm-item.open .perm-pop { display: block; }
.perm-pop-title { font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.perm-pop-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.perm-hero { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; text-decoration: none; color: var(--text); }
.perm-hero:hover { background: var(--bg3); }
.perm-hero img { width: 34px; height: 34px; border-radius: 6px; background: var(--bg3); object-fit: cover; flex-shrink: 0; }
.perm-hero-name { font-size: 13px; font-weight: 600; }
.perm-hero-via { font-size: 11px; color: var(--text-dim); margin-left: auto; padding-left: 8px; white-space: nowrap; }

/* 同名アビリティ（例:「愛しき者」）のテキスト参照: ホバーで顔写真+名前ポップアップ、各キャラページへリンク */
.hero-ref { position: relative; cursor: help; border-bottom: 1px dotted var(--accent2); }
.hero-ref-pop {
  display: none; position: absolute; z-index: 60; left: 0; top: calc(100% + 4px);
  min-width: 170px; max-width: 300px;
  background: var(--bg2); border: 1px solid var(--accent); border-radius: 10px;
  padding: 8px; box-shadow: 0 10px 24px -6px rgba(0,0,0,.7);
  white-space: normal; font-weight: 400; flex-direction: column; gap: 4px;
}
.hero-ref:hover > .hero-ref-pop, .hero-ref:focus-within > .hero-ref-pop { display: flex; }
/* 永続強化ページ: 名前参照にホバー中はカードのポップアップを隠して二重表示を防ぐ */
.perm-item:has(.hero-ref:hover) > .perm-pop { display: none; }

/* item / relic cards */
.icard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  gap: 12px;
}
.icard .icon { width: 56px; height: 56px; border-radius: 8px; background: var(--bg3); object-fit: contain; flex-shrink: 0; }
.icard .name { font-weight: 700; font-size: 15px; }
.icard .meta { font-size: 12px; color: var(--text-dim); margin: 1px 0 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icard .desc { font-size: 13px; }
.icard .stats-line { font-size: 12.5px; margin-top: 4px; color: var(--accent2); }

.rarity { font-weight: 700; }
.rarity-1 { color: var(--rar-common); }
.rarity-2 { color: var(--rar-rare); }
.rarity-3 { color: var(--rar-epic); }
.rarity-4 { color: var(--rar-legendary); }
.rarity-5 { color: var(--rar-unique); }

/* ===== keyword rich text ===== */
.kw { font-weight: 700; }
.kw-attack { color: var(--kw-attack); }
.kw-magic { color: var(--kw-magic); }
.kw-maxhp, .kw-maxhealth, .kw-health, .kw-hp { color: var(--kw-maxhp); }
.kw-defense { color: var(--kw-defense); }
.kw-attackspeed { color: var(--kw-attackspeed); }
.kw-crit { color: var(--kw-crit); }
.kw-mana, .kw-managen { color: var(--kw-mana); }
.kw-hps, .kw-hp\/s { color: var(--kw-hps); }
.kw-shield, .kw-lasting { color: var(--kw-shield); }
.kw-rush { color: var(--kw-rush); }
.kw-stall { color: var(--kw-stall); }
.kw-poison { color: var(--kw-poison); }
.kw-frost { color: var(--kw-frost); }
.kw-burn { color: var(--kw-burn); }
.kw-shard, .kw-generate { color: var(--kw-shard); }
.kw-stun { color: var(--kw-stun); }
.kw-stealth { color: var(--kw-stealth); }
.kw-omnivamp { color: var(--kw-omnivamp); }
.kw-debuff { color: var(--kw-debuff); }
.kw-taunt { color: var(--kw-taunt); }
.kw-backup, .kw-backuponly, .kw-reserve { color: var(--kw-backup); }
.kw-class, .kw-rank, .kw-primarystat { color: var(--kw-class); }
.kw-warrior { color: #ff9c6b; }
.kw-tank { color: #ffd97a; }
.kw-vanguard { color: #7ee081; }
.kw-assassin { color: #ff8181; }
.kw-duelist { color: #ffca6b; }
.kw-mystic { color: #8ae2ff; }
.kw-mage { color: #c99bff; }
.kw-bold { color: var(--text); }
.kw-damage { color: var(--kw-attack); }
.kw-quest { color: var(--accent); }
.kw-statcalc { color: var(--accent2); }
[class*="kw-statcalc"] { color: var(--accent2); }

/* ===== hero detail ===== */
.hero-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; }
/* 全身立ち絵は縦長なので、縦長ボックス+contain で全身が切れずに収まるようにする */
.hero-head .portrait { width: 200px; height: 300px; border-radius: 12px; background: var(--bg3); object-fit: contain; object-position: center; }
.hero-head .lead { flex: 1; min-width: 260px; }
.hero-head .alias { color: var(--text-dim); font-size: 13.5px; font-style: italic; }
.hero-head .classes { color: var(--accent2); font-weight: 700; margin: 2px 0 8px; }
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.spec {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.spec .name { font-weight: 800; color: var(--accent); }
.spec .tags { margin: 2px 0 6px; }

.backlink { font-size: 13px; }

.note { font-size: 12.5px; color: var(--text-dim); background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }

.footer { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 50px; border-top: 1px solid var(--border); padding-top: 16px; }

@media (max-width: 640px) {
  .filter-label { min-width: 100%; padding-top: 0; }
  .hero-head .portrait { width: 150px; height: 225px; }
}
