/* Organic Wiki — Horizon Cobalt Theme (UX.md) + Light Encyclopedic Toggle */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans.ttf") format("truetype");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/Lora.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/Lora-Italic.ttf") format("truetype");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root, [data-theme="dark"] {
  --bg-void: #060D17;
  --bg-panel: #08111E;
  --bg-wash: #0B1624;
  --bg-well: #050B14;
  --bg-hover: rgba(60, 108, 200, 0.22);
  --text: #F2F6FA;
  --text-muted: rgba(242, 246, 250, 0.66);
  --border: rgba(185, 224, 248, 0.18);
  --border-strong: rgba(185, 224, 248, 0.34);
  --accent-fill: #3C6CC8;
  --accent-glow: #6EF0F0;
  --d-name: #E07E34;
  --d-item: #6EF0F0;
  --d-world: #64B689;
  --gold: #F5D758;
  --hp: #EB6B60;
  --mp: #6EF0F0;
  --portrait-well: linear-gradient(180deg, rgba(17, 34, 56, 0.92) 0%, rgba(5, 11, 20, 0.96) 100%);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-void: #F3F6FA;
  --bg-panel: #FFFFFF;
  --bg-wash: #E9EFF7;
  --bg-well: #EDF2F8;
  --bg-hover: rgba(42, 87, 176, 0.09);
  --text: #102033;
  --text-muted: #4C627A;
  --border: #CBD8E6;
  --border-strong: #94ADC7;
  --accent-fill: #2A57B0;
  --accent-glow: #0B7B8A;
  --d-name: #C25912;
  --d-item: #0E7490;
  --d-world: #1B7A47;
  --gold: #9A6700;
  --hp: #C8372D;
  --mp: #0E7490;
  --portrait-well: linear-gradient(180deg, #E8EFF8 0%, #D9E4F2 100%);
  --shadow: 0 8px 24px rgba(16, 32, 51, 0.10);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg-void);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-glow); text-decoration: none; }
a:hover { text-decoration: underline; }
a.d-name { color: var(--d-name); font-weight: 600; }
a.d-item { color: var(--d-item); font-weight: 600; }
a.d-world { color: var(--d-world); font-weight: 600; }
.d-gold { color: var(--gold); font-weight: 700; }
.d-player { color: var(--text); font-weight: 600; text-decoration: underline dotted var(--border-strong); }

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 11px;
  font-weight: 700;
  background: var(--text);
  color: var(--bg-void);
  border-radius: 2px;
  vertical-align: 1px;
}

code {
  font-family: Consolas, monospace;
  font-size: 13px;
  background: var(--bg-well);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-strong);
}

.nav-toggle {
  display: none;
  background: var(--bg-well);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 6px 8px;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-ico { width: 28px; height: 28px; object-fit: contain; }
.brand-title {
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.brand-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-glow);
  border: 1px solid var(--border-strong);
  padding: 2px 6px;
  border-radius: 2px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--text); }

.spacer { flex: 1; }

.search-wrap {
  position: relative;
  width: min(360px, 42vw);
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-well);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 0 10px;
  height: 36px;
}
.search-box:focus-within { border-color: var(--accent-glow); }
.search-box input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-kbd {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 2px;
}
.search-results {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 60;
}
.search-results.open { display: block; }
.sr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.sr-item:last-child { border-bottom: 0; }
.sr-item:hover, .sr-item.active { background: var(--bg-hover); text-decoration: none; }
.sr-img { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }
.sr-title { font-size: 14px; font-weight: 600; }
.sr-cat { margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-well);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--accent-glow); }

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px 12px 32px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}
.nav-group { margin-bottom: 16px; }
.nav-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 4px 10px;
}
.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  margin: 2px 0;
  border-radius: 2px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
}
.nav-link:hover { background: var(--bg-hover); text-decoration: none; }
.nav-link.active {
  background: rgba(60, 108, 200, 0.24);
  border-color: var(--accent-glow);
  font-weight: 700;
}
.nav-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.main-wrap {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 56px;
}

.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 24px;
  align-items: start;
}
.article-grid.no-infobox { grid-template-columns: minmax(0, 1fr); }

