/* Foundation Documentation */
:root {
  --sidebar-width: 260px;
  /* Foundation edition palette, using the kit's *Ink* (text-on-light) greens.
     The kit's raw brand green (#34d399) is a fill/decoration colour — at body
     size on white it only reaches ~1.8:1, so it is never used for text here. */
  --primary: #047857;        /* edition brandInk      — links, accents  */
  --primary-dark: #065f46;   /* edition brandInkHover — hover / headings */
  --accent: #047857;         /* alias: kept for older rules, same ink green */
  --accent-soft: #e8f5ef;    /* pale green tint for the active nav row   */
  --bg: #ffffff;             /* content surface  */
  --bg-sidebar: #fbfbfd;     /* app canvas — sits behind the white column */
  --text: #1d1d1f;           /* primary ink   */
  --text-muted: #6e6e73;     /* secondary ink */
  --text-sidebar: #1d1d1f;   /* nav labels read as primary text, not muted */
  --border: #e5e5e7;
  --hover-bg: #f0f0f2;
  --code-bg: #f5f5f7;
  --code-border: #e5e5e7;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  text-decoration: none;
  display: block;
}

.subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-links {
  flex: 1;
  padding: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.nav-group {
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.nav-group-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s, color 0.15s;
}

.nav-group-heading::-webkit-details-marker { display: none; }
.nav-group-heading::marker { content: ''; }

.nav-group-heading:hover {
  color: var(--text);
  background: var(--hover-bg);
}

.nav-group-chevron {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.nav-group[open] > .nav-group-heading .nav-group-chevron {
  transform: rotate(90deg);
}

.nav-group-name { flex: 1; }

.nav-group-count {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.nav-group-items {
  padding: 0.15rem 0 0.5rem;
}

.nav-link {
  display: block;
  padding: 0.4rem 1.5rem;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--primary-dark);
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
}

.sidebar-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.sidebar-footer a:hover { color: var(--primary); }
.sidebar-footer .sep { color: #b8b8bd; margin: 0 0.5rem; }

/* Content */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  max-width: 900px;
  padding: 3rem 4rem;
}

/* Top bar — sticky header with user identity + sign-out icon. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: -3rem -4rem 2rem;
  padding: 0.75rem 4rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: none;
}

.topbar-icon-btn {
  padding: 0.5rem;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar-icon-btn:hover {
  background: var(--hover-bg);
  color: var(--text);
}

/* Markdown styling */
.markdown-body h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}

.markdown-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.markdown-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-dark);
}

.markdown-body p {
  margin-bottom: 1rem;
}

.markdown-body ul, .markdown-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-body li {
  margin-bottom: 0.25rem;
}

.markdown-body code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.markdown-body pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 0.85rem;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
}

.markdown-body th {
  background: var(--code-bg);
  font-weight: 600;
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  background: #f5f5f7;
  color: var(--text-muted);
}

.markdown-body a {
  color: var(--primary);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
}

.markdown-body .mermaid {
  margin: 1.5rem 0;
  overflow-x: auto;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .content {
    margin-left: 0;
    padding: 2rem 1.5rem;
    padding-top: 4rem;
  }
  .nav-toggle { display: block; }
  .topbar {
    margin: -4rem -1.5rem 1.5rem;
    padding: 0.75rem 1.5rem 0.75rem 4rem;
  }
  .topbar-user span { display: none; }
}
