/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f0f1a;
  --bg-surface:  #16192a;
  --bg-raised:   #1e2140;
  --bg-code:     #12131f;
  --border:      #2a2d4a;
  --text:        #c8cad8;
  --text-dim:    #6b6e88;
  --text-bright: #eaecf5;
  --accent:      #ffd700;
  --accent-dim:  #b89b00;
  --link:        #74aaff;
  --link-hover:  #a8ccff;
  --green:       #51cf66;
  --red:         #ff6b6b;
  --orange:      #ff922b;
  --cyan:        #22b8cf;
  --magenta:     #cc5de8;
  --max-width:   860px;
  --sidebar-w:   280px;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', monospace;
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.7;
  min-height: 100vh;
}

/* === LAYOUT === */
.site-wrapper {
  display: flex;
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 2rem 1.25rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-link {
  display: block;
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  margin: 0.1rem 0;
  border-radius: 4px;
  transition: all 0.15s ease;
  line-height: 1.5;
}

.sidebar-link:hover {
  background: var(--bg-raised);
  color: var(--text-bright);
}

.sidebar-link.active {
  background: var(--bg-raised);
  color: var(--accent);
  font-weight: 500;
}

.sidebar-link .num {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  margin-right: 0.35rem;
}

/* === MAIN CONTENT === */
.content-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.content-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 2.5rem 6rem;
}

/* === TYPOGRAPHY === */
h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 0.5rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

strong {
  color: var(--text-bright);
  font-weight: 600;
}

em {
  color: var(--text);
  font-style: italic;
}

del {
  color: var(--text-dim);
  text-decoration: line-through;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* === LISTS === */
ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

li > ul, li > ol {
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
}

/* Checkbox lists (TODO) */
li input[type="checkbox"] {
  margin-right: 0.5rem;
  accent-color: var(--accent);
}

/* === CODE === */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  color: var(--cyan);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text);
}

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-bright);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  background: var(--bg-surface);
  white-space: nowrap;
}

tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover {
  background: var(--bg-surface);
}

/* === BLOCKQUOTES === */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  border-radius: 0 6px 6px 0;
  color: var(--text);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* === TABLE OF CONTENTS (on-page) === */
.toc {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.toc nav ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.toc nav ul ul {
  padding-left: 1.25rem;
}

.toc nav li {
  margin-bottom: 0.2rem;
}

.toc nav a {
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
}

.toc nav a:hover {
  color: var(--accent);
}

/* === META / HEADER === */
.page-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.page-meta .badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-research { background: #1a3a2a; color: var(--green); }
.badge-design   { background: #3a2a1a; color: var(--orange); }
.badge-backlog  { background: #2a1a3a; color: var(--magenta); }

/* === INDEX PAGE === */
.index-hero {
  margin-bottom: 3rem;
}

.index-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.index-hero .tagline {
  font-size: 1.1rem;
  color: var(--text-dim);
  max-width: 600px;
}

.index-stats {
  display: flex;
  gap: 1.5rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.5rem;
  min-width: 140px;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.doc-list {
  margin-top: 2rem;
}

.doc-list h2 {
  margin-top: 2rem;
}

.doc-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
  transition: all 0.15s ease;
}

.doc-card:hover {
  border-color: var(--accent-dim);
  background: var(--bg-raised);
  text-decoration: none;
}

.doc-card-title {
  font-weight: 600;
  color: var(--text-bright);
  font-size: 0.95rem;
}

.doc-card-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* === PREV/NEXT NAV === */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.page-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s ease;
}

.page-nav a:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.page-nav .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  display: block;
  margin-bottom: 0.15rem;
}

/* === MOBILE NAV TOGGLE === */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.mobile-header-title {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.menu-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 1.25rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  line-height: 1;
}

.menu-toggle:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 30;
    border-right: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 25;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .site-wrapper {
    flex-direction: column;
  }

  .content-area {
    margin-left: 0;
  }

  .content-wrapper {
    padding: 1.5rem 1rem 4rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  h3 {
    font-size: 1.05rem;
  }

  .index-hero h1 {
    font-size: 1.75rem;
  }

  .index-hero .tagline {
    font-size: 0.95rem;
  }

  .index-stats {
    flex-direction: row;
    gap: 0.75rem;
  }

  .stat-card {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    text-align: center;
  }

  .stat-number {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  /* Tables scroll horizontally on mobile */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Code blocks scroll */
  pre {
    font-size: 0.78rem;
    padding: 1rem;
  }

  /* TOC smaller on mobile */
  .toc {
    padding: 1rem;
  }

  .toc nav a {
    font-size: 0.78rem;
  }

  /* Page nav stacks on mobile */
  .page-nav {
    flex-direction: column;
  }

  .page-nav a {
    text-align: center;
  }
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}
