/* css variables for theming */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-tertiary: #adb5bd;
  --border-color: #dee2e6;
  --link-color: #0d6efd;
  --link-hover: #0a58ca;
  --code-bg: #f8f9fa;
  --code-border: #dee2e6;
  --sidebar-width: 280px;
  --header-height: 60px;
  --accent-color: #198754;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
}

[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #404040;
  --text-primary: #e9ecef;
  --text-secondary: #adb5bd;
  --text-tertiary: #6c757d;
  --border-color: #404040;
  --link-color: #6ea8fe;
  --link-hover: #9ec5fe;
  --code-bg: #2d2d2d;
  --code-border: #404040;
  --accent-color: #20c997;
  --warning-color: #ffc107;
  --danger-color: #ea868f;
}

/* reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* sidebar navigation */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  margin-bottom: 2rem;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.site-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--link-color);
}

.site-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 1rem;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.github-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

.nav-list {
  list-style: none;
  margin-bottom: 2rem;
}

.nav-item {
  margin-bottom: 0.25rem;
}

.nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 0.9375rem;
}

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

.nav-link.active {
  background-color: var(--link-color);
  color: #ffffff;
  font-weight: 500;
}

/* theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.theme-icon {
  display: none;
}

[data-theme="light"] .theme-icon-dark {
  display: block;
}

[data-theme="dark"] .theme-icon-light {
  display: block;
}

/* mobile menu toggle */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-toggle span {
  width: 20px;
  height: 2px;
  background-color: var(--text-primary);
  transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

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

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-content {
  margin-bottom: 4rem;
}

/* typography */
.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4,
.page-content h5,
.page-content h6 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.page-content h1 {
  font-size: 2.25rem;
}

.page-content h2 {
  font-size: 1.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.page-content h3 {
  font-size: 1.5rem;
}

.page-content h4 {
  font-size: 1.25rem;
}

.page-content h5 {
  font-size: 1.125rem;
}

.page-content h6 {
  font-size: 1rem;
}

.page-content p {
  margin-bottom: 1rem;
}

.page-content a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.page-content a:hover {
  border-bottom-color: var(--link-color);
}

.page-content ul,
.page-content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.page-content li {
  margin-bottom: 0.5rem;
}

.page-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--accent-color);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
}

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

/* code blocks */
.page-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 3px;
  padding: 0.2em 0.4em;
}

.page-content pre {
  margin: 1.5rem 0;
  padding: 1rem;
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}

.page-content pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  font-size: 0.875rem;
}

/* tables */
.page-content table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.page-content th,
.page-content td {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  text-align: left;
}

.page-content th {
  background-color: var(--bg-secondary);
  font-weight: 600;
}

.page-content tr:nth-child(even) {
  background-color: var(--bg-secondary);
}

/* images */
.page-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1.5rem 0;
}

/* horizontal rule */
.page-content hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

/* footer */
.page-footer {
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* syntax highlighting (rouge) */
.highlight {
  background-color: var(--code-bg);
}

.highlight .c,
.highlight .cm,
.highlight .c1,
.highlight .cs {
  color: var(--text-tertiary);
  font-style: italic;
}

.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt {
  color: var(--danger-color);
  font-weight: 600;
}

.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc,
.highlight .sd {
  color: var(--accent-color);
}

.highlight .na,
.highlight .nb,
.highlight .nc,
.highlight .no {
  color: var(--link-color);
}

.highlight .nf {
  color: var(--warning-color);
}

.highlight .m,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .mo {
  color: var(--accent-color);
}

/* responsive design */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .menu-toggle {
    display: flex;
  }

  .content {
    margin-left: 0;
    padding: 5rem 1.5rem 2rem;
  }

  .page-title {
    font-size: 2rem;
  }

  .page-content h1 {
    font-size: 1.875rem;
  }

  .page-content h2 {
    font-size: 1.5rem;
  }

  .page-content h3 {
    font-size: 1.25rem;
  }
}

/* scrollbar styling */
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background-color: var(--bg-secondary);
}

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

.sidebar::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-tertiary);
}

/* accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* focus styles */
a:focus,
button:focus {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

/* print styles */
@media print {
  .sidebar,
  .menu-toggle,
  .theme-toggle,
  .page-footer {
    display: none;
  }

  .content {
    margin-left: 0;
    max-width: 100%;
  }
}