.page-header {
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.page-header h1 {
  margin: 0 0 6px;
  font-family: "Lora", Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 32px;
  line-height: 1.2;
}
.subtitle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
  background: var(--bg-well);
  color: var(--text);
}
.badge-boss { border-color: var(--hp); color: var(--hp); }
.badge-hostile { border-color: var(--d-name); color: var(--d-name); }
.badge-passive { border-color: var(--d-world); color: var(--d-world); }
.badge-key { border-color: var(--gold); color: var(--gold); }
.badge-tier { border-color: var(--accent-glow); color: var(--accent-glow); }

h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 26px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
h3 { font-size: 16px; font-weight: 700; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
ul, ol { margin: 0 0 14px; padding-left: 22px; }
li { margin-bottom: 5px; }

.infobox {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
  position: sticky;
  top: 76px;
}
.ib-title {
  background: var(--accent-fill);
  color: #FFFFFF;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}
.ib-sub {
  background: var(--bg-wash);
  text-align: center;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-glow);
  border-bottom: 1px solid var(--border);
}
.portrait-stage {
  background: var(--portrait-well);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 210px;
}
.portrait-stage img {
  max-width: 196px;
  max-height: 196px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}
.portrait-stage.icon-stage { min-height: 148px; }
.portrait-stage.icon-stage img { max-width: 112px; max-height: 112px; }

.ib-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ib-table th, .ib-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.ib-table tr:last-child th, .ib-table tr:last-child td { border-bottom: 0; }
.ib-table th { width: 42%; color: var(--text-muted); font-weight: 600; background: var(--bg-well); }

.tattle-box, .dialogue-box, .callout {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent-glow);
  border-radius: 2px;
  padding: 12px 16px;
  margin: 12px 0 16px;
}
.callout-gold { border-left-color: var(--gold); }
.callout-warn { border-left-color: var(--d-name); }
.tattle-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-glow);
  margin-bottom: 6px;
}
.tattle-head img { width: 22px; height: 22px; object-fit: contain; }

.dialogue-turn {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.dialogue-turn:last-child { border-bottom: 0; padding-bottom: 0; }
.dialogue-turn:first-child { padding-top: 0; }
.turn-speaker { font-size: 13px; font-weight: 700; color: var(--d-name); margin-bottom: 2px; }
.turn-sub { font-weight: 500; color: var(--text-muted); font-size: 12px; margin-left: 6px; }

.table-wrap { overflow-x: auto; margin: 10px 0 18px; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  font-size: 14px;
}
table.data-table th, table.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.data-table thead th {
  background: var(--bg-wash);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
}
table.data-table.sortable thead th { cursor: pointer; user-select: none; }
table.data-table.sortable thead th:hover { color: var(--accent-glow); }
table.data-table tbody tr:hover { background: var(--bg-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.no-wrap { white-space: nowrap; }

.inline-ico {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 6px;
}
.table-thumb {
  width: 34px;
  height: 34px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 8px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 14px 0 22px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 14px;
  color: var(--text);
  transition: border-color 0.12s;
}
.card:hover { border-color: var(--accent-glow); text-decoration: none; }
.card-top { display: flex; align-items: center; gap: 12px; }
.card-ico { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.card-title { font-size: 15px; font-weight: 700; }
.card-meta { font-size: 12px; color: var(--text-muted); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px;
  align-items: center;
}
.filter-btn {
  padding: 5px 11px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-panel);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
}
.filter-btn.active, .filter-btn:hover {
  border-color: var(--accent-glow);
  color: var(--text);
  background: var(--bg-hover);
}
.filter-input {
  margin-left: auto;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-well);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  font-family: inherit;
  font-size: 13px;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 18px;
}
.stat-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 14px;
  min-width: 120px;
}
.stat-val { font-size: 20px; font-weight: 700; color: var(--accent-glow); }
.stat-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }

.skill-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  padding: 14px;
  margin-bottom: 10px;
}
.skill-card img { width: 48px; height: 48px; object-fit: contain; flex-shrink: 0; }
.skill-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.skill-name { font-size: 16px; font-weight: 700; }

.editorial-notes {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 14px 18px;
  margin: 12px 0;
}

.tech-footnote {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

@media (max-width: 1040px) {
  .article-grid { grid-template-columns: minmax(0, 1fr); }
  .infobox { position: static; order: -1; max-width: 380px; }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: -260px;
    top: 56px;
    width: 248px;
    z-index: 50;
    transition: left 0.16s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { left: 0; }
  .breadcrumbs { display: none; }
}
@media print {
  .topbar, .sidebar, .filter-bar { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
}
