/* Peercraft Docs — shared styles */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --bg-card: #f7f8fa;
  --text: #1f2733;
  --text-strong: #111826;
  --text-muted: #5b6474;
  --border: #e6e8ec;
  --border-strong: #d5d9df;
  --kbd-bg: #eef0f3;
  --shadow: 0 10px 40px rgba(15, 23, 42, 0.14);
  --topbar-h: 60px;
}
[data-theme="dark"] {
  --primary: #5c8bfa;
  --primary-hover: #7ba2fb;
  --bg: #0e1116;
  --bg-subtle: #151a21;
  --bg-card: #161b23;
  --text: #c9d1dd;
  --text-strong: #eef2f7;
  --text-muted: #8a94a6;
  --border: #232a35;
  --border-strong: #303947;
  --kbd-bg: #1e2530;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 24px); }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 20px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text-strong); font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; }
.brand-name { color: var(--primary); }
.brand-docs { font-weight: 600; color: var(--text-strong); }
.topnav { margin-left: auto; display: flex; gap: 24px; }
.topnav a { color: var(--text); font-size: 14.5px; font-weight: 500; }
.topnav a:hover { color: var(--primary); text-decoration: none; }
.search-button {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; min-width: 190px;
  font: inherit; font-size: 14px; color: var(--text-muted);
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer;
}
.search-button:hover { border-color: var(--border-strong); }
.search-button kbd, .search-input-row kbd {
  margin-left: auto; padding: 2px 6px;
  font-family: inherit; font-size: 11.5px; color: var(--text-muted);
  background: var(--kbd-bg); border: 1px solid var(--border); border-radius: 5px;
}
.theme-toggle, .hamburger {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: none;
  color: var(--text-muted);
  background: none; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer;
}
.theme-toggle:hover, .hamburger:hover { color: var(--text-strong); border-color: var(--border-strong); }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
.hamburger { display: none; }

/* ---------- Docs shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
}
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 28px 20px 40px 24px;
  border-right: 1px solid var(--border);
}
.nav-group { margin-bottom: 26px; }
.nav-group-title { font-size: 13.5px; font-weight: 700; color: var(--text-strong); margin-bottom: 8px; }
.nav-link {
  display: block; padding: 5px 10px; margin-left: -10px;
  font-size: 14px; color: var(--text-muted); border-radius: 6px;
}
.nav-link:hover { color: var(--text-strong); text-decoration: none; background: var(--bg-subtle); }
.nav-link[aria-current="page"] { color: var(--primary); font-weight: 600; }

.main { padding: 44px 56px 80px; }
.article { max-width: 760px; }

.toc { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 36px 24px 40px 4px; }
.toc-title { font-size: 13px; font-weight: 700; color: var(--text-strong); margin-bottom: 10px; padding-left: 13px; }
.toc-links { display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.toc-link { padding: 4px 0 4px 12px; margin-left: -1px; font-size: 13px; color: var(--text-muted); border-left: 1px solid transparent; }
.toc-link:hover { color: var(--text-strong); text-decoration: none; }
.toc-link.active { color: var(--primary); border-left-color: var(--primary); }
.toc-sub { padding-left: 24px; }

/* ---------- Article typography ---------- */
.article h1 { font-size: 34px; line-height: 1.2; font-weight: 700; color: var(--text-strong); margin: 0 0 14px; letter-spacing: -0.02em; }
.article h2 { font-size: 23px; font-weight: 700; color: var(--text-strong); margin: 44px 0 12px; padding-top: 28px; border-top: 1px solid var(--border); letter-spacing: -0.01em; }
.article h1 + h2, .article p:first-child + h2 { border-top: none; padding-top: 8px; }
.article h3 { font-size: 17.5px; font-weight: 650; color: var(--text-strong); margin: 28px 0 8px; }
.article p { margin: 0 0 14px; }
.article li { margin: 5px 0; }
.article ul, .article ol { padding-left: 24px; margin: 0 0 14px; }
.article code {
  padding: 2px 6px; font-size: 13.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--kbd-bg); border-radius: 5px;
}
.article pre { padding: 14px 16px; overflow-x: auto; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 10px; }
.article pre code { padding: 0; background: none; }
.article table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: 14.5px; display: block; overflow-x: auto; }
.article th, .article td { padding: 8px 12px; text-align: left; border: 1px solid var(--border); }
.article th { background: var(--bg-subtle); color: var(--text-strong); }
.article blockquote { margin: 0 0 14px; padding: 10px 16px; border-left: 3px solid var(--primary); background: var(--bg-subtle); border-radius: 0 8px 8px 0; color: var(--text-muted); }
.article img { border: 1px solid var(--border); border-radius: 10px; margin: 6px 0 14px; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* ---------- Footer ---------- */
.footer { padding: 28px 24px 40px; text-align: center; font-size: 14px; color: var(--text-muted); border-top: 1px solid var(--border); }
.footer p { margin: 4px 0; }

/* ---------- Search modal ---------- */
.search-overlay[hidden] { display: none; }
.search-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 14, 20, 0.45);
  backdrop-filter: blur(2px);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 20px 20px;
}
.search-modal {
  width: 100%; max-width: 580px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.search-input-row input { flex: 1; font: inherit; font-size: 16px; color: var(--text-strong); background: none; border: none; outline: none; }
.search-results { max-height: 46vh; overflow-y: auto; padding: 8px; }
.search-result { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.search-result:hover, .search-result.selected { background: var(--bg-subtle); text-decoration: none; }
.search-result .r-title { font-size: 14.5px; font-weight: 600; color: var(--text-strong); }
.search-result.selected .r-title { color: var(--primary); }
.search-result .r-group { font-size: 12.5px; color: var(--text-muted); }
.search-empty { padding: 18px 14px; font-size: 14px; color: var(--text-muted); text-align: center; }

/* ---------- Landing ---------- */
.landing-main { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
.hero { padding: 110px 0 70px; max-width: 820px; }
.hero-brand { font-size: clamp(40px, 6vw, 64px); font-weight: 800; letter-spacing: -0.03em; color: var(--primary); margin: 0; line-height: 1.06; }
.hero h1 { font-size: clamp(36px, 5.4vw, 58px); font-weight: 800; letter-spacing: -0.03em; color: var(--text-strong); margin: 0 0 26px; line-height: 1.12; }
.hero p { font-size: clamp(19px, 2.2vw, 24px); color: var(--text-muted); margin: 0 0 34px; max-width: 640px; line-height: 1.5; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.btn { display: inline-block; padding: 12px 26px; font-size: 15.5px; font-weight: 600; border-radius: 999px; }
.btn:hover { text-decoration: none; }
.btn-primary { color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { color: var(--text-strong); background: var(--bg-subtle); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; padding: 40px 0 30px; }
.feature-card { padding: 26px 28px 30px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; }
.feature-card h3 { margin: 0 0 10px; font-size: 17.5px; color: var(--text-strong); }
.feature-card p { margin: 0; font-size: 15px; color: var(--text-muted); line-height: 1.6; }

.landing-shot { padding: 30px 0 90px; }
.landing-shot img { width: 100%; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .toc { display: none; }
  .shell { grid-template-columns: 250px minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .hamburger { display: flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 50;
    width: 290px; height: calc(100vh - var(--topbar-h));
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  .main { padding: 34px 24px 60px; }
  .topnav { display: none; }
  .search-button { margin-left: auto; min-width: 0; }
  .search-button span { display: none; }
}
@media (max-width: 640px) {
  .feature-grid { grid-template-columns: 1fr; }
  .hero { padding: 64px 0 46px; }
  .search-button kbd { display: none; }
}
