/* Global Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-color: #fff;
  --text-color: #333;
  --border-color: #e0e0e0;
  --code-bg: #f5f5f5;
  --link-color: #0066cc;
  --header-border: #e0e0e0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  transition: background-color 0.3s, color 0.3s;
}

/* Dark Mode */
#dark-mode-checkbox {
  display: none;
}

.dark-mode-toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  cursor: pointer;
  margin-left: auto;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

#dark-mode-checkbox:checked + .toggle-slider {
  background-color: #4CAF50;
}

#dark-mode-checkbox:checked + .toggle-slider:before {
  transform: translateX(26px);
}

/* Dark mode styles */
body:has(#dark-mode-checkbox:checked) {
  --bg-color: #1a1a1a;
  --text-color: #e0e0e0;
  --border-color: #444;
  --code-bg: #2a2a2a;
  --link-color: #4a9eff;
  --header-border: #444;
}

body:has(#dark-mode-checkbox:checked) code {
  background-color: var(--code-bg);
  color: #e0e0e0;
}

body:has(#dark-mode-checkbox:checked) pre {
  background-color: var(--code-bg);
  border-color: var(--border-color);
}

body:has(#dark-mode-checkbox:checked) pre code {
  color: #e0e0e0;
}

body:has(#dark-mode-checkbox:checked) .post-tags .tag {
  background-color: #333;
  color: #e0e0e0;
}

body:has(#dark-mode-checkbox:checked) .post-tags .tag:hover {
  background-color: #444;
}

/* Header */
header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

header nav {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

header nav a:hover {
  text-decoration: underline;
}

header nav .home-link {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
}

header nav .home-link:hover {
  color: var(--link-color);
  text-decoration: none;
}

/* Main Content */
main {
  margin-bottom: 3rem;
}

/* Post Previews (Index Page) */
.post-preview {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

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

.post-preview h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.post-preview h2 a {
  color: var(--text-color);
  text-decoration: none;
}

.post-preview h2 a:hover {
  color: var(--link-color);
}

.post-preview time {
  color: #666;
  font-size: 0.9rem;
}

.post-preview .post-excerpt {
  color: #666;
  font-size: 0.95rem;
  margin-top: 0.75rem;
  line-height: 1.6;
}

/* Post Content */
.post {
  max-width: 100%;
}

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

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.post-date {
  color: #666;
  font-size: 0.95rem;
}

.reading-time {
  color: #666;
  font-size: 0.9rem;
  font-style: italic;
}

/* Tags */
.post-tags {
  margin-top: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.post-tags .tag {
  display: inline-block;
  padding: 0.25em 0.75em;
  background-color: #f0f0f0;
  color: #333;
  text-decoration: none;
  border-radius: 3px;
  font-size: 0.85rem;
  transition: background-color 0.2s;
}

.post-tags .tag:hover {
  background-color: #e0e0e0;
  text-decoration: none;
}

/* Tags Page */
.tag-section {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #e0e0e0;
}

.tag-section:last-child {
  border-bottom: none;
}

.tag-section h2 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.tag-count {
  font-size: 1rem;
  color: #666;
  font-weight: normal;
}

.tag-posts {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
}

.tag-posts li {
  margin-bottom: 0.75rem;
  padding-left: 0;
}

.tag-posts li a {
  color: #333;
  text-decoration: none;
}

.tag-posts li a:hover {
  color: #0066cc;
  text-decoration: underline;
}

.tag-posts li time {
  color: #666;
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

/* Archive Page */
.archive-year {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #ddd;
}

.archive-year:last-child {
  border-bottom: none;
}

.archive-year h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: #333;
}

.archive-month {
  margin-bottom: 2rem;
  margin-left: 1rem;
}

.archive-month h3 {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
  color: #555;
}

.archive-posts {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
}

.archive-posts li {
  margin-bottom: 0.5rem;
  padding-left: 0;
}

.archive-posts li a {
  color: #333;
  text-decoration: none;
}

.archive-posts li a:hover {
  color: #0066cc;
  text-decoration: underline;
}

.archive-posts li time {
  color: #666;
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

/* Author Bio */
.author-bio {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 3rem;
  padding: 1.5rem;
  background-color: var(--code-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-avatar.placeholder {
  background-color: var(--link-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
}

.author-info h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  margin-top: 0;
}

.author-info p {
  color: #666;
  line-height: 1.6;
  margin-bottom: 0;
}

@media (max-width: 600px) {
  .author-bio {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

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

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

h2 {
  font-size: 1.8rem;
}

h3 {
  font-size: 1.4rem;
}

h4 {
  font-size: 1.2rem;
}

p {
  margin-bottom: 1em;
}

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

a:hover {
  text-decoration: underline;
}

ul, ol {
  margin-left: 1.5em;
  margin-bottom: 1em;
}

li {
  margin-bottom: 0.5em;
}

blockquote {
  border-left: 4px solid var(--border-color);
  padding-left: 1em;
  margin-left: 0;
  margin-bottom: 1em;
  color: #666;
  font-style: italic;
}

/* Code Blocks */
code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
  font-size: 0.9em;
}

/* Inline code */
p code,
li code,
td code {
  background-color: var(--code-bg);
  padding: 0.25em 0.5em;
  border-radius: 4px;
  color: #d14;
  font-size: 0.9em;
  border: 1px solid var(--border-color);
}

/* Code blocks */
pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.25em;
  overflow-x: auto;
  margin-bottom: 1.5em;
  margin-top: 1em;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  color: var(--text-color);
  display: block;
  white-space: pre;
  font-size: 0.9em;
}

/* Language-specific code block hints (via class) */
pre code.language-javascript,
pre code.language-js {
  color: #e0e0e0;
}

pre code.language-css {
  color: #e0e0e0;
}

pre code.language-html {
  color: #e0e0e0;
}

pre code.language-bash,
pre code.language-shell {
  color: #e0e0e0;
}

body:not(:has(#dark-mode-checkbox:checked)) pre code {
  color: #333;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}

th, td {
  padding: 0.5em;
  border: 1px solid var(--border-color);
  text-align: left;
}

th {
  background-color: var(--code-bg);
  font-weight: 600;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  margin-bottom: 1em;
  border-radius: 4px;
}

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

/* Footer */
footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 600px) {
  body {
    padding: 15px;
  }
  
  .post h1 {
    font-size: 2rem;
  }
  
  header h1 {
    font-size: 1.5rem;
  }
}
