/* Google Font - IBM Plex Mono for typewriter feel */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* Reset and base styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1a1a1a;
  --text-primary: #e5e5e5;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --accent: #a855f7;
  --accent-hover: #c084fc;
  --border: #262626;
  --code-bg: #1e1e1e;
  --code-text: #d4d4d4;
  --hash-color: #525252;
  --font-mono: 'IBM Plex Mono', 'Courier New', Courier, monospace;
  --font-sans: 'IBM Plex Mono', 'Courier New', Courier, monospace;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
}

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container-wide {
  max-width: 900px;
}

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

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

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

nav {
  margin-top: 0.75rem;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  margin-right: 1.5rem;
  font-size: 0.9rem;
}

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

/* Author section */
.author-section {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 3rem;
}

.author-photo {
  width: 140px;
  height: 140px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: center top;
}

.author-info h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.author-info .tagline {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.author-info p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Directory listing */
.directory {
  margin-top: 2rem;
}

.directory h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.directory ul {
  list-style: none;
}

.directory li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.directory li:last-child {
  border-bottom: none;
}

.directory a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

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

.directory .date {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

.directory .description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: block;
  margin-top: 0.25rem;
}

/* Blog post styles */
article {
  margin-bottom: 4rem;
}

article header {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 2rem;
}

article h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

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

article .meta a {
  color: var(--text-secondary);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.4;
}

/* Hash symbol prefix for headings */
article h1::before {
  content: '# ';
  color: var(--hash-color);
  font-weight: 400;
}

article h2::before {
  content: '## ';
  color: var(--hash-color);
  font-weight: 400;
}

article h3::before {
  content: '### ';
  color: var(--hash-color);
  font-weight: 400;
}

article h4::before {
  content: '#### ';
  color: var(--hash-color);
  font-weight: 400;
}

h2 {
  font-size: 1.5rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

h3 {
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h4 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

/* Anchor link target highlight */
h2:target,
h3:target,
h4:target {
  animation: highlight-fade 2s ease-out;
}

@keyframes highlight-fade {
  0% { background-color: rgba(168, 85, 247, 0.2); }
  100% { background-color: transparent; }
}

p {
  margin-bottom: 1.25rem;
}

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

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

strong {
  font-weight: 600;
  color: var(--text-primary);
}

em {
  font-style: italic;
}

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

li {
  margin-bottom: 0.5rem;
}

li > ul,
li > ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Table of Contents */
.toc {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2rem 0;
}

.toc-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.toc-title::before {
  content: none;
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.toc li {
  margin-bottom: 0.5rem;
  padding-left: 0;
}

.toc li:last-child {
  margin-bottom: 0;
}

.toc a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.toc a:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc a::before {
  content: '• ';
  color: var(--hash-color);
}

/* Nested TOC items */
.toc ul ul {
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

.toc ul ul a::before {
  content: '◦ ';
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--bg-tertiary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  color: var(--code-text);
}

pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  display: block;
}

/* Syntax highlighting colors */
pre .comment { color: #6a9955; }
pre .keyword { color: #569cd6; }
pre .string { color: #ce9178; }
pre .number { color: #b5cea8; }
pre .function { color: #dcdcaa; }
pre .operator { color: #d4d4d4; }
pre .variable { color: #9cdcfe; }

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  background-color: var(--bg-secondary);
  border-radius: 0 8px 8px 0;
}

blockquote p {
  color: var(--text-primary);
  font-style: normal;
  margin-bottom: 0.5rem;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Nested headings in blockquotes */
blockquote h3,
blockquote h4 {
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

blockquote h3::before,
blockquote h4::before {
  color: var(--hash-color);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

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

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

tr:hover {
  background-color: var(--bg-secondary);
}

/* Figures and charts */
figure {
  margin: 2rem 0;
  padding: 0;
}

figure img,
figure svg {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

figcaption {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 0.75rem;
  font-style: italic;
}

/* Horizontal rule */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

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

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  margin-top: 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer a {
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 1.5rem 1rem;
  }

  .author-section {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .author-photo {
    width: 120px;
    height: 120px;
  }

  article h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  pre {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.5rem;
  }
}
