/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --sidebar-w:    260px;
  --toc-w:        200px;
  --topbar-h:     54px;

  --bg:           #f8f7f4;
  --bg-sidebar:   #f0efe9;
  --bg-content:   #ffffff;
  --bg-code:      #f3f2ee;
  --bg-hover:     #e8e7e0;

  --border:       #dddbd3;
  --border-light: #eceae3;

  --text:         #1c1b18;
  --text-muted:   #7a7870;
  --text-sidebar: #3d3c38;

  --accent:       #2563eb;
  --accent-bg:    #eff4ff;
  --accent-hover: #1d4ed8;

  --warn:         #92400e;
  --warn-bg:      #fffbeb;
  --warn-border:  #fbbf24;

  --tip:          #065f46;
  --tip-bg:       #f0fdf4;
  --tip-border:   #34d399;

  --font-body:    'Figtree', sans-serif;
  --font-serif:   'Lora', Georgia, serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  --radius:       6px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --transition:   0.18s ease;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 1.5rem); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Top Bar ───────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--topbar-h);
  background: var(--bg-content);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.2rem;
  box-shadow: var(--shadow);
}
.topbar-left  { display: flex; align-items: center; gap: .7rem; flex-shrink: 0; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: .8rem; flex-shrink: 0; }

.sidebar-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 32px; height: 32px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text); }

.site-logo {
  display: flex; align-items: center; gap: .5rem;
  text-decoration: none; color: var(--text);
  font-family: var(--font-body); font-weight: 700; font-size: .95rem;
  white-space: nowrap;
}
.logo-icon { font-size: 1.1rem; }

/* Search */
.search-wrap {
  position: relative;
  display: flex; align-items: center;
  width: min(420px, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 .75rem;
  gap: .5rem;
}
.search-icon { color: var(--text-muted); flex-shrink: 0; }
.search-input {
  border: none; background: transparent;
  font-family: var(--font-body); font-size: .85rem;
  color: var(--text); flex: 1;
  outline: none; padding: .45rem 0;
}
.search-input::placeholder { color: var(--text-muted); }
.search-wrap kbd {
  font-family: var(--font-mono); font-size: .7rem;
  background: var(--border); border-radius: 4px;
  padding: .1rem .4rem; color: var(--text-muted);
  flex-shrink: 0;
}

.topbar-link {
  font-size: .82rem; color: var(--text-muted); text-decoration: none;
  transition: color var(--transition);
}
.topbar-link:hover { color: var(--accent); text-decoration: none; }
.topbar-cta {
  background: var(--accent); color: #fff !important;
  padding: .25rem .7rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.topbar-cta:hover { background: var(--accent-hover); }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.4rem 0 3rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-nav { padding: 0 .75rem; }

/* Section groups */
.nav-section { margin-bottom: .25rem; }

.nav-section-toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-weight: 700;
  font-size: .72rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted);
  padding: .55rem .6rem;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  user-select: none;
}
.nav-section-toggle:hover { background: var(--bg-hover); color: var(--text); }

.chevron {
  transition: transform var(--transition);
  flex-shrink: 0;
}
.nav-section.open .chevron { transform: rotate(180deg); }

/* Submenu */
.nav-submenu {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s cubic-bezier(.4,0,.2,1);
}
.nav-section.open .nav-submenu { max-height: 600px; }

.nav-item {
  display: block;
  padding: .42rem .6rem .42rem 1.2rem;
  margin: 1px 0;
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text-sidebar);
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  border-left: 2px solid transparent;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ─── Content area ──────────────────────────────────────────────────────── */
.content-wrap {
  flex: 1;
  display: flex;
  min-width: 0;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 2.5rem clamp(1.5rem, 5vw, 3.5rem);
  max-width: 800px;
}

