/* CSS Custom Properties */
:root {
  --primary-color: #3b82f6;
  --text-color: #1f2937;
  --bg-color: #ffffff;
  --border-color: #e5e7eb;
  --spacing: 1rem;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Base Styles */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--bg-color);
  padding: var(--spacing);
}

/* Header */
header {
  border-bottom: 2px solid var(--border-color);
  padding-bottom: var(--spacing);
  margin-bottom: calc(var(--spacing) * 2);
}

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

header h1 a {
  color: var(--primary-color);
  text-decoration: none;
}

nav {
  display: flex;
  gap: var(--spacing);
}

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

nav a:hover {
  color: var(--primary-color);
}

/* Container Layout */
.container {
  display: grid;
  grid-template-columns: 1fr;
  gap: calc(var(--spacing) * 2);
  max-width: 900px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
  }
}

/* Main Content */
main {
  min-width: 0;
  /* Prevents grid blowout */
}

/* Post Styles */
.post h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text-color);
}

.post-meta {
  margin-bottom: calc(var(--spacing) * 2);
  padding-bottom: var(--spacing);
  border-bottom: 1px solid var(--border-color);
}

.post-meta time {
  color: #6b7280;
  font-size: 0.9rem;
}

.post-tags {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  background: #f3f4f6;
  padding: 0.25rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--text-color);
}

.tag:hover {
  background: #e5e7eb;
}

/* Post Content */
.post-content {
  font-size: 1.1rem;
  line-height: 1.8;
}

.post-content h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.75rem;
}

.post-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.4rem;
}

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

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

.post-content code {
  background: #f3f4f6;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
}

.post-content pre {
  background: #1f2937;
  color: #f3f4f6;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1rem 0;
}

/* Post List (Home Page) */
.post-list {
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing) * 2);
}

.post-preview {
  padding-bottom: calc(var(--spacing) * 1.5);
  border-bottom: 1px solid var(--border-color);
}

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

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

.post-preview h3 a:hover {
  color: var(--primary-color);
}

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

.post-preview .tags {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Sidebar */
.sidebar {
  background: #f9fafb;
  padding: var(--spacing);
  border-radius: 0.5rem;
  align-self: start;
  position: sticky;
  top: var(--spacing);
}

.sidebar h3 {
  margin-bottom: var(--spacing);
  font-size: 1.2rem;
}

.tag-list {
  list-style: none;
}

.tag-list li {
  margin-bottom: 0.5rem;
}

.tag-list a {
  color: var(--text-color);
  text-decoration: none;
}

.tag-list a:hover {
  color: var(--primary-color);
}

.tag-list .count {
  color: #9ca3af;
  font-size: 0.85rem;
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 1rem;
}

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

.post-content th {
  background: #f3f4f6;
  font-weight: 600;
}

.post-content tr:last-child td {
  font-weight: 600;
}

/* Footer */
footer {
  margin-top: calc(var(--spacing) * 3);
  padding-top: var(--spacing);
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
}