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

:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f9fafb;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-border: #e5e7eb;
  --color-code-bg: #f3f4f6;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --max-width: 720px;
  --spacing: 1.5rem;
}

[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-bg-alt: #1e293b;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-primary: #60a5fa;
  --color-primary-hover: #93c5fd;
  --color-border: #334155;
  --color-code-bg: #1e293b;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 1.05rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5em auto;
  border-radius: 4px;
}

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

main.container {
  padding-top: 3rem;
  padding-bottom: 4rem;
  min-height: calc(100vh - 200px);
}

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

.site-title:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.site-nav a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background-color 0.2s ease;
}

.theme-toggle:hover {
  background-color: var(--color-bg-alt);
}

/* ===== Home / Blog List ===== */
.home-header {
  margin-bottom: 3rem;
  text-align: center;
}

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

.home-description {
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.post-card {
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-border);
}

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

.post-card-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.post-card-title a {
  color: var(--color-text);
}

.post-card-title a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.post-card-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.separator {
  color: var(--color-border);
}

.tag {
  background-color: var(--color-bg-alt);
  padding: 0.1rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.post-card-excerpt {
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.read-more {
  font-weight: 500;
  font-size: 0.9rem;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.pagination-link {
  font-weight: 500;
}

.pagination-link.disabled {
  color: var(--color-text-muted);
  opacity: 0.5;
  pointer-events: none;
}

.pagination-info {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ===== Prose (markdown content) — shared wrapper for posts, pages, and standalone reports ===== */
.prose {
  font-size: 1.05rem;
  line-height: 1.75;
}

.prose h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.prose h2 {
  font-size: 1.6rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.prose h3 {
  font-size: 1.3rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.prose h4 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose ul,
.prose ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  font-style: italic;
}

.prose code {
  font-family: var(--font-mono);
  background-color: var(--color-code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.prose pre {
  background-color: var(--color-code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  display: block;
  overflow-x: auto;
}

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

.prose th {
  background-color: var(--color-bg-alt);
  font-weight: 600;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
}

/* ===== Post Page ===== */
.post-header {
  margin-bottom: 2.5rem;
  text-align: center;
}

.post-title {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.post-meta {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.75;
}

.post-content h2 {
  font-size: 1.6rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.post-content h3 {
  font-size: 1.3rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

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

.post-content ul,
.post-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  font-style: italic;
}

.post-content code {
  font-family: var(--font-mono);
  background-color: var(--color-code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.post-content pre {
  background-color: var(--color-code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

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

.post-content th {
  background-color: var(--color-bg-alt);
  font-weight: 600;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.back-link {
  font-weight: 500;
}

/* ===== Page (About) ===== */
.page-header {
  text-align: center;
  margin-bottom: 3rem;
}

.page-title {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.page-content {
  font-size: 1.05rem;
  line-height: 1.75;
}

.page-content h2 {
  font-size: 1.6rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.page-content p {
  margin-bottom: 1.25rem;
}

.page-content ul {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.page-content li {
  margin-bottom: 0.5rem;
}

/* ===== 404 Page ===== */
.error-page {
  text-align: center;
  padding: 4rem 0;
}

.error-code {
  font-size: 6rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}

.error-message {
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-size: 1.2rem;
}

.button {
  display: inline-block;
  background-color: var(--color-primary);
  color: white;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-weight: 500;
  transition: background-color 0.15s ease;
}

.button:hover {
  background-color: var(--color-primary-hover);
  color: white;
  text-decoration: none;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  background-color: var(--color-bg-alt);
  padding: 1.5rem 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.social-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-right {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .site-nav {
    gap: 1rem;
  }

  .post-title,
  .page-title {
    font-size: 1.75rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}
