/* === Layout — Sidebar, Main Content, Grid === */

/* --- Sidebar Navigation --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-brand {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
}
.sidebar-brand .brand-name {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-primary);
}
.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--text-heading);
  background: rgba(184, 149, 48, 0.1);
  border-left-color: #B89530;
}
.nav-item.active {
  color: var(--accent-primary);
  background: rgba(184, 149, 48, 0.15);
  border-left-color: var(--accent-primary);
}

.nav-number {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 1.6rem;
}
.nav-item.active .nav-number { color: var(--accent-primary); }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --- Mobile Hamburger --- */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  color: var(--text-primary);
}
.hamburger svg { display: block; }

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 3rem 3.5rem 4rem;
  max-width: 1200px;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}
.page-header .page-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-primary);
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}
.page-header h1 {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
}
.page-header .page-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 60ch;
}

/* --- Section --- */
.section {
  margin-bottom: 3.5rem;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* --- Grid Layouts --- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* --- Flex helpers --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

/* --- Diagram Container --- */
.diagram-container {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  position: relative;
}
.diagram-container h3 {
  margin-bottom: 1rem;
}

/* --- Full-width section --- */
.full-width {
  max-width: none;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: block; }
  .main-content {
    margin-left: 0;
    padding: 2rem 1.5rem 3rem;
  }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
}

@media (max-width: 600px) {
  .main-content { padding: 1.5rem 1rem 2rem; }
  .page-header h1 { font-size: 1.5rem; }
}