/* ─── Breadcrumb ────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: .4rem;
  font-size: .78rem; color: var(--text-muted);
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.bc-sep { opacity: .5; }
.bc-current { color: var(--text); font-weight: 500; }

/* ─── Wiki Article ──────────────────────────────────────────────────────── */
.wiki-article { animation: fadeIn .35s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wiki-article h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  line-height: 1.2;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: .6rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--border-light);
}

.article-lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.75;
}

.wiki-article h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 2.4rem 0 .8rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
.wiki-article h3 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  margin: 1.8rem 0 .6rem;
  color: var(--text);
}

.wiki-article p { margin-bottom: 1.1rem; color: var(--text); }

.wiki-article ul, .wiki-article ol {
  padding-left: 1.5rem;
  margin-bottom: 1.2rem;
}
.wiki-article li { margin-bottom: .3rem; }

.wiki-article code {
  font-family: var(--font-mono);
  font-size: .82em;
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: .15em .4em;
  color: #c0392b;
}

.wiki-article pre {
  background: #1e1e2e;
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  margin: 1.4rem 0;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.65;
  color: #cdd6f4;
  border: 1px solid #313244;
}
.wiki-article pre code {
  background: none; border: none; padding: 0; color: inherit; font-size: inherit;
}

/* Callout boxes */
.callout {
  border-left: 3px solid;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  font-size: .9rem;
}
.callout-warn  { background: var(--warn-bg);  border-color: var(--warn-border); color: var(--warn); }
.callout-tip   { background: var(--tip-bg);   border-color: var(--tip-border);  color: var(--tip); }
.callout-info  { background: var(--accent-bg); border-color: var(--accent);     color: var(--accent); }
.callout strong { display: block; margin-bottom: .3rem; font-size: .8rem; letter-spacing: .05em; text-transform: uppercase; }

/* Table */
.wiki-table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem; margin: 1.5rem 0;
}
.wiki-table th {
  background: var(--bg-code); font-weight: 600;
  padding: .6rem 1rem; text-align: left;
  border: 1px solid var(--border);
}
.wiki-table td {
  padding: .55rem 1rem;
  border: 1px solid var(--border-light);
  vertical-align: top;
}
.wiki-table tr:hover td { background: var(--bg); }

/* Tags / badges */
.badge {
  display: inline-block;
  font-size: .72rem; font-weight: 600; font-family: var(--font-mono);
  padding: .15rem .55rem;
  border-radius: 999px;
}
.badge-get    { background: #dbeafe; color: #1e40af; }
.badge-post   { background: #dcfce7; color: #166534; }
.badge-delete { background: #fee2e2; color: #991b1b; }
.badge-put    { background: #fef9c3; color: #854d0e; }

.wiki-link { color: var(--accent); font-weight: 500; }

/* ─── TOC Rail ──────────────────────────────────────────────────────────── */
.toc-rail {
  width: var(--toc-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 2.5rem 1rem 3rem 1.5rem;
  border-left: 1px solid var(--border-light);
}
.toc-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: .8rem;
}
.toc-nav { display: flex; flex-direction: column; gap: .2rem; }
.toc-item {
  font-size: .8rem; color: var(--text-muted); text-decoration: none;
  padding: .25rem .5rem;
  border-radius: 4px;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent;
}
.toc-item:hover { color: var(--accent); text-decoration: none; }
.toc-sub { padding-left: 1rem; }
.toc-active { color: var(--accent) !important; border-left-color: var(--accent); background: var(--accent-bg); }

/* ─── Footer ────────────────────────────────────────────────────────────── */
.wiki-footer {
  border-top: 1px solid var(--border);
  padding: 1.1rem 1.5rem;
  font-size: .8rem;
  color: var(--text-muted);
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
}
.footer-sep { opacity: .4; }
.wiki-footer a { color: var(--text-muted); }
.wiki-footer a:hover { color: var(--accent); text-decoration: none; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .toc-rail { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 150;
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-right { display: none; }
  .content { padding: 1.5rem 1.2rem; }
}

@media (max-width: 480px) {
  .topbar-center { display: none; }
}
