@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --background: 220 15% 10%;
  --foreground: 220 10% 85%;
  --card: 220 15% 13%;
  --card-foreground: 220 10% 85%;
  --popover: 220 15% 13%;
  --popover-foreground: 220 10% 85%;
  --primary: 200 60% 55%;
  --primary-foreground: 220 15% 10%;
  --secondary: 220 12% 18%;
  --secondary-foreground: 220 10% 75%;
  --muted: 220 12% 16%;
  --muted-foreground: 220 10% 50%;
  --accent: 200 60% 55%;
  --accent-foreground: 220 15% 10%;
  --destructive: 0 62% 50%;
  --destructive-foreground: 0 0% 98%;
  --border: 220 12% 20%;
  --input: 220 12% 20%;
  --ring: 200 60% 55%;
  --radius: 0.375rem;
  --sidebar-background: 220 15% 8%;
  --sidebar-foreground: 220 10% 70%;
  --sidebar-primary: 200 60% 55%;
  --sidebar-primary-foreground: 220 15% 10%;
  --sidebar-accent: 220 12% 14%;
  --sidebar-accent-foreground: 220 10% 85%;
  --sidebar-border: 220 12% 16%;
  --sidebar-ring: 200 60% 55%;
  --tag-bg: 220 12% 18%;
  --tag-foreground: 200 40% 65%;
  --code-bg: 220 15% 8%;
  --code-border: 220 12% 20%;
  --link: 200 60% 55%;
}

* {
  border-color: hsl(var(--border));
}

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  color: hsl(var(--foreground));
  font-weight: 600;
  letter-spacing: -0.025em;
}

a {
  color: hsl(var(--link));
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: hsl(var(--sidebar-background));
  border-right: 1px solid hsl(var(--sidebar-border));
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar.collapsed {
  width: 64px;
  padding: 24px 8px;
}

.sidebar.collapsed .profile .tagline,
.sidebar.collapsed .profile h1,
.sidebar.collapsed .social {
  display: none;
}

.sidebar.collapsed .profile {
  justify-content: center;
}

.sidebar.collapsed .avatar {
  margin: 0 auto;
}

.sidebar.collapsed .menu a span {
  display: none;
}

.sidebar.collapsed .menu a {
  justify-content: center;
  padding: 10px;
}

.profile {
  padding: 0 8px;
  margin-bottom: 24px;
}

.profile a {
  text-decoration: none;
  color: inherit;
  display: block;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-bottom: 12px;
}

.profile h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: hsl(var(--sidebar-accent-foreground));
}

.tagline {
  font-size: 13px;
  color: hsl(var(--sidebar-foreground));
  margin: 0;
}

/* Menu */
.menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 15px;
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.menu a:hover {
  background: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-accent-foreground));
}

.menu a.active {
  background: hsl(var(--sidebar-accent));
  color: hsl(var(--sidebar-accent-foreground));
  font-weight: 500;
}

.menu svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Social */
.social {
  margin-top: auto;
  display: flex;
  gap: 12px;
  padding: 0 8px;
  padding-bottom: 8px;
}

.social a {
  color: hsl(var(--sidebar-foreground));
  transition: color 0.2s ease;
}

.social a:hover {
  color: hsl(var(--sidebar-accent-foreground));
}

.social svg {
  width: 20px;
  height: 20px;
}

/* Sidebar trigger for mobile */
.sidebar-trigger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  color: hsl(var(--foreground));
}

.sidebar-trigger svg {
  width: 18px;
  height: 18px;
}

/* Content area */
.content {
  flex: 1;
  padding: 48px;
}

.content p {
  line-height: 1.7;
  margin-bottom: 16px;
}

/* Limit home and about width */
.hero,
.about-content,
.content > section {
  max-width: 72ch;
}

/* Posts page width */
.posts-page {
  max-width: 72ch;
}

/* Hero section (Home) */
.hero {
  margin-bottom: 48px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero p {
  font-size: 18px;
  color: hsl(var(--muted-foreground));
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.section-header a {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: hsl(var(--primary));
}

.section-header a svg {
  width: 12px;
  height: 12px;
}

/* Post list */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.post-item {
  padding-bottom: 24px;
  border-bottom: 1px solid hsl(var(--border));
}

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

.post-item h3 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 4px;
}

.post-item h3 a {
  color: hsl(var(--foreground));
  transition: color 0.2s ease;
}

.post-item h3 a:hover {
  color: hsl(var(--primary));
}

.post-date {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  display: block;
  margin-bottom: 8px;
}

.post-excerpt {
  font-size: 15px;
  color: hsl(var(--secondary-foreground));
  line-height: 1.6;
  margin-bottom: 12px;
}

/* Tags */
.tag {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  background: hsl(var(--tag-bg));
  color: hsl(var(--tag-foreground));
  border-radius: 4px;
  transition: opacity 0.2s ease;
  line-height: 1.4;
}

.tag:hover {
  opacity: 0.8;
  text-decoration: none;
}

/* Tag filters - clickable buttons */
.tag-filters .tag {
  all: unset;
  cursor: pointer;
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  background: hsl(var(--tag-bg));
  color: hsl(var(--tag-foreground));
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
  text-decoration: none;
}

.tag-filters .tag:hover {
  opacity: 0.8;
}

.tag-filters .tag.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Post item tags - visual badges */
.post-item .tags .tag {
  background: hsl(var(--tag-bg));
  color: hsl(var(--tag-foreground));
  cursor: default;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* Posts page */
.posts-page {
  max-width: 72ch;
}

.posts-header {
  margin-bottom: 32px;
}

.posts-header h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
}

.posts-header p {
  color: hsl(var(--muted-foreground));
  font-size: 15px;
  margin-bottom: 20px;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
  line-height: 2;
}

.tag-filters .tag {
  cursor: pointer;
  all: unset;
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  background: hsl(var(--tag-bg));
  color: hsl(var(--tag-foreground));
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
  text-decoration: none;
}

.tag-filters .tag:hover {
  opacity: 0.8;
}

.tag-filters .tag.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Post detail */
.post-detail {
  width: 100%;
}

.post-detail .back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 24px;
  text-decoration: none;
}

