/* ============================================
   Blog 2026 — Monospace-first stylesheet
   ============================================ */

/* --- Font Faces --- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-bold.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/caveat-bold.woff2') format('woff2');
}

/* --- CSS Custom Properties --- */
:root {
  --font-heading: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-body: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-code: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Type scale */
  --text-sm: 0.75rem;
  --text-base: 1rem;       /* 16px — monospace needs smaller base */
  --text-lg: 1.25rem;
  --text-xl: 1.563rem;
  --text-2xl: 1.953rem;
  --text-3xl: 2.441rem;

  /* Light mode colors */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-bg: #fafaf9;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #71717a;
  --color-border: #e4e4e7;
  --color-tag-bg: #f0f0ff;
  --color-tag-text: #4338ca;
  --color-code-bg: #f4f4f5;

  /* Spacing */
  --content-width: 75ch;
  --gutter: 1.5rem;
}

/* Dark mode */
.dark {
  --color-primary: #60a5fa;
  --color-primary-hover: #93bbfd;
  --color-bg: #18181b;
  --color-surface: #27272a;
  --color-text: #e4e4e7;
  --color-text-muted: #a1a1aa;
  --color-border: #3f3f46;
  --color-tag-bg: #1e1b4b;
  --color-tag-text: #a5b4fc;
  --color-code-bg: #1e1e1e;
}

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

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */
.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0.75rem var(--gutter);
}

/* --- Header --- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: 1rem var(--gutter);
}

.site-header .header-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-title {
  font-family: 'Caveat', cursive;
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.site-nav a {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

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

.site-nav a[aria-current="page"] {
  color: var(--color-primary);
  font-weight: 700;
}

/* Dark mode toggle */
.dark-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1;
  transition: color 0.2s, border-color 0.2s;
}

.dark-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem var(--gutter);
  text-align: center;
}

.site-footer .footer-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.site-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--color-primary);
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
}

.social-links a {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s, transform 0.2s;
  display: inline-block;
}

.social-links a:hover {
  transform: scale(1.15);
}

/* --- Links --- */
a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

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

/* --- Headings --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
}

h1 { font-size: var(--text-2xl); margin-bottom: 0.5em; }
h2 { font-size: var(--text-xl); margin-top: 1.75em; margin-bottom: 0.5em; }
h3 { font-size: var(--text-xl); margin-top: 1.5em; margin-bottom: 0.5em; }
h4 { font-size: var(--text-lg); margin-top: 1.5em; margin-bottom: 0.5em; }

/* --- Prose (article content) --- */
.prose p {
  margin-bottom: 1.25em;
}

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

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

.prose li > ul, .prose li > ol {
  margin-top: 0.5em;
  margin-bottom: 0;
}

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

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1.5em 0;
}

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

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95em;
}

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

.prose th {
  font-weight: 700;
  background: var(--color-surface);
}

/* Inline code — same font as body, distinguish with color */
.prose code:not(pre code) {
  font-family: var(--font-code);
  font-size: 0.9em;
  color: var(--color-primary);
}

/* Code blocks */
.prose pre {
  font-family: var(--font-code);
  font-size: 0.8125rem;
  line-height: 1.6;
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin: 1.5em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.prose a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

/* --- Post Card --- */
.post-card {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--color-border);
}

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

.post-card-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

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

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

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

.post-card-description {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

/* --- Post Header (single post page) --- */
.post-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.post-header h1 {
  margin-bottom: 0.75rem;
}

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

/* --- Tags --- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 400;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  padding: 0.1em 0.5em;
  border-radius: 0.25rem;
  text-decoration: none;
  text-transform: lowercase;
  transition: opacity 0.2s;
}

.tag:hover {
  opacity: 0.8;
  color: var(--color-tag-text);
}

/* Tag count badge */
.count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* --- Taxonomy Page Grids --- */
.taxonomy-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.taxonomy-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* --- Page Title --- */
.page-title {
  margin-bottom: 1.5rem;
}

/* --- Section: "View all" link --- */
.section-link {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--color-primary);
  text-decoration: none;
  margin-top: 1rem;
}

.section-link:hover {
  text-decoration: underline;
}

/* --- 404 --- */
.not-found {
  text-align: center;
  padding: 4rem 0;
}

.not-found h1 {
  font-size: 4rem;
  color: var(--color-text-muted);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  font-size: var(--text-sm);
}

.pagination a {
  color: var(--color-primary);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  transition: background-color 0.2s;
}

.pagination a:hover {
  background: var(--color-surface);
}

.pagination .current {
  color: var(--color-text-muted);
}

/* --- Embeds (Gists, Tweets) --- */
.prose .gist {
  margin: 1.5em 0;
}

.prose .gist .gist-file {
  border-radius: 0.5rem;
  border-color: var(--color-border);
}

.prose .gist .gist-data {
  border-bottom-color: var(--color-border);
}

.prose .twitter-tweet {
  margin: 1.5em auto !important;
}

/* --- Highlighter Markers --- */
.yellow-marker {
  background-color: rgba(255,241,118,0.5);
  padding: 0.1em 0.2em;
  border-radius: 0.15em;
}

.pink-marker {
  background-color: rgba(244,143,177,0.45);
  padding: 0.1em 0.2em;
  border-radius: 0.15em;
}

.green-marker {
  background-color: rgba(165,214,167,0.5);
  padding: 0.1em 0.2em;
  border-radius: 0.15em;
}

.dark .yellow-marker {
  background-color: rgba(255,241,118,0.3);
}

.dark .pink-marker {
  background-color: rgba(244,143,177,0.3);
}

.dark .green-marker {
  background-color: rgba(165,214,167,0.3);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  :root {
    --text-base: 0.9375rem;
    --text-3xl: 2rem;
    --text-2xl: 1.6rem;
    --text-xl: 1.3rem;
    --gutter: 1rem;
  }

  .site-header .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .post-card-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}
