/* ========== DESIGN TOKENS ========== */
:root {
  --color-bg: #0d1117;
  --color-bg-surface: #161b22;
  --color-bg-elevated: #1c2128;
  --color-border: #30363d;
  --color-text: #e6edf3;
  --color-text-muted: #8b949e;
  --color-text-subtle: #6e7681;
  --color-accent: #2d6a9f;
  --color-accent-light: #58a6ff;
  --color-accent-hover: #1f4e7a;
  --color-amber: #d4a851;
  --color-success: #3fb950;
  --color-danger: #f85149;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius: 6px;
  --radius-lg: 12px;
  --container-max: 820px;
  --container-wide: 1200px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ========== ACCESSIBILITY ========== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.5rem 1rem;
  background: var(--color-accent);
  color: var(--color-text);
  border-radius: var(--radius);
  z-index: 999;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 1rem;
}

/* ========== LAYOUT ========== */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  flex: 1;
}

/* ========== HEADER ========== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.site-header .container {
  max-width: var(--container-wide);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 1rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.logo-mark {
  color: var(--color-accent-light);
  font-family: var(--font-mono);
  font-size: 1.1rem;
}

.logo-text {
  font-size: 1rem;
}

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

.site-header nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.site-header nav a:hover {
  color: var(--color-text);
}

/* ========== HERO ========== */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}

.hero-eyebrow {
  color: var(--color-accent-light);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero p {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  max-width: 55ch;
  margin: 0 auto;
}

/* ========== POST CARD ========== */
.posts-grid {
  padding: 3rem 0;
}

.posts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.post-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.post-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

.post-card-image img {
  width: 100%;
  height: 240px;
  object-fit: cover;
}

.post-card-body {
  padding: 1.5rem;
}

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

.post-card-meta time {
  color: var(--color-text-subtle);
  font-size: 0.85rem;
}

.post-card-title {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.post-card-title a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.15s;
}

.post-card-title a:hover {
  color: var(--color-accent-light);
}

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

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ========== BADGES & TAGS ========== */
.category-badge {
  display: inline-flex;
  align-items: center;
  background: var(--color-accent-hover);
  color: var(--color-accent-light);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: background 0.15s;
}

.category-badge:hover {
  background: var(--color-accent);
}

.tag {
  display: inline-flex;
  align-items: center;
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 0.1rem 0.65rem;
  font-size: 0.8rem;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.tag:hover {
  border-color: var(--color-accent-light);
  color: var(--color-accent-light);
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(212, 168, 81, 0.1);
  color: var(--color-amber);
  border: 1px solid rgba(212, 168, 81, 0.3);
  border-radius: var(--radius);
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin-top: 1rem;
}

/* ========== POST PAGE ========== */
.post-header {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--color-border);
}

.post-meta-top {
  margin-bottom: 1.25rem;
}

.post-title {
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}

.post-subtitle {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  font-style: italic;
}

.post-excerpt {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 1rem;
  max-width: 65ch;
}

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

.post-meta strong {
  color: var(--color-text-muted);
}

.updated-note {
  font-size: 0.85rem;
}

.post-image {
  margin: 2rem auto;
}

.post-image img {
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border: 1px solid var(--color-border);
}

.ai-disclosure {
  margin: 1.5rem auto;
  padding: 0.75rem 1rem;
  background: rgba(212, 168, 81, 0.06);
  border: 1px solid rgba(212, 168, 81, 0.2);
  border-radius: var(--radius);
  color: var(--color-amber);
  font-size: 0.875rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.ai-disclosure-icon {
  flex-shrink: 0;
}

/* ========== PROSE (post content) ========== */
.post-content {
  padding: 2.5rem 0;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.post-content h2 {
  font-size: 1.6rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.4rem;
}

.post-content h3 {
  font-size: 1.25rem;
  color: var(--color-text-muted);
}

.post-content h4 {
  font-size: 1.05rem;
}

.post-content p {
  margin-bottom: 1.25rem;
  max-width: 70ch;
}

.post-content a {
  color: var(--color-accent-light);
  text-decoration: underline;
  text-decoration-color: rgba(88, 166, 255, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

.post-content a:hover {
  text-decoration-color: var(--color-accent-light);
}

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

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

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

.post-content strong {
  color: var(--color-text);
  font-weight: 600;
}

.post-content em {
  font-style: italic;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}

.post-content th {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  padding: 0.6rem 0.9rem;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--color-border);
}

.post-content td {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  vertical-align: top;
}

.post-content tr:nth-child(even) td {
  background: var(--color-bg-surface);
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--color-text);
}

.post-content pre {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  max-width: 100%;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

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

/* Mermaid diagrams */
.post-content img[src^="data:image/svg"] {
  max-width: 100%;
  background: var(--color-bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 1rem;
  margin: 1.5rem 0;
}

/* ========== REFERENCES ========== */
.post-references {
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
}

.references h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.reference-list {
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.reference-list li {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ========== POST FOOTER ========== */
.post-footer {
  padding: 1.5rem 0 3rem;
}

.back-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--color-accent-light);
}

/* ========== ARCHIVE / LISTING ========== */
.page-header {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--color-text-muted);
}

.listing-filters {
  padding: 1.5rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
}

/* ========== CATEGORIES PAGE ========== */
.categories-grid {
  padding: 3rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.category-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.category-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.category-card .count {
  color: var(--color-text-subtle);
  font-size: 0.85rem;
}

/* ========== PAGINATION ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem 0;
}

.pagination a,
.pagination span {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: border-color 0.15s, color 0.15s;
}

.pagination a:hover,
.pagination a[aria-current] {
  border-color: var(--color-accent-light);
  color: var(--color-accent-light);
}

/* ========== FOOTER ========== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  color: var(--color-text-subtle);
  font-size: 0.875rem;
  text-align: center;
}

.site-footer .container {
  max-width: var(--container-wide);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.site-footer strong {
  color: var(--color-text-muted);
}

.footer-meta {
  color: var(--color-text-subtle);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
  .hero {
    padding: 3rem 0 2rem;
  }

  .post-title {
    font-size: 1.6rem;
  }

  .post-card-image img {
    height: 180px;
  }

  .site-header .container {
    padding-block: 0.75rem;
  }

  .site-header nav {
    gap: 1rem;
  }
}