.post-detail .back-link:hover {
  color: hsl(var(--foreground));
}

.post-detail .back-link svg {
  width: 12px;
  height: 12px;
}

.post-detail header {
  margin-bottom: 32px;
}

.post-detail h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.2;
}

.post-detail .post-meta {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 16px;
}

.post-detail .tags {
  margin-bottom: 0;
}

/* Post detail with TOC layout */
.post-with-toc {
  display: flex;
  gap: 32px;
}

.post-with-toc .post-detail {
  flex: 1;
  min-width: 0;
  max-width: 72ch;
}

/* Table of Contents */
.toc {
  width: 224px;
  flex-shrink: 0;
  display: none;
}

@media (min-width: 1280px) {
  .toc {
    display: block;
  }
}

.toc-content {
  position: sticky;
  top: 80px;
}

.toc-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  margin-bottom: 12px;
}

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

.toc li {
  margin-bottom: 6px;
}

.toc a {
  display: block;
  padding: 2px 0;
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  transition: color 0.2s ease;
  line-height: 1.4;
}

.toc a:hover {
  color: hsl(var(--foreground));
}

.toc a.active {
  color: hsl(var(--primary));
  font-weight: 500;
}

.toc .toc-h3 {
  padding-left: 12px;
}

.toc .toc-h4 {
  padding-left: 24px;
}

/* Prose / Markdown - 72ch like Lovable */
.prose {
  line-height: 1.7;
  color: hsl(var(--foreground));
  max-width: 72ch;
}

.prose h1 { font-size: 30px; font-weight: 700; margin: 40px 0 16px; }
.prose h2 { font-size: 24px; font-weight: 600; margin: 32px 0 12px; border-bottom: 1px solid hsl(var(--border)); padding-bottom: 8px; }
.prose h3 { font-size: 20px; font-weight: 600; margin: 24px 0 8px; }
.prose h4 { font-size: 18px; font-weight: 600; margin: 20px 0 8px; }
.prose p { margin-bottom: 16px; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose ul, .prose ol { margin-bottom: 16px; padding-left: 24px; }
.prose li { margin-bottom: 4px; }
.prose blockquote {
  border-left: 2px solid hsl(var(--primary));
  padding-left: 16px;
  font-style: italic;
  color: hsl(var(--muted-foreground));
  margin: 16px 0;
}
.prose > p:first-of-type img,
.prose img:first-child {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 0 24px 0;
}
.prose img:not(:first-child) { max-width: 100%; border-radius: 8px; margin: 24px 0; }
.prose hr { border: none; border-top: 1px solid hsl(var(--border)); margin: 32px 0; }
.prose strong { font-weight: 600; }

/* Inline code */
.prose code:not(pre code) {
  background: hsl(var(--code-bg));
  border: 1px solid hsl(var(--code-border));
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  font-family: "JetBrains Mono", monospace;
  color: hsl(var(--primary));
}

/* Code blocks */
.prose pre {
  background: hsl(var(--code-bg)) !important;
  border: 1px solid hsl(var(--code-border));
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 24px 0;
}

.prose pre code {
  font-size: 14px;
  font-family: "JetBrains Mono", monospace;
  line-height: 1.6;
  color: hsl(var(--foreground));
  background: transparent;
}

/* Previous / Next navigation */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid hsl(var(--border));
}

.post-nav a {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
}

.post-nav a:hover {
  color: hsl(var(--foreground));
}

.post-nav a span {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.post-nav a strong {
  color: hsl(var(--foreground));
  font-weight: 500;
  display: block;
}

.post-nav a:hover strong {
  color: hsl(var(--primary));
}

.post-nav .next {
  text-align: right;
}

.post-nav .next span {
  justify-content: flex-end;
}

/* About page */
.about-content h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 24px;
}

.about-content p {
  font-size: 16px;
  color: hsl(var(--secondary-foreground));
  line-height: 1.7;
  margin-bottom: 16px;
}

.about-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
  color: hsl(var(--foreground));
}

.about-content ul {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.about-content li {
  font-size: 14px;
  font-family: "JetBrains Mono", monospace;
  color: hsl(var(--muted-foreground));
  margin-bottom: 8px;
}

.about-content li span {
  color: hsl(var(--primary));
  margin-right: 8px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 0;
}

.empty-state p {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 40;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-trigger {
    display: flex;
  }

  .content {
    padding: 24px 16px;
    padding-top: 60px;
  }

  .hero h1, .posts-header h1, .post-detail h1, .about-content h1 {
    font-size: 28px;
  }

  .post-with-toc {
    flex-direction: column;
  }

  .toc {
    display: none;
  }
}
