/* ════════════════════════════════════════
   CODEX.CSS — Wikipedia-style Wiki
   ════════════════════════════════════════ */

/* ── Wiki Layout ── */
.wiki-header {
  max-width: 1000px;
  margin: 0 auto;
  padding: 90px 2rem 0;
}

.wiki-search {
  position: relative;
  margin-bottom: 0.75rem;
}

.wiki-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem 0.7rem 2.6rem;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.wiki-search input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.15);
}

.wiki-search input::placeholder { color: var(--text-muted); }

.wiki-search::before {
  content: '🔍';
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 1;
}

.wiki-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 380px;
  overflow-y: auto;
  z-index: 200;
  display: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.wiki-search-results.active { display: block; }

.wiki-search-result {
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.wiki-search-result:last-child { border-bottom: none; }
.wiki-search-result:hover { background: rgba(201, 168, 76, 0.08); }

.wiki-search-result .result-title {
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.88rem;
}

.wiki-search-result .result-cat {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.1rem;
}

/* ── Breadcrumbs ── */
.wiki-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.25rem 0 0.75rem;
  flex-wrap: wrap;
}

.wiki-breadcrumb a {
  color: var(--gold);
  text-decoration: none;
  transition: color 0.15s;
  cursor: pointer;
}

.wiki-breadcrumb a:hover { color: var(--gold-light); text-decoration: underline; }
.wiki-breadcrumb .sep { opacity: 0.4; }
.wiki-breadcrumb .current { color: var(--text-primary); }

/* ── Wiki Body ── */
.wiki-body {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
  min-height: 60vh;
}

.wiki-page { display: none; }
.wiki-page.active {
  display: block;
  animation: wikiFadeIn 0.2s ease;
}

@keyframes wikiFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hub / Landing ── */
.wiki-hub-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  color: var(--gold);
  text-align: center;
  margin-bottom: 0.4rem;
}

.wiki-hub-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.wiki-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
  margin-bottom: 2.5rem;
}

.wiki-category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem;
  cursor: pointer;
  transition: border-color 0.25s, transform 0.2s, box-shadow 0.25s;
  text-decoration: none;
  display: block;
}

.wiki-category-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(0,0,0,0.4);
}

.wiki-category-card .card-icon { font-size: 1.8rem; margin-bottom: 0.6rem; }

.wiki-category-card .card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--gold);
  margin-bottom: 0.3rem;
}

.wiki-category-card .card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.wiki-category-card .card-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
  opacity: 0.6;
}

/* ── Category List ── */
.wiki-cat-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

.wiki-cat-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
}

.wiki-article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
}

.wiki-article-link {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  text-decoration: none;
  display: block;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.wiki-article-link:hover {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.04);
}

.wiki-article-link .link-icon { font-size: 1.2rem; margin-bottom: 0.2rem; }

.wiki-article-link .link-title {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  color: var(--gold-light);
  margin-bottom: 0.2rem;
}

.wiki-article-link .link-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Article Page Layout ── */
.wiki-article-wrap {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 2rem;
  align-items: start;
}

.wiki-article-main { min-width: 0; }

/* ── Table of Contents ── */
.wiki-toc {
  position: sticky;
  top: 90px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) var(--bg-card);
}

.wiki-toc-title {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.wiki-toc a {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.12s;
  cursor: pointer;
}

.wiki-toc a:hover { color: var(--gold); }

/* ── See Also ── */
.wiki-see-also {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.wiki-see-also h3 {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  color: var(--gold);
  margin-bottom: 0.7rem;
}

.wiki-see-also-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.wiki-see-also-links a {
  background: rgba(201, 168, 76, 0.07);
  border: 1px solid rgba(201, 168, 76, 0.18);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--gold);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}

.wiki-see-also-links a:hover {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold);
}

/* ── Lore Sections ── */
.lore-intro {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 1.5rem;
  font-style: italic;
  border-left: 3px solid var(--gold);
  padding-left: 1rem;
}

.lore-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin: 1rem 0;
}

.lore-block h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--gold-light);
  margin-bottom: 0.5rem;
}

.lore-block p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.lore-block p:last-child { margin-bottom: 0; }

/* ══════════════════════════════════════
   CONTENT STYLES (preserved)
   ══════════════════════════════════════ */

.codex-section { scroll-margin-top: 100px; display: none; }
.codex-section.active { display: block; }

.codex-section-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--gold);
  border-bottom: 1px solid rgba(201,168,76,0.25);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.codex-subsection-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  margin: 1.5rem 0 0.75rem;
}

.codex-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}

.codex-entry h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--gold-light);
  margin-bottom: 0.4rem;
}

.codex-entry p { font-size: 0.9rem; color: var(--text-muted); margin: 0; }

/* ── Stat block ── */
.stat-block {
  background: var(--bg-darker);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 8px;
  overflow: hidden;
  margin: 1rem 0 1.5rem;
}

.stat-block-title {
  background: rgba(201,168,76,0.12);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.55rem 1rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.stat-label { color: var(--text-muted); }
.stat-value { color: var(--text-primary); font-weight: 600; text-align: right; max-width: 65%; }

/* ── Ability block ── */
.ability-block {
  background: rgba(139, 26, 42, 0.08);
  border-left: 3px solid var(--crimson);
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  margin: 0.6rem 0;
}

.ability-name {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--crimson-light, #c4404f);
  margin-bottom: 0.3rem;
}

.ability-text { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }

/* ── Accordion / details ── */
details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.5rem 0;
  overflow: hidden;
}

details summary {
  list-style: none;
  padding: 0.75rem 1rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--gold-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

details summary::-webkit-details-marker { display: none; }
details summary::before { content: '▶'; font-size: 0.65em; color: var(--gold); transition: transform 0.25s; }
details[open] summary::before { transform: rotate(90deg); }
details summary:hover { background: rgba(201,168,76,0.06); }

.details-content {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

.details-content ul { padding-left: 1.4rem; margin: 0.5rem 0; }
.details-content li { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 0.3rem; }
.details-content p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 0.5rem; }

/* ── Callout colors ── */
.callout { border-radius: 8px; padding: 0.9rem 1.2rem; margin: 1rem 0; font-size: 0.9rem; }
.callout-gold  { background: rgba(201,168,76,0.1);  border-left: 4px solid var(--gold); color: var(--text-secondary); }
.callout-danger { background: rgba(139,26,42,0.1); border-left: 4px solid var(--crimson); color: var(--text-secondary); }
.callout-purple { background: rgba(100,60,160,0.15); border-left: 4px solid #7c4dcc; color: var(--text-secondary); }

/* ── Table wrapper ── */
.table-wrapper { overflow-x: auto; margin: 0.5rem 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead tr { background: rgba(201,168,76,0.1); }
th { font-family: var(--font-heading); font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold); padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 0.5rem 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.04); color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(201,168,76,0.04); }

/* ── Grid utilities ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

.mt-2 { margin-top: 1.25rem !important; }
.mt-3 { margin-top: 2rem !important; }
.text-muted { color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 860px) {
  .wiki-article-wrap { grid-template-columns: 1fr; }
  .wiki-toc { position: static; max-height: none; margin-bottom: 1.5rem; }
  .wiki-header { padding: 85px 1rem 0; }
  .wiki-body { padding: 0 1rem 3rem; }
  .wiki-hub-title { font-size: 1.7rem; }
  .wiki-categories { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .wiki-categories { grid-template-columns: 1fr; }
  .wiki-article-grid { grid-template-columns: 1fr; }
}
