/* ============================================
   AdventureSystem Wiki — Dark Fantasy RPG Theme
   Author: Feiiy
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 19px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: #0b0d12;
  color: #d0d4dc;
  line-height: 1.85;
  min-height: 100vh;
  overflow-x: hidden;
  font-weight: 450;
}
a { color: #d4a54a; text-decoration: none; transition: color .2s; }
a:hover { color: #f0c866; }
::selection { background: rgba(212,165,74,.3); }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0d0f14; }
::-webkit-scrollbar-thumb { background: #2a2d38; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3d48; }

/* --- Layout --- */
.page-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.main-layout { display: flex; flex: 1; max-width: 1440px; margin: 0 auto; width: 100%; }

/* --- Top Navigation --- */
.top-nav {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(13,15,20,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(212,165,74,.15);
  padding: 0 2rem; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { display: flex; align-items: center; gap: .6rem; }
.nav-brand-icon { font-size: 1.6rem; }
.nav-brand-text { font-size: 1.35rem; font-weight: 900; color: #d4a54a; letter-spacing: 1.5px; }
.nav-brand-ver { font-size: .75rem; color: #666; background: rgba(212,165,74,.12); padding: 2px 8px; border-radius: 10px; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { color: #888; font-size: .9rem; font-weight: 500; transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: #d4a54a; }
.nav-search {
  background: #181b24; border: 1px solid #2a2d38; border-radius: 8px;
  padding: 6px 14px; color: #c8ccd4; font-size: .85rem; width: 200px;
  outline: none; transition: border-color .2s;
}
.nav-search:focus { border-color: #d4a54a; }
.nav-search::placeholder { color: #555; }
.mobile-menu-btn { display: none; background: none; border: none; color: #d4a54a; font-size: 1.4rem; cursor: pointer; }

/* --- Left Sidebar --- */
.sidebar {
  width: 260px; min-width: 260px; padding: 1.5rem 0;
  border-right: 1px solid rgba(212,165,74,.08);
  height: calc(100vh - 56px); position: sticky; top: 56px;
  overflow-y: auto; overflow-x: hidden;
  background: rgba(13,15,20,.5);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a2d38; border-radius: 2px; }
.sidebar-group { margin-bottom: .8rem; }
.sidebar-group-title {
  font-size: .75rem; text-transform: uppercase; letter-spacing: 2px;
  color: #d4a54a; padding: .5rem 1.5rem; font-weight: 700;
  display: flex; align-items: center; gap: .5rem;
}
.sidebar-group-title::after { content: ''; flex: 1; height: 1px; background: rgba(212,165,74,.15); }
.sidebar-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1.5rem .5rem 2rem;
  font-size: .95rem; color: #999; font-weight: 500; cursor: pointer;
  transition: all .15s; border-left: 2px solid transparent;
}
.sidebar-link:hover { color: #c8ccd4; background: rgba(212,165,74,.04); }
.sidebar-link.active {
  color: #d4a54a; border-left-color: #d4a54a;
  background: rgba(212,165,74,.08); font-weight: 700;
}
.sidebar-link-icon { font-size: .9rem; width: 20px; text-align: center; }

/* --- Content Area --- */
.content-area {
  flex: 1; padding: 2rem 3rem; max-width: 900px;
  min-height: calc(100vh - 56px);
}

/* Page sections (all hidden by default, shown via JS) */
.doc-page { display: none; animation: fadeIn .3s ease; }
.doc-page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* --- Right mini-TOC --- */
.right-toc {
  width: 200px; min-width: 200px; padding: 2rem 1rem;
  position: sticky; top: 56px; height: calc(100vh - 56px);
  overflow-y: auto; font-size: .78rem;
}
.right-toc-title { color: #d4a54a; font-size: .7rem; text-transform: uppercase; letter-spacing: 2px; margin-bottom: .8rem; font-weight: 600; }
.right-toc a {
  display: block; color: #555; padding: .25rem 0; border-left: 1px solid #2a2d38;
  padding-left: .8rem; transition: all .15s;
}
.right-toc a:hover, .right-toc a.active { color: #d4a54a; border-left-color: #d4a54a; }

/* --- Typography --- */
.doc-page h1 {
  font-size: 2.6rem; font-weight: 900; color: #f0e8dc;
  margin-bottom: 1.2rem; padding-bottom: .8rem;
  border-bottom: 2px solid rgba(212,165,74,.2);
  display: flex; align-items: center; gap: .6rem;
}
.doc-page h1 .page-icon { font-size: 2rem; }
.doc-page h2 {
  font-size: 1.6rem; font-weight: 800; color: #d4a54a;
  margin: 2.5rem 0 1rem; padding-bottom: .5rem;
  border-bottom: 1px solid rgba(212,165,74,.12);
}
.doc-page h3 { font-size: 1.28rem; font-weight: 700; color: #d4a54a; margin: 1.5rem 0 .6rem; }
.doc-page p { margin-bottom: 1.1rem; font-size: 1.05rem; font-weight: 450; }
.doc-page ul, .doc-page ol { padding-left: 1.5rem; margin-bottom: 1.1rem; }
.doc-page li { margin-bottom: .5rem; font-size: 1.05rem; font-weight: 450; }
.doc-page strong { color: #d4a54a; font-weight: 700; }

/* --- Code Blocks --- */
.doc-page code {
  font-family: 'Cascadia Code', 'Consolas', 'SF Mono', 'Menlo', monospace;
  font-size: .9em; background: rgba(212,165,74,.1);
  color: #d4a54a; padding: 3px 7px; border-radius: 5px; font-weight: 600;
}
.doc-page pre {
  background: #12151c; border: 1px solid #1e2130;
  border-radius: 10px; padding: 1.2rem 1.5rem;
  margin-bottom: 1.2rem; overflow-x: auto;
  position: relative;
}
.doc-page pre code {
  background: none; color: #c8ccd4; padding: 0;
  font-size: .92rem; line-height: 1.75; font-weight: 500;
}
/* YAML syntax colors */
.doc-page pre .key { color: #7ec8e3; }
.doc-page pre .val-str { color: #a8d8a8; }
.doc-page pre .val-num { color: #e8b87a; }
.doc-page pre .comment { color: #555; font-style: italic; }
.doc-page pre .val-bool { color: #e88a7a; }

/* --- Tables --- */
.doc-page table {
  width: 100%; border-collapse: collapse; margin-bottom: 1.5rem;
  font-size: .96rem;
}
.doc-page th {
  background: rgba(212,165,74,.1); color: #d4a54a;
  text-align: left; padding: .6rem 1rem; font-weight: 600;
  border-bottom: 2px solid rgba(212,165,74,.2);
}
.doc-page td {
  padding: .5rem 1rem;
  border-bottom: 1px solid #1a1d28;
}
.doc-page tr:hover td { background: rgba(212,165,74,.03); }

/* --- Alert Boxes --- */
.alert {
  padding: 1rem 1.2rem; border-radius: 10px; margin-bottom: 1.2rem;
  border-left: 4px solid; font-size: .95rem; font-weight: 480;
}
.alert-title { font-weight: 800; font-size: 1rem; margin-bottom: .3rem; display: flex; align-items: center; gap: .4rem; }
.alert-info { background: rgba(110,160,255,.08); border-color: #5588cc; }
.alert-info .alert-title { color: #7ab4ff; }
.alert-warn { background: rgba(255,180,60,.08); border-color: #cc9933; }
.alert-warn .alert-title { color: #ffbb44; }
.alert-danger { background: rgba(255,80,80,.08); border-color: #cc4444; }
.alert-danger .alert-title { color: #ff6666; }
.alert-tip { background: rgba(80,200,120,.08); border-color: #44aa66; }
.alert-tip .alert-title { color: #66cc88; }

/* --- Feature Cards (for overview page) --- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.feature-card {
  background: linear-gradient(135deg, rgba(212,165,74,.06), rgba(212,165,74,.02));
  border: 1px solid rgba(212,165,74,.12);
  border-radius: 12px; padding: 1.2rem 1.4rem;
  transition: all .25s;
}
.feature-card:hover { border-color: rgba(212,165,74,.3); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.feature-card-icon { font-size: 2rem; margin-bottom: .6rem; }
.feature-card-title { font-size: 1.15rem; font-weight: 800; color: #f0e8dc; margin-bottom: .4rem; }
.feature-card-desc { font-size: .95rem; color: #aaa; font-weight: 480; line-height: 1.6; }

/* --- Hero Section (overview) --- */
.hero {
  text-align: center; padding: 3rem 2rem;
  background: radial-gradient(ellipse at 50% 0%, rgba(212,165,74,.1) 0%, transparent 60%);
  margin: -2rem -3rem 2rem; border-bottom: 1px solid rgba(212,165,74,.1);
}
.hero h1 { justify-content: center; font-size: 3rem; font-weight: 900; border: none; padding-bottom: 0; }
.hero-subtitle { color: #bbb; font-size: 1.25rem; font-weight: 500; margin-top: .6rem; letter-spacing: 0.08em; }
.hero-badges { display: flex; gap: .8rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }
.hero-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(212,165,74,.08); border: 1px solid rgba(212,165,74,.15);
  padding: .35rem .9rem; border-radius: 20px; font-size: .8rem; color: #d4a54a; font-weight: 600;
}

/* --- Badge (inline) --- */
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; font-weight: 600; vertical-align: middle; margin-left: .4rem; }
.badge-new { background: rgba(80,200,120,.15); color: #66cc88; }
.badge-ver { background: rgba(110,160,255,.15); color: #7ab4ff; }
.badge-warn { background: rgba(255,180,60,.15); color: #ffbb44; }

/* --- Page Navigation --- */
.page-nav { display: flex; justify-content: space-between; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid #1a1d28; gap: 1rem; }
.page-nav-btn {
  display: flex; flex-direction: column; padding: .8rem 1.2rem;
  background: rgba(212,165,74,.04); border: 1px solid rgba(212,165,74,.1);
  border-radius: 10px; transition: all .2s; cursor: pointer; min-width: 0; flex: 1; max-width: 48%;
}
.page-nav-btn:hover { border-color: rgba(212,165,74,.3); background: rgba(212,165,74,.08); }
.page-nav-label { font-size: .7rem; color: #666; }
.page-nav-title { font-size: 1rem; color: #d4a54a; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-nav-next { text-align: right; }

/* --- Footer --- */
.footer {
  text-align: center; padding: 1.5rem; font-size: .75rem; color: #666; font-weight: 500;
  border-top: 1px solid rgba(212,165,74,.08);
}

/* --- Event type tags --- */
.event-tag {
  display: inline-block; font-size: .7rem; padding: 2px 8px;
  border-radius: 6px; font-weight: 600; margin-right: .3rem;
}
.event-positive { background: rgba(80,200,120,.12); color: #66cc88; }
.event-negative { background: rgba(255,80,80,.12); color: #ff7777; }

/* --- Search overlay --- */
.search-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  justify-content: center; padding-top: 15vh;
}
.search-overlay.active { display: flex; }
.search-box {
  background: #181b24; border: 1px solid rgba(212,165,74,.2);
  border-radius: 14px; width: 560px; max-width: 92vw; padding: 1.2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.search-input {
  width: 100%; background: transparent; border: none; outline: none;
  color: #e8e0d4; font-size: 1.1rem; padding: .5rem;
}
.search-input::placeholder { color: #555; }
.search-results { max-height: 50vh; overflow-y: auto; margin-top: .5rem; }
.search-result-item {
  display: block; padding: .7rem .8rem; border-radius: 8px;
  cursor: pointer; transition: background .15s; font-size: .88rem;
}
.search-result-item:hover { background: rgba(212,165,74,.08); }
.search-result-title { color: #d4a54a; font-weight: 600; }
.search-result-desc { color: #666; font-size: .78rem; margin-top: .15rem; }

/* --- Responsive --- */
@media (max-width: 1100px) {
  .right-toc { display: none; }
}
@media (max-width: 860px) {
  .sidebar { display: none; position: fixed; left: 0; top: 56px; z-index: 900; width: 280px; height: calc(100vh - 56px); background: #0d0f14; border-right: 1px solid rgba(212,165,74,.15); }
  .sidebar.open { display: block; }
  .mobile-menu-btn { display: block; }
  .content-area { padding: 1.5rem 1.2rem; }
  .hero { margin: -1.5rem -1.2rem 1.5rem; }
  .nav-search { width: 140px; }
  .feature-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .nav-search { display: none; }
  .nav-links a:not(.nav-github) { display: none; }
}
