/* CSS Custom Properties - Theme System */

/* Default theme (dark) */
:root {
  --bg: #0a0a0a;
  --fg: #fafafa;
  --muted: #a1a1aa;
  --accent: #a855f7;
  --border: #27272a;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #fafafa;
  --muted: #a1a1aa;
  --accent: #a855f7;
  --border: #27272a;
}

/* Light theme */
[data-theme="light"] {
  --bg: #fafafa;
  --fg: #18181b;
  --muted: #71717a;
  --accent: #a855f7;
  --border: #e4e4e7;
}

/* Base Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Typography */
html {
  font-size: 16px;
  line-height: 1.6;
}

body {
  font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--fg);
  background-color: var(--bg);
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.125rem;
}

/* Paragraphs and text */
p {
  margin-bottom: 1rem;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Muted text utility */
.muted {
  color: var(--muted);
}

/* Code */
code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9em;
  background-color: var(--border);
  padding: 0.125em 0.25em;
  border-radius: 4px;
}

pre {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  background-color: var(--border);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

pre code {
  background-color: transparent;
  padding: 0;
}

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

li {
  margin-bottom: 0.25rem;
}

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin-left: 0;
  margin-bottom: 1rem;
  color: var(--muted);
  font-style: italic;
}

/* Horizontal rule */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Container utility */
.container {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Selection styling */
::selection {
  background-color: var(--accent);
  color: var(--bg);
}

/* Site Header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  max-width: 42rem;
  margin: 0 auto;
}

/* Site Navigation */
.site-nav {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: color 0.2s ease;
}

.nav-link:hover {
  color: var(--fg);
  text-decoration: none;
  opacity: 1;
}

.nav-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-link--active {
  color: var(--accent);
}

/* Theme Toggle Button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background-color: var(--border);
}

.theme-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Show sun icon in dark mode, moon icon in light mode */
[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

[data-theme="light"] .icon-sun {
  display: none;
}

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

/* Main content wrapper */
main {
  padding: 0 1rem 2rem;
  max-width: 42rem;
  margin: 0 auto;
}

/* Social Links */
.social-links {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.social-link:hover {
  border-color: var(--accent);
  background-color: var(--border);
  text-decoration: none;
  opacity: 1;
}

.social-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.social-link svg {
  flex-shrink: 0;
}

/* Site Footer */
.site-footer {
  padding: 2rem 1rem;
  max-width: 42rem;
  margin: 0 auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin-bottom: 0.75rem;
}

.rss-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--muted);
  font-size: 0.875rem;
  transition: color 0.2s ease;
}

.rss-link:hover {
  color: var(--accent);
  text-decoration: none;
  opacity: 1;
}

.rss-link svg {
  flex-shrink: 0;
}

/* Blog Post Layout */
.post {
  max-width: 65ch; /* Optimal readable line length */
  margin: 0 auto;
}

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

.post-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.post-date {
  display: block;
  color: var(--muted);
  font-size: 0.875rem;
}

.post-content {
  line-height: 1.7;
}

.post-content h2 {
  margin-top: 2rem;
}

.post-content h3 {
  margin-top: 1.5rem;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.post-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Blog List Page */
.blog-list {
  max-width: 65ch;
  margin: 0 auto;
}

.blog-list h1 {
  margin-bottom: 1.5rem;
}

.post-list {
  list-style: none;
  padding-left: 0;
}

.post-item {
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.post-item:last-child {
  border-bottom: none;
}

.post-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 0;
  color: var(--fg);
  text-decoration: none;
  transition: color 0.2s ease;
}

.post-link:hover {
  color: var(--accent);
  text-decoration: none;
  opacity: 1;
}

.post-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.post-item-title {
  font-weight: 500;
}

.post-item-date {
  color: var(--muted);
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* Reading List Page */
.reading-list {
  max-width: 65ch;
  margin: 0 auto;
}

.reading-list h1 {
  margin-bottom: 0.5rem;
}

.reading-list > p {
  color: var(--muted);
  margin-bottom: 2rem;
}

.reading-list h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.book-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.book-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.book-item:last-child {
  border-bottom: none;
}

.book-title {
  font-weight: 500;
  color: var(--fg);
}

.book-author {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Homepage */
.homepage {
  max-width: 65ch;
  margin: 0 auto;
}

.home-section {
  margin-top: 3rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.section-header h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.view-all-link {
  font-size: 0.875rem;
  color: var(--accent);
}

.home-post-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.home-post-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.home-post-item:last-child {
  border-bottom: none;
}

.home-post-link {
  color: var(--fg);
  font-weight: 500;
}

.home-post-link:hover {
  color: var(--accent);
  text-decoration: none;
  opacity: 1;
}

.home-book-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.home-book-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.home-book-item:last-child {
  border-bottom: none;
}
