/*
 * Dark Theme for RecycledSpace.com
 * Based on Lanyon/Poole theme structure
 * Supports: prefers-color-scheme, .theme-dark class, and toggle via localStorage
 */

/* Dark theme base - applied via class or media query */
@media (prefers-color-scheme: dark) {
  html {
    background-color: #1a1a1a;
  }
  body {
    color: #c9d1d9;
    background-color: #0d1117;
  }

  /* Links */
  a {
    color: #58a6ff;
  }
  a:hover,
  a:focus {
    color: #79c0ff;
  }

  /* Headings */
  h1, h2, h3, h4, h5, h6 {
    color: #e6edf3;
  }

  strong {
    color: #e6edf3;
  }

  /* Code blocks */
  code {
    color: #ff7b72;
    background-color: #161b22;
  }
  pre {
    background-color: #161b22;
    border: 1px solid #30363d;
  }
  pre code {
    color: #c9d1d9;
  }

  /* Blockquotes */
  blockquote {
    color: #8b949e;
    border-left-color: #30363d;
  }

  /* Tables */
  table {
    border-color: #30363d;
  }
  td, th {
    border-color: #30363d;
  }
  tbody tr:nth-child(odd) td,
  tbody tr:nth-child(odd) th {
    background-color: #161b22;
  }
  tbody tr:nth-child(even) td,
  tbody tr:nth-child(even) th {
    background-color: #0d1117;
  }

  /* HR */
  hr {
    border-top-color: #30363d;
    border-bottom-color: #0d1117;
  }

  /* Abbreviations */
  abbr {
    color: #8b949e;
    border-bottom-color: #484f58;
  }

  /* Messages */
  .message {
    color: #c9d1d9;
    background-color: #161b22;
    border: 1px solid #30363d;
  }

  /* Masthead */
  .masthead {
    border-bottom-color: #21262d;
  }
  .masthead-title,
  .masthead-title a {
    color: #8b949e;
  }
  .masthead-title small {
    color: #484f58;
  }

  /* Posts and pages */
  .page-title,
  .post-title,
  .post-title a {
    color: #e6edf3;
  }
  .post-date {
    color: #8b949e;
  }

  /* Related posts */
  .related {
    border-top-color: #21262d;
  }
  .related-posts li small {
    color: #6e7681;
  }
  .related-posts li a:hover {
    color: #58a6ff;
  }

  /* Pagination */
  .pagination {
    color: #484f58;
  }
  .pagination-item {
    border-color: #30363d;
  }
  a.pagination-item:hover {
    background-color: #161b22;
    color: #e6edf3;
  }

  /* Sidebar toggle button */
  .sidebar-toggle {
    color: #c9d1d9;
    background-color: #21262d;
    border: 1px solid #30363d;
  }
  .sidebar-toggle:before {
    background-image: linear-gradient(to bottom, #c9d1d9, #c9d1d9 20%, #21262d 20%, #21262d 40%, #c9d1d9 40%, #c9d1d9 60%, #21262d 60%, #21262d 80%, #c9d1d9 80%, #c9d1d9 100%);
  }
  .sidebar-toggle:active,
  #sidebar-checkbox:focus ~ .sidebar-toggle,
  #sidebar-checkbox:checked ~ .sidebar-toggle {
    color: #0d1117;
    background-color: #c9d1d9;
  }
  .sidebar-toggle:active:before,
  #sidebar-checkbox:focus ~ .sidebar-toggle:before,
  #sidebar-checkbox:checked ~ .sidebar-toggle:before {
    background-image: linear-gradient(to bottom, #0d1117, #0d1117 20%, #c9d1d9 20%, #c9d1d9 40%, #0d1117 40%, #0d1117 60%, #c9d1d9 60%, #c9d1d9 80%, #0d1117 80%, #0d1117 100%);
  }

  /* Content title (custom) */
  .content-title h2 {
    color: #8b949e;
  }

  /* Muted text */
  .muted {
    color: #6e7681 !important;
  }

  /* Images - add subtle border for visibility on dark bg */
  img {
    border: 1px solid #30363d;
  }
}

/* Manual dark theme via class (for toggle button) */
.theme-dark {
  background-color: #0d1117;
  color: #c9d1d9;
}

