/* Scoped codex: independent of legacy homepage artwork and rem scaling. */
/* Full-page guide: same paper and jade palette as the news index.
   Deliberately scoped so homepage dialogs retain their existing appearance. */
.factions-page-body main { display: block; height: auto; overflow: visible; }
.factions-page-body .news-index-container { width: min(1180px, calc(100% - 32px)); max-width: 1180px; }
.factions-page-body .news-index-heading > p { max-width: 730px; line-height: 1.7; }
.factions-page-body .kl-factions-page {
  display: block; position: relative; inset: auto; width: 100%; max-width: none;
  height: auto; min-height: 0; max-height: none; overflow: visible;
  margin: 0; padding: 0; color: #243f49;
  border: 1px solid #bed4cc; border-radius: 20px;
  background: #fffcf2; box-shadow: 0 22px 60px rgb(41 82 79 / 13%);
}
.factions-page-body .kl-factions-page .codex-header {
  position: static; padding: 22px 26px; border-radius: 20px 20px 0 0;
  background: #f1f6eb; border-bottom: 1px solid #cdded3;
}
.factions-page-body .kl-factions-page .codex-header h2 { color: #1d4650; font-size: 23px; }
.kl-factions-page .codex-layout { padding: 24px; gap: 24px; grid-template-columns: 190px minmax(0, 1fr); align-items: start; }
.kl-factions-page #faction-submenu { padding: 10px; background: #edf4ed; border: 1px solid #d2e0d5; border-radius: 12px; }
.kl-factions-page #faction-menu-list { gap: 5px; }
.kl-factions-page .module-subbutton { color: #375e61; background: transparent; border-color: transparent; padding: 10px 12px; font-weight: 600; }
.kl-factions-page .module-subbutton:hover { background: #deede4; }
.kl-factions-page .module-subbutton.active { color: white; border-color: #247d78; background: linear-gradient(135deg, #247d78, #43978f); box-shadow: 0 3px 9px #267e7826; }
.kl-factions-page .faction-hero { padding: 24px; background: linear-gradient(120deg, #e1f0e8, #f6f6e8); border-color: #b8d3c7; border-radius: 12px; }
.kl-factions-page #faction-name { color: #175951; font-size: 32px; }
.kl-factions-page #faction-combat { color: #2a6a61; background: #ffffffa6; border-color: #b8d3c7; margin: 8px 0 10px; }
.kl-factions-page #faction-summary { color: #4f6c69; }
.kl-factions-page .faction-books { margin: 24px 0 20px; }
.kl-factions-page .faction-books h3 { color: #285c59; }
.kl-factions-page .book-choice { min-height: 96px; padding: 12px 6px; color: #3a5654; border-color: #d6ddd0; background: #fffef9; transition: background .18s ease, border-color .18s ease; }
.kl-factions-page .book-choice:hover { border-color: #72a99b; background: #f0f7ee; }
.kl-factions-page button[aria-pressed="true"] { color: #165c51; border-color: #438d7d; background: #e2f0e5; box-shadow: inset 0 0 0 1px #438d7d; }
.kl-factions-page label { color: #365d5c; }
.kl-factions-page input { background: #fffef9; color: #243f49; border-color: #bfcfc5; }
.kl-factions-page input::placeholder { color: #7d918c; opacity: 1; }
.kl-factions-page .faction-link { background: #e6f0e5; color: #28675d; border-color: #91b7a8; }
.kl-factions-page .result-note { color: #386b61; }
.kl-factions-page .book-page { border-color: #d2d6bc; border-radius: 12px; overflow: hidden; }
.kl-factions-page .book-page-heading { padding: 16px; background: #eaf1e4; }
.kl-factions-page .book-page-heading h3 { color: #2c625a; }
.kl-factions-page #skill-count { color: #647d70; }
.kl-factions-page .book-ledger { background: #fffdf5; color: #41534a; }
.kl-factions-page .ledger-heading { background: #e8e5ce; color: #68613b; letter-spacing: .04em; }
.kl-factions-page .book-summary-content { padding: 20px; }
.kl-factions-page .book-description { line-height: 1.8; }
.kl-factions-page .skill-row { border-color: #e1e4d5; }
.kl-factions-page .skill-choice { border-color: #e1e4d5; background: #f5f6eb; color: #365e52; }
.kl-factions-page .skill-effect { line-height: 1.75; }
.kl-factions-page .skill-requirement { color: #7a8067; }
.kl-factions-page button:focus-visible, .kl-factions-page input:focus-visible { outline-color: #247d78; }
.factions-page-body .site-footer { position: relative; clear: both; margin-top: 0; }
@media (max-width: 800px) {
  .kl-factions-page .codex-layout { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 18px; }
  .kl-factions-page #faction-menu-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kl-factions-page .module-subbutton { text-align: center; font-size: 13px; padding: 10px 4px; }
  .factions-page-body .kl-factions-page .codex-header { padding: 18px; }
  .kl-factions-page .faction-hero { padding: 18px; }
}
@media (max-width: 420px) {
  .factions-page-body .news-index-container { width: calc(100% - 20px); }
  .kl-factions-page .codex-layout { padding: 12px; }
  .kl-factions-page #faction-menu-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.factions-body { background: #101c2b; }
.factions-intro { max-width: 1160px; margin: 0 auto; padding: 48px 24px 28px; color: #dbe5ef; }
.factions-intro > p:first-child { color: #efc67b; font-size: 12px; font-weight: 700; letter-spacing: 2px; }
.factions-intro h1 { margin: 12px 0; color: #ffe1a0; font-size: clamp(28px, 5vw, 46px); line-height: 1.2; }
.factions-intro > p:last-child { max-width: 720px; line-height: 1.7; }
#mon-phai { scroll-margin-top: calc(var(--home-nav-height, var(--thiennu-nav-height, 90px)) + 16px); }
.faction-launch {
  position: relative; z-index: 20; isolation: isolate; overflow: hidden;
  display: block; max-width: 94%; margin: 12px auto; padding: 8px 16px;
  border: 1px solid #ffe19a; border-radius: 7px;
  background: linear-gradient(115deg, #8c240c, #c24712 55%, #922509);
  color: #fff1bc; font: 700 20px/1.35 Arial,sans-serif; text-align: center;
  text-shadow: 0 1px 1px #581704; cursor: pointer;
  box-shadow: 0 2px 0 #652009, 0 0 6px #ffa32166;
  animation: faction-beacon 2.8s cubic-bezier(.45, 0, .55, 1) infinite;
  transition: filter .35s ease-in-out, border-color .35s ease-in-out;

}
.faction-launch::before {
  content: "✦"; display: inline-block; margin-right: 6px; color: #ffdb72;
  text-shadow: 0 0 4px #ffc655; animation: faction-star 2.8s ease-in-out infinite;
}
.faction-launch::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  top: -40%; left: -65%; width: 24%; height: 180%;
  background: linear-gradient(90deg, transparent, #ffe6a85c, transparent);
  transform: skewX(-22deg); animation: faction-shine 4s cubic-bezier(.4, 0, .2, 1) infinite;
}
.faction-launch:hover { filter: brightness(1.12); border-color: #fff; }
.faction-launch:focus-visible { outline: 3px solid #8a2b08; outline-offset: 6px; }
.faction-launch:active { filter: brightness(.96); }
@keyframes faction-beacon {
  0%, 100% { box-shadow: 0 2px 0 #652009, 0 0 4px #ffa32144; }
  50% { box-shadow: 0 2px 0 #652009, 0 0 10px #ffc65599; }
}
@keyframes faction-star { 0%, 100% { opacity: .75; } 50% { opacity: 1; text-shadow: 0 0 5px #ffe19a; } }
@keyframes faction-shine { 0%, 35% { left: -65%; } 75%, 100% { left: 140%; } }
@media (prefers-reduced-motion: reduce) {
  .faction-launch, .faction-launch::before, .faction-launch::after { animation: none; }
  .faction-launch::after { display: none; }
}
.page5 .faction-launch { position: absolute; top: 164px; left: 50%; transform: translateX(-50%); margin: 0; }
.kl-factions { box-sizing: border-box; width: min(1160px, 96vw); max-width: 96vw; height: min(900px, 92vh); max-height: 92vh; margin: auto; padding: 0; border: 1px solid #ad8544; border-radius: 14px; background: #1d293b; color: #edf2fa; font: 15px/1.55 Arial,sans-serif; text-align: left; }
.kl-factions::backdrop { background: #07111bcc; }
.kl-factions *, .kl-factions *::before, .kl-factions *::after { box-sizing: border-box; }
.kl-factions [hidden] { display: none !important; }
.kl-factions h2, .kl-factions h3, .kl-factions h4, .kl-factions h5, .kl-factions p, .kl-factions dl, .kl-factions dd { margin: 0; padding: 0; }
.kl-factions button, .kl-factions input { font: inherit; }
.kl-factions button { cursor: pointer; }
.kl-factions button:focus-visible, .kl-factions input:focus-visible { outline: 3px solid #f4cd74; outline-offset: 3px; }
.kl-factions .codex-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; background: #1d293b; border-bottom: 1px solid #52617a; }
.kl-factions .codex-header h2 { font-size: 22px; color: #ffe1a0; }
.kl-factions .codex-close { padding: 8px 14px; border: 1px solid #79869a; border-radius: 6px; background: transparent; color: white; }
.kl-factions .codex-layout { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 20px; padding: 20px; }
.kl-factions #faction-menu-list { display: grid; gap: 6px; }
.kl-factions .module-subbutton { width: 100%; padding: 9px 12px; text-align: left; border: 1px solid #50617c; border-radius: 6px; color: #edf2fa; background: #293a51; }
.kl-factions .module-subbutton.active, .kl-factions button[aria-pressed="true"] { border-color: #efbe5c; background: #514535; color: #ffe1a0; }
.kl-factions .faction-panel { min-width: 0; }
.kl-factions .faction-hero { padding: 18px; border: 1px solid #8c744e; border-radius: 10px; background: linear-gradient(120deg,#314b62,#263247); }
.kl-factions #faction-name { font-size: 30px; color: #ffd57b; }
.kl-factions #faction-combat { display: inline-block; padding: 2px 8px; margin: 5px 0 8px; border: 1px solid #8c744e; border-radius: 4px; color: #ffe1a0; }
.kl-factions .faction-books { margin: 16px 0; }
.kl-factions .faction-books h3 { margin-bottom: 8px; font-size: 18px; color: #ffd57b; }
.kl-factions .book-list { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.kl-factions .book-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 9px 4px; min-width: 0; border: 1px solid #62718a; border-radius: 7px; background: #192436; color: #f4f6fc; font-size: 13px; }
.kl-factions .codex-icon { display: inline-block; width: 44px; height: 44px; flex-shrink: 0; background-repeat: no-repeat; border: 1px solid #c09648; border-radius: 7px; vertical-align: middle; }
.kl-factions .codex-icon-placeholder { text-align: center; line-height: 44px; background: #293a51; color: #ffe1a0; }
.kl-factions .skill-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 12px; }
.kl-factions .skill-search { flex: 1; min-width: 150px; }
.kl-factions label { display: block; margin-bottom: 4px; font-weight: 600; }
.kl-factions input { width: 100%; height: 42px; padding: 8px 10px; border: 1px solid #62718a; border-radius: 6px; background: #152235; color: white; }
.kl-factions .skill-level-control { width: 135px; }
.kl-factions .faction-link { padding: 9px 12px; border: 1px solid #c09648; border-radius: 6px; background: #293a51; color: #ffe1a0; }
.kl-factions .result-note { padding: 10px 0; color: #ffe1a0; }
.kl-factions .book-page { border: 1px solid #c09648; }
.kl-factions .book-page-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.kl-factions .book-page-heading h3 { font-size: 19px; color: #ffd57b; }
.kl-factions #skill-count { white-space: nowrap; font-size: 13px; }
.kl-factions .book-ledger { background: #faf2df; color: #583613; }
.kl-factions .ledger-heading { padding: 7px 10px; background: #e8bf68; color: #4b2d0d; font-size: 13px; text-transform: uppercase; }
.kl-factions .book-summary-content { padding: 16px; }
.kl-factions .book-cover-icon { text-align: center; }
.kl-factions .book-cover-icon .codex-icon { width: 64px; height: 64px; }
.kl-factions .book-level { text-align: center; margin: 8px 0; }
.kl-factions .book-description { margin-top: 10px; }
.kl-factions .skill-table-heading, .kl-factions .skill-row { display: grid; grid-template-columns: 160px minmax(0,1fr); }
.kl-factions .skill-row { border-top: 1px solid #ddc493; }
.kl-factions .skill-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 10px; text-align: center; border-right: 1px solid #ddc493; }
.kl-factions .skill-icons { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.kl-factions .skill-requirement { font-size: 12px; }
.kl-factions .skill-effect { padding: 14px 16px; overflow-wrap: anywhere; }
.kl-factions .skill-effect p + p, .kl-factions .skill-effect h5 { margin-top: 8px; }
.kl-factions .skill-stats { margin-bottom: 8px; }
.kl-factions .skill-stats div { display: flex; gap: 5px; }
.kl-factions .skill-stats dd { font-weight: bold; }
.kl-factions .skill-empty { padding: 24px; }
.kl-factions .skill-level-note { color: #8a4918; font-weight: bold; margin-bottom: 10px; }
@media(max-width: 700px) {
  .kl-factions { width: 96vw; height: 94dvh; max-height: 94dvh; font-size: 14px; }
  .kl-factions .codex-layout { grid-template-columns: minmax(0,1fr); padding: 12px; gap: 14px; }
  .kl-factions #faction-menu-list { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
  .kl-factions .module-subbutton { padding: 8px 4px; text-align: center; font-size: 12px; }
  .kl-factions .codex-header { padding: 12px; }
  .kl-factions .codex-header h2 { font-size: 18px; }
  .kl-factions .book-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .kl-factions .skill-table-heading, .kl-factions .skill-row { grid-template-columns: 105px minmax(0,1fr); }
  .kl-factions .skill-effect { padding: 12px 10px; }
  .kl-factions .book-page-heading { flex-wrap: wrap; }
  .faction-launch { font-size: 14px; padding: 7px 12px; }
}
.kl-factions.kl-factions-page { display: block; height: auto; max-height: none; margin: 0 auto 48px; overflow: visible; }
.kl-factions-page .codex-header { position: static; border-radius: 14px 14px 0 0; }
/* Mountain artwork shared by the standalone guide and homepage dialog. */
body #kl-factions.kl-factions #faction-detail > .faction-hero {
  box-sizing: border-box;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 26px 30px;
  overflow: hidden;
  border: 1px solid #a68b59;
  border-radius: 10px;
  background-color: #1d293b;
  background-image:
    linear-gradient(90deg, rgba(15, 26, 42, .96) 0%, rgba(15, 26, 42, .83) 38%, rgba(15, 26, 42, .22) 75%, rgba(15, 26, 42, .12) 100%),
    url('../imgs/mon-phai.webp');
  background-position: center, center 48%;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 35px #0c162833;
}
body #kl-factions.kl-factions .faction-hero #faction-name {
  margin: 0 0 8px;
  color: #ffda87;
  text-shadow: 0 2px 5px #07111dcc;
}
body #kl-factions.kl-factions .faction-hero #faction-profile {
  max-width: 500px;
}
body #kl-factions.kl-factions .faction-hero #faction-combat {
  color: #ffe4a8;
  background: #162334d9;
  border-color: #ae9159;
}
body #kl-factions.kl-factions .faction-hero #faction-summary {
  color: #f4f6fc;
  line-height: 1.6;
  text-shadow: 0 1px 4px #07111d;
}
@media (max-width: 600px) {
  body #kl-factions.kl-factions #faction-detail > .faction-hero {
    min-height: 175px;
    padding: 20px 16px;
    background-image:
      linear-gradient(90deg, rgba(15, 26, 42, .9), rgba(15, 26, 42, .62)),
      url('../imgs/mon-phai.webp');
    background-position: center, 60% center;
  }
}
/* Shared horizontal picker, including overrides for factions-page.css. */
#kl-factions.kl-factions .codex-layout.faction-horizontal,
.factions-page-body #kl-factions.kl-factions-page .codex-layout.faction-horizontal {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
}
#kl-factions.kl-factions .faction-horizontal > #faction-submenu,
#kl-factions.kl-factions .faction-horizontal > #faction-panel {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
#kl-factions.kl-factions #faction-menu-list {
  display: flex;
  flex-flow: row nowrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 3px;
  padding: 3px 3px 12px;
  scrollbar-width: thin;
  scrollbar-color: #ad8544 #152235;
}
#kl-factions.kl-factions #faction-menu-list .module-subbutton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 110px;
  width: 110px;
  min-width: 0;
  gap: 6px;
  padding: 10px 5px;
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
  scroll-snap-align: start;
}
#kl-factions.kl-factions #faction-menu-list .faction-emblem {
  display: block;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: 0;
  object-fit: contain;
}
#kl-factions.kl-factions #faction-menu-list img.faction-emblem {
  border: 0;
  background: transparent;
}
@media (max-width: 560px) {
  #kl-factions.kl-factions #faction-menu-list { gap: 6px; }
  #kl-factions.kl-factions #faction-menu-list .module-subbutton {
    flex-basis: 96px;
    width: 96px;
    padding: 8px 3px;
    font-size: 12px;
  }
}
