/* =========================================================
   Idle Fantasy Wiki — stylesheet
   Design: wikia-inspired, dark sidebar, light content area
   ========================================================= */

:root {
  --navy:          #1b2437;
  --navy-dark:     #111927;
  --sidebar-bg:    #1a2535;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --gold:          #e8a020;
  --gold-light:    #f5b83a;
  --content-bg:    #f8f8f6;
  --content-card:  #ffffff;
  --text:          #2a2a2a;
  --text-muted:    #666;
  --link:          #2563a8;
  --link-hover:    #1a4a85;
  --sidebar-text:  #b8cfe8;
  --sidebar-active:#ffffff;
  --border:        #dde1e8;
  --table-head-bg: #2c3e50;
  --table-head-fg: #ffffff;
  --table-alt:     #f0f4f8;
  --table-border:  #d0d8e4;
  --h1-accent:     #e8a020;
  --radius:        4px;
  --sidebar-width: 230px;
  --header-height: 56px;
}

/* ---- Dark mode overrides ---- */
[data-theme="dark"] {
  --content-bg:   #0d1117;
  --content-card: #161b22;
  --text:         #c9d1d9;
  --text-muted:   #8b949e;
  --link:         #58a6ff;
  --link-hover:   #79b8ff;
  --border:       #21262d;
  --table-head-bg:#1c2b3a;
  --table-head-fg:#c9d1d9;
  --table-alt:    #161b22;
  --table-border: #21262d;
  --sidebar-bg:   #0d1117;
  --sidebar-hover:rgba(255,255,255,0.07);
  --navy:         #0d1117;
  --navy-dark:    #080c12;
}

[data-theme="dark"] body             { background: #0d1117; color: #c9d1d9; }
[data-theme="dark"] .content        { background: #0d1117; }
[data-theme="dark"] .content strong { color: #e0e6f0; }
[data-theme="dark"] .content em     { color: #8b949e; }
[data-theme="dark"] .content code   { background: #1f2937; border-color: #374151; color: #e5e7eb; }
[data-theme="dark"] .content h1,
[data-theme="dark"] .content h2     { color: #e0e6f0; }
[data-theme="dark"] .content h3     { color: #b0bec5; }
[data-theme="dark"] .content h4     { color: #8b949e; }
[data-theme="dark"] .content h2 + p strong,
[data-theme="dark"] .content h3 + p strong { color: #b0bec5; }
[data-theme="dark"] .content tbody tr:hover { background: #1c2333; }
[data-theme="dark"] tr:target       { background-color: #2d2000 !important; outline-color: var(--gold); }

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--content-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
.site-header {
  background: var(--navy);
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  flex-shrink: 0;
}

.site-title {
  color: var(--gold);
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}
.site-title:hover { color: var(--gold-light); }
.site-icon { font-size: 1.3rem; }

.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.4); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  flex-shrink: 0;
}
.nav-toggle:hover { color: var(--gold-light); }

/* Backdrop behind open mobile nav */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
}
.nav-backdrop.visible { display: block; }

.site-tagline {
  color: rgba(200, 220, 240, 0.55);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Layout ---- */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow-y: auto;
  padding: 0.75rem 0 2rem;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar > ul > li > a {
  font-weight: 600;
}

.sidebar a {
  display: block;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.32rem 1rem;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sidebar a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar a.active {
  color: var(--sidebar-active);
  border-left-color: var(--gold);
  background: rgba(232, 160, 32, 0.12);
  font-weight: 600;
}

/* Nested nav indentation */
.sidebar ul ul a { padding-left: 1.75rem; }
.sidebar ul ul ul a { padding-left: 2.5rem; }

.nav-section { margin-top: 0.25rem; }

.nav-label {
  display: block;
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.85rem 1rem 0.2rem;
  opacity: 0.9;
}

/* ---- Content area ---- */
.content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 3rem;
  max-width: 1000px;
}

/* ---- Typography ---- */
.content h1 {
  font-size: 1.9rem;
  color: var(--navy);
  border-bottom: 3px solid var(--h1-accent);
  padding-bottom: 0.4rem;
  margin-bottom: 1.25rem;
}
.content h2 {
  font-size: 1.3rem;
  color: var(--navy);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
  margin: 2rem 0 0.85rem;
}
.content h3 {
  font-size: 1.05rem;
  color: #3a4a5c;
  margin: 1.5rem 0 0.5rem;
}
.content h4 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 1rem 0 0.4rem;
}
.content p {
  line-height: 1.7;
  margin-bottom: 0.8rem;
}
.content ul, .content ol {
  padding-left: 1.5rem;
  margin-bottom: 0.8rem;
}
.content li { margin-bottom: 0.25rem; line-height: 1.6; }

.content a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid rgba(37, 99, 168, 0.25);
  transition: color 0.1s, border-color 0.1s;
}
.content a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

.content strong { color: #1a2437; }
.content em { color: #555; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ---- Tables ---- */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1.5rem;
  font-size: 0.875rem;
  background: var(--content-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.content thead th {
  background: var(--table-head-bg);
  color: var(--table-head-fg);
  font-weight: 600;
  text-align: left;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: none;
}

.content tbody tr { border-bottom: 1px solid var(--table-border); }
.content tbody tr:last-child { border-bottom: none; }
.content tbody tr:nth-child(even) { background: var(--table-alt); }
.content tbody tr:hover { background: #e8edf4; }
.content td { padding: 0.45rem 0.85rem; vertical-align: top; }

/* Numeric columns (Qty, XP, Level) — right-aligned hint via data */
.content td:nth-child(2),
.content td:nth-child(3) { color: var(--text); }

/* Highlighted row — triggered by URL fragment (#item-slug) */
tr:target {
  background-color: #fef3c7 !important;
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  /* Push the row below the sticky header when the browser scrolls to it */
  scroll-margin-top: calc(var(--header-height) + 0.75rem);
}

/* ---- Stat lines (HP | Atk | Str | Def rows from boss/enemy templates) ---- */
.content h2 + p strong,
.content h3 + p strong {
  color: #2c3e50;
}

/* Inline code / monospace */
.content code {
  background: #eef2f8;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-size: 0.875em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--navy-dark);
  color: rgba(180, 200, 220, 0.6);
  font-size: 0.78rem;
  padding: 0.75rem 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.site-footer a {
  color: rgba(180, 200, 220, 0.85);
  text-decoration: none;
}
.site-footer a:hover { color: #fff; }

/* ---- Responsive: hamburger nav on narrow screens ---- */
@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .site-tagline { display: none; }

  /* Sidebar slides in from the left as a fixed overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 270px;
    height: 100%;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    padding-top: calc(var(--header-height) + 0.5rem);
    border-right: 1px solid rgba(255,255,255,0.1);
  }
  .sidebar.open { transform: translateX(0); }

  .content { padding: 1.25rem 1rem 2rem; }
}