.theme-dark a {
  color: #58a6ff;
}
.theme-dark a:hover,
.theme-dark a:focus {
  color: #79c0ff;
}

.theme-dark h1,
.theme-dark h2,
.theme-dark h3,
.theme-dark h4,
.theme-dark h5,
.theme-dark h6 {
  color: #e6edf3;
}

.theme-dark strong {
  color: #e6edf3;
}

.theme-dark code {
  color: #ff7b72;
  background-color: #161b22;
}

.theme-dark pre {
  background-color: #161b22;
  border: 1px solid #30363d;
}

.theme-dark pre code {
  color: #c9d1d9;
}

.theme-dark blockquote {
  color: #8b949e;
  border-left-color: #30363d;
}

.theme-dark table {
  border-color: #30363d;
}

.theme-dark td,
.theme-dark th {
  border-color: #30363d;
}

.theme-dark tbody tr:nth-child(odd) td,
.theme-dark tbody tr:nth-child(odd) th {
  background-color: #161b22;
}

.theme-dark tbody tr:nth-child(even) td,
.theme-dark tbody tr:nth-child(even) th {
  background-color: #0d1117;
}

.theme-dark hr {
  border-top-color: #30363d;
  border-bottom-color: #0d1117;
}

.theme-dark abbr {
  color: #8b949e;
  border-bottom-color: #484f58;
}

.theme-dark .message {
  color: #c9d1d9;
  background-color: #161b22;
  border: 1px solid #30363d;
}

.theme-dark .masthead {
  border-bottom-color: #21262d;
}

.theme-dark .masthead-title,
.theme-dark .masthead-title a {
  color: #8b949e;
}

.theme-dark .masthead-title small {
  color: #484f58;
}

.theme-dark .page-title,
.theme-dark .post-title,
.theme-dark .post-title a {
  color: #e6edf3;
}

.theme-dark .post-date {
  color: #8b949e;
}

.theme-dark .related {
  border-top-color: #21262d;
}

.theme-dark .related-posts li small {
  color: #6e7681;
}

.theme-dark .related-posts li a:hover {
  color: #58a6ff;
}

.theme-dark .pagination {
  color: #484f58;
}

.theme-dark .pagination-item {
  border-color: #30363d;
}

.theme-dark a.pagination-item:hover {
  background-color: #161b22;
  color: #e6edf3;
}

.theme-dark .sidebar-toggle {
  color: #c9d1d9;
  background-color: #21262d;
  border: 1px solid #30363d;
}

.theme-dark .sidebar-toggle:before {
  background-image: linear-gradient(to bottom, #c9d1d9, #c9d1d9 20%, #21262d 20%, #21262d 40%, #c9d1d9 40%, #c9d1d9 60%, #21262d 60%, #21262d 80%, #c9d1d9 80%, #c9d1d9 100%);
}

.theme-dark .sidebar-toggle:active,
.theme-dark #sidebar-checkbox:focus ~ .sidebar-toggle,
.theme-dark #sidebar-checkbox:checked ~ .sidebar-toggle {
  color: #0d1117;
  background-color: #c9d1d9;
}

.theme-dark .sidebar-toggle:active:before,
.theme-dark #sidebar-checkbox:focus ~ .sidebar-toggle:before,
.theme-dark #sidebar-checkbox:checked ~ .sidebar-toggle:before {
  background-image: linear-gradient(to bottom, #0d1117, #0d1117 20%, #c9d1d9 20%, #c9d1d9 40%, #0d1117 40%, #0d1117 60%, #c9d1d9 60%, #c9d1d9 80%, #0d1117 80%, #0d1117 100%);
}

.theme-dark .content-title h2 {
  color: #8b949e;
}

.theme-dark .muted {
  color: #6e7681 !important;
}

.theme-dark img {
  border: 1px solid #30363d;
}

/* Theme toggle button styles */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0;
  font-size: inherit;
  color: rgba(255,255,255,.6);
  width: 100%;
  text-align: left;
}

.theme-toggle:hover {
  color: #fff;
}

.theme-toggle-icon {
  display: inline-block;
  width: 1rem;
  margin-right: 0.5rem;
}