/* Modern CSS Reset & Variables */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --text-primary: #1a1a1a;
  --text-secondary: #6c757d;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --border: #e9ecef;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  --transition: all 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --accent: #4da6ff;
    --accent-hover: #66b3ff;
    --border: #404040;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header Styles */
header {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 2rem 0;
  margin-bottom: 3rem;
  box-shadow: 0 2px 4px var(--shadow);
}

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

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

header h1 a:hover {
  color: var(--accent);
}

header p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin: 0;
}

header .header-contact {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

header .header-contact a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

header .header-contact a:hover {
  color: var(--accent);
}

header .header-contact .sep {
  color: var(--text-secondary);
  opacity: 0.6;
  margin: 0 0.5rem;
}

/* Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
  line-height: 1.8;
  font-size: 18px;
}

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

h1 {
  font-size: 2.5rem;
  margin-top: 0;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
}

p {
  margin-bottom: 1.5rem;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Home Page Styles */
.home {
  padding: 0;
}

.page-heading {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
}

.post-list-heading {
  font-size: 1.75rem;
  margin-top: 3rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
}

.post-list-heading a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

.post-list-heading a:hover {
  color: var(--accent);
}

.view-all {
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.view-all a {
  color: var(--accent);
  text-decoration: none;
}

.view-all a:hover {
  text-decoration: underline;
}

.category-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

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

.post-list li {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: var(--transition);
  box-shadow: 0 2px 4px var(--shadow);
}

.post-list li:hover {
  box-shadow: 0 4px 12px var(--shadow-hover);
  transform: translateY(-2px);
}

.post-meta {
  display: block;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.post-link {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}

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

.rss-subscribe {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Post Content Styles */
main article,
main .post-content {
  background-color: var(--bg-primary);
  border-radius: 8px;
  padding: 2.5rem;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 2rem;
}

main > :not(article):not(.post-content) {
  background-color: var(--bg-primary);
  border-radius: 8px;
  padding: 2.5rem;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 2rem;
}

/* Code Blocks */
pre {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

code {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Source Code Pro', monospace;
  font-size: 0.9em;
  background-color: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

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

/* Math Blocks */
mjx-container {
  max-width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
}

/* Comments Section */
#comments {
  background-color: var(--bg-primary);
  border-radius: 8px;
  padding: 2rem;
  margin-top: 3rem;
  box-shadow: 0 2px 8px var(--shadow);
}

/* Footer */
footer {
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

footer p {
  margin: 0;
}

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

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

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

li {
  margin-bottom: 0.5rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
    font-size: 16px;
  }

  header {
    padding: 1.5rem 0;
    margin-bottom: 2rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  main article,
  main .post-content,
  main > :not(article):not(.post-content) {
    padding: 1.5rem;
  }

  .post-list li {
    padding: 1.25rem;
  }
}