/* ── Reset & base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #ffffff;
  --bg-header:    #0d1b2a;
  --bg-sidebar:   #f5f5f0;
  --border:       #e0ddd6;
  --text:         #1c1c1c;
  --text-muted:   #6b6b6b;
  --accent:       #2be07a;
  --accent-hover: #1db85e;
  --code-bg:      #f0ede8;
  --sidebar-w:    240px;
  --header-h:     60px;
  --radius:       6px;
  --font-body:    'Georgia', 'Times New Roman', serif;
  --font-ui:      system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-header);
  border-bottom: 1px solid rgba(255,255,255,.07);
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

#site-logo {
  height: 36px;
  width: auto;
  display: block;
}

#site-logo.hidden { display: none; }

/* hide brand-name text — logo image already contains the full name */
.brand-name { display: none; }

/* hamburger */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
  transition: opacity .2s;
}

/* ── Layout ──────────────────────────────────────── */
.layout {
  display: flex;
  margin-top: var(--header-h);
  flex: 1;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  overflow-y: auto;
  transition: transform .25s ease;
}

.nav-home {
  display: block;
  padding: .45rem 1.25rem;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .5rem;
}
.nav-home:hover { color: var(--accent); }

.nav-category {
  margin-bottom: 1.25rem;
}

.nav-category-label {
  display: block;
  padding: .3rem 1.25rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: .15rem;
}

.nav-article {
  display: block;
  padding: .4rem 1.25rem .4rem 1.5rem;
  font-size: .88rem;
  text-decoration: none;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-article:hover {
  background: var(--border);
  color: var(--accent);
}
.nav-article.active {
  border-left-color: var(--accent);
  color: var(--accent);
  background: rgba(43,108,176,.06);
  font-weight: 600;
}

/* ── Main content ────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 2.5rem 2rem 4rem;
  max-width: 800px;
}

/* ── Hero ────────────────────────────────────────── */
.hero {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.hero-logo {
  display: block;
  height: 72px;
  width: auto;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
  margin-bottom: .4rem;
}

.tagline {
  font-size: .9rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .75rem;
}

.hero-desc {
  color: var(--text-muted);
  max-width: 520px;
  font-size: .95rem;
}

/* ── Article grid on home ────────────────────────── */
.article-grid {
  display: grid;
  gap: 1rem;
}

.article-card {
  display: block;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: border-color .15s, box-shadow .15s;
  color: var(--text);
}
.article-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(43,108,176,.1);
}

.article-card-meta {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: .3rem;
}

.article-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Article body ────────────────────────────────── */
#article-body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}

#article-body h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: var(--text);
  letter-spacing: -.02em;
  font-family: var(--font-ui);
  border-bottom: 2px solid var(--border);
  padding-bottom: .6rem;
}
#article-body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2rem 0 .6rem;
  font-family: var(--font-ui);
  color: var(--text);
}
#article-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1.5rem 0 .4rem;
  font-family: var(--font-ui);
}
#article-body p { margin-bottom: 1.1rem; }
#article-body ul, #article-body ol {
  margin: .5rem 0 1.1rem 1.4rem;
}
#article-body li { margin-bottom: .3rem; }

#article-body a { color: var(--accent); }
#article-body a:hover { color: var(--accent-hover); }

#article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: .5rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-sidebar);
  border-radius: 0 var(--radius) var(--radius) 0;
}

#article-body code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: .88em;
  background: var(--code-bg);
  padding: .15em .35em;
  border-radius: 3px;
}

#article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0;
}
#article-body pre code {
  background: none;
  padding: 0;
  font-size: .85rem;
}

#article-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: .92rem;
  font-family: var(--font-ui);
}
#article-body th, #article-body td {
  border: 1px solid var(--border);
  padding: .5rem .75rem;
  text-align: left;
}
#article-body th {
  background: var(--bg-sidebar);
  font-weight: 600;
}

/* ── Back link ───────────────────────────────────── */
.back-link {
  display: inline-block;
  margin-top: 2.5rem;
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
  font-family: var(--font-ui);
}
.back-link:hover { text-decoration: underline; }

/* ── Error ───────────────────────────────────────── */
.error-msg {
  color: #c0392b;
  margin-bottom: 1rem;
}

/* ── Footer ──────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1rem;
  font-size: .78rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
  margin-left: var(--sidebar-w);
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 220px;
    transform: translateX(-100%);
    z-index: 90;
    box-shadow: 2px 0 12px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }

  .menu-toggle { display: flex; }

  .content { margin-left: 0; padding: 1.5rem 1rem 3rem; }
  .site-footer { margin-left: 0; }
}
