:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;
  --max-width: 64rem;
  --prose-width: 42rem;
  --radius: 8px;
  --transition: 150ms ease;
}

[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #16161f;
  --text: #e4e4ed;
  --text-secondary: #8888a0;
  --border: #2a2a3a;
  --border-hover: #3a3a50;
  --accent: #7c5cfc;
  --accent-hover: #9b80fd;
  --tag-bg: #1e1e30;
  --tag-text: #9b80fd;
  --code-bg: #12121a;
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-secondary: #f0f0f5;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #64648a;
  --border: #e0e0ea;
  --border-hover: #c0c0d0;
  --accent: #5b3fd9;
  --accent-hover: #7c5cfc;
  --tag-bg: #eeeef5;
  --tag-text: #5b3fd9;
  --code-bg: #f0f0f5;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
}

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

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

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

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

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

.site-header nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

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

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: border-color var(--transition), color var(--transition);
}

#theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

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

/* Post Grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* Post Card */
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.post-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  color: var(--text);
}

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

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

.post-card-body time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-card-body h2 {
  font-size: 1.125rem;
  margin: 0.375rem 0 0.5rem;
  line-height: 1.3;
}

.post-card-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

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

.tag-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 9999px;
  font-weight: 500;
}

a.tag-pill:hover {
  background: var(--accent);
  color: #fff;
}

/* Post Page */
.post-header {
  max-width: var(--prose-width);
  margin: 0 auto 2rem;
}

.post-header time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-header h1 {
  font-size: 2rem;
  margin: 0.5rem 0;
  line-height: 1.2;
}

.post-header .post-description {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.post-hero {
  width: 100%;
  max-width: var(--prose-width);
  margin: 0 auto 2rem;
  display: block;
  border-radius: var(--radius);
}

/* Prose */
.prose {
  max-width: var(--prose-width);
  margin: 0 auto;
}

.prose h2 {
  font-size: 1.5rem;
  margin: 2.5rem 0 1rem;
}

.prose h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}

.prose p {
  margin: 1rem 0;
}

.prose img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin: 1rem 0;
}

.prose li {
  margin: 0.25rem 0;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

/* Code */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

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

.prose pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Syntax highlighting — Prism token overrides */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata { color: var(--text-secondary); }
.token.punctuation { color: var(--text-secondary); }
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol { color: #7ec8e3; }
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin { color: #a5d6a7; }
.token.operator,
.token.entity,
.token.url { color: var(--text-secondary); }
.token.atrule,
.token.attr-value,
.token.keyword { color: var(--accent); }
.token.function,
.token.class-name { color: #f0a0c0; }
.token.regex,
.token.important,
.token.variable { color: #ffcc80; }

/* YouTube embed */
.youtube-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin: 1.5rem 0;
  border-radius: var(--radius);
}

.youtube-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Responsive */
@media (max-width: 640px) {
  .post-grid {
    grid-template-columns: 1fr;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }

  main {
    padding: 1.5rem 1rem;
  }
}
