/* public/css/main.css */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0d0f14;
  --bg2: #13161d;
  --bg3: #1a1d26;
  --border: #2a2d3a;
  --text: #e8eaf0;
  --text2: #8b91a8;
  --text3: #555b70;
  --accent: #7c6af7;
  --accent2: #5b4fd4;
  --accent-glow: rgba(124,106,247,0.15);
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --font: 'Sora', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: #a89bf9; }

img { max-width: 100%; height: auto; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── HEADER ── */
.site-header {
  background: rgba(13,15,20,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.site-logo span { color: var(--accent); }
.header-search {
  flex: 1;
  max-width: 400px;
}
.header-search form { display: flex; gap: 0; }
.header-search input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 0.5rem 1rem;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  transition: border-color .2s;
}
.header-search input:focus { border-color: var(--accent); }
.header-search button {
  background: var(--accent);
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.5rem 1rem;
  color: white;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background .2s;
}
.header-search button:hover { background: var(--accent2); }
.header-nav { margin-left: auto; display: flex; align-items: center; gap: 1.5rem; }
.header-nav a { color: var(--text2); font-size: 0.875rem; font-weight: 500; transition: color .2s; }
.header-nav a:hover { color: var(--text); }
.btn-editor {
  background: var(--accent);
  color: white !important;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-editor:hover { background: var(--accent2) !important; color: white !important; }

/* ── LAYOUT ── */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 2rem;
}
.page-wrapper.full { grid-template-columns: 1fr; }
.main-content { min-width: 0; }
.sidebar {}

/* ── HERO ── */
.wiki-hero {
  background: linear-gradient(135deg, var(--bg2) 0%, #0f1219 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.wiki-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow) 0%, transparent 60%);
}
.wiki-hero h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 700; position: relative; }
.wiki-hero p { color: var(--text2); margin-top: 0.5rem; position: relative; }

/* ── ARTICLE GRID ── */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}
.article-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
}
.article-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124,106,247,0.12);
}
.article-card-img { width: 100%; height: 160px; object-fit: cover; }
.article-card-img-placeholder {
  width: 100%; height: 120px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 2rem;
}
.article-card-body { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; }
.article-card-meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(124,106,247,0.3);
}
.article-card-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; line-height: 1.4; }
.article-card-title a { color: inherit; }
.article-card-title a:hover { color: var(--accent); }
.article-card-excerpt { color: var(--text2); font-size: 0.85rem; flex: 1; }
.article-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 0.75rem; color: var(--text3); }

/* ── SIDEBAR ── */
.sidebar-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.sidebar-block h3 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 1rem; }
.category-list { list-style: none; }
.category-list li a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  color: var(--text2);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  transition: color .2s;
}
.category-list li:last-child a { border-bottom: none; }
.category-list li a:hover { color: var(--text); }
.category-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 0.2rem 0.6rem;
  border-radius: 5px;
  font-size: 0.75rem;
  transition: all .2s;
}
.tag:hover { border-color: var(--accent); color: var(--accent); }

/* ── ARTICLE VIEW ── */
.article-header { margin-bottom: 2rem; }
.article-header h1 { font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 700; line-height: 1.25; margin-bottom: 1rem; }
.article-meta { display: flex; gap: 1rem; flex-wrap: wrap; color: var(--text3); font-size: 0.8rem; margin-bottom: 1.5rem; }
.article-cover { width: 100%; max-height: 400px; object-fit: cover; border-radius: var(--radius); margin-bottom: 2rem; border: 1px solid var(--border); }
.article-content { color: var(--text); font-size: 0.95rem; }
.article-content h1, .article-content h2, .article-content h3 { margin: 2rem 0 1rem; font-weight: 600; }
.article-content h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.article-content p { margin-bottom: 1.25rem; color: var(--text2); }
.article-content ul, .article-content ol { margin: 0 0 1.25rem 1.5rem; color: var(--text2); }
.article-content li { margin-bottom: 0.4rem; }
.article-content code { font-family: var(--mono); background: var(--bg3); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.85em; color: #a89bf9; }
.article-content pre { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; overflow-x: auto; margin-bottom: 1.25rem; }
.article-content pre code { background: none; padding: 0; color: var(--text); }
.article-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--text2); font-style: italic; margin-bottom: 1.25rem; }
.article-content img { border-radius: 8px; border: 1px solid var(--border); }
.article-content table { width: 100%; border-collapse: collapse; margin-bottom: 1.25rem; }
.article-content th, .article-content td { border: 1px solid var(--border); padding: 0.6rem 1rem; text-align: left; }
.article-content th { background: var(--bg3); }

/* ── TAGS ── */
.article-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

/* ── RELATED ── */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }

/* ── FOOTER ── */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text3);
  font-size: 0.8rem;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text3);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

/* ── SECTION TITLE ── */
.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .page-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  /* Sidebar moves below main content on mobile */
  .sidebar {
    display: block;
    order: 2;
  }
  .main-content { order: 1; }
  .header-search { display: none; }
  .articles-grid { grid-template-columns: 1fr; }
  .header-inner { gap: 0.75rem; }
  .wiki-hero { padding: 2rem 1rem; }
}

/* ── HAMBURGER MENU ── */
.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  line-height: 1;
  margin-left: auto;
  transition: background .15s, border-color .15s;
}
.hamburger:hover { background: var(--bg3); border-color: var(--text3); }

/* Mobile search — always hidden on desktop */
.mobile-search { display: none; }

/* Mobile dropdown menu */
.mobile-menu {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.mobile-menu.open { display: block; }
.mobile-menu-inner { padding: 0.75rem 0; }
.mobile-nav-section {
  padding: 0.4rem 1.25rem 0.2rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-top: 0.4rem;
}
.mobile-nav-links { display: flex; flex-direction: column; }
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.25rem;
  color: var(--text2);
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background .1s, color .1s;
  text-decoration: none;
}
.mobile-nav-link:hover,
.mobile-nav-link:active { background: rgba(255,255,255,0.04); color: var(--text); }

@media (max-width: 768px) {
  .hamburger { display: flex; }
  .header-nav { display: none !important; }
  .header-search { display: none; }
  .mobile-search {
    display: block;
    padding: 0.65rem 1rem;
    background: var(--bg2);
    border-top: 1px solid var(--border);
  }
}

/* ── LOGO SIZES ── */
.site-logo-img {
  height: 52px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  display: block;
}

.hero-logo-img {
  height: 120px;
  width: auto;
  max-width: 320px;
  object-fit: contain;
  display: block;
  margin: 0 auto 1.25rem auto;
  position: relative;
}

/* Make header taller to accommodate larger logo */
.site-header .header-inner {
  height: auto;
  min-height: 64px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

@media (max-width: 768px) {
  .site-logo-img {
    height: 40px;
    max-width: 140px;
  }
  .hero-logo-img {
    height: 80px;
    max-width: 200px;
  }
}

/* ── MOBILE SIDEBAR: compact horizontal layout ── */
@media (max-width: 768px) {
  .sidebar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }
  .sidebar-block {
    flex: 1 1 100%;
    min-width: 0;
  }
  /* Tag cloud stays horizontal wrap naturally */
  .tag-cloud { gap: 0.35rem; }
  /* Category list goes horizontal pill-style on mobile */
  .category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .category-list li { flex-shrink: 0; }
  .category-list li a {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    background: var(--bg3);
    border-bottom: none;
    white-space: nowrap;
  }
  .category-list li a:hover {
    border-color: var(--accent);
  }
}
