/* ============================================================
   CSS Custom Properties — Light & Dark Themes
   ============================================================ */
:root,
[data-theme="light"] {
  --color-bg:          #ffffff;
  --color-bg-secondary: #f8f9fa;
  --color-bg-tertiary:  #f0f2f5;
  --color-surface:     #ffffff;
  --color-border:      #e2e8f0;
  --color-border-subtle: #edf2f7;
  --color-text:        #1a202c;
  --color-text-secondary: #4a5568;
  --color-text-tertiary:  #718096;
  --color-accent:      #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-subtle: #eff6ff;
  --color-tag-bg:      #e2e8f0;
  --color-tag-text:    #4a5568;
  --color-code-bg:     #f6f8fa;
  --color-code-border: #e2e8f0;
  --color-link:        #2563eb;
  --color-link-hover:  #1d4ed8;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --max-width:   720px;
  --max-width-wide: 1100px;
}

[data-theme="dark"] {
  --color-bg:          #0f1117;
  --color-bg-secondary: #161b22;
  --color-bg-tertiary:  #1c2128;
  --color-surface:     #161b22;
  --color-border:      #30363d;
  --color-border-subtle: #21262d;
  --color-text:        #e6edf3;
  --color-text-secondary: #8b949e;
  --color-text-tertiary:  #6e7681;
  --color-accent:      #58a6ff;
  --color-accent-hover: #79b8ff;
  --color-accent-subtle: #132138;
  --color-tag-bg:      #21262d;
  --color-tag-text:    #8b949e;
  --color-code-bg:     #161b22;
  --color-code-border: #30363d;
  --color-link:        #58a6ff;
  --color-link-hover:  #79b8ff;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
}

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

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

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

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

/* ============================================================
   Site Header / Nav
   ============================================================ */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-container {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-links a:hover {
  color: var(--color-text);
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-text-tertiary);
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
}

/* ============================================================
   Home Page
   ============================================================ */
.home-hero {
  padding: 4rem 0 3rem;
  text-align: center;
}

.hero-name {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  line-height: 1.1;
}

.hero-tagline {
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  margin-bottom: 2rem;
  font-weight: 400;
}

.social-links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}

.social-link:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  text-decoration: none;
}

.home-content {
  margin-bottom: 3rem;
}

.home-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 3rem;
}

.section-card {
  display: block;
  padding: 2rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.section-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--color-accent-subtle) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.section-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.section-card:hover::before {
  opacity: 1;
}

.section-card-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: block;
}

.section-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.section-card p {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.card-cta {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent);
}

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

.page-header h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--color-text-secondary);
  font-size: 1rem;
}

/* ============================================================
   Blog Post List
   ============================================================ */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.post-card {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

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

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

.reading-time {
  padding: 0.15rem 0.5rem;
  background: var(--color-bg-secondary);
  border-radius: 100px;
  font-size: 0.75rem;
}

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

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

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

.post-card-summary {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

/* ============================================================
   Tags
   ============================================================ */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ============================================================
   Blog/Project Single Post
   ============================================================ */
.post-article {
  max-width: 100%;
}

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text-tertiary);
}

.post-title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--color-text);
  margin-bottom: 1rem;
  line-height: 1.15;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.back-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
}

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

/* ============================================================
   Projects List
   ============================================================ */
.projects-index {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 3rem;
}

.project-index-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border-subtle);
  gap: 1rem;
}

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

.project-index-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  flex: 1;
}

.project-index-link:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.project-index-item time {
  font-size: 0.8rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.project-card {
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

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

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.project-card-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

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

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

.project-card-header time {
  font-size: 0.8rem;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  padding-top: 0.35rem;
}

.project-card-summary {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.project-link {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  transition: all 0.15s ease;
}

.project-link:hover {
  background: var(--color-accent);
  color: white;
  text-decoration: none;
}

.btn-link {
  padding: 0.4rem 1rem;
  font-size: 0.875rem;
}

/* ============================================================
   Prose (Markdown rendered content)
   ============================================================ */
.prose {
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1.8;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  color: var(--color-text);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-top: 2em;
  margin-bottom: 0.75em;
}

.prose h1 { font-size: 2em; }
.prose h2 { font-size: 1.5em; border-bottom: 1px solid var(--color-border); padding-bottom: 0.3em; }
.prose h3 { font-size: 1.25em; }
.prose h4 { font-size: 1.1em; }

.prose p {
  margin-bottom: 1.25em;
}

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

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

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

.prose blockquote {
  border-left: 3px solid var(--color-accent);
  margin: 1.5em 0;
  padding: 0.75em 1.25em;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}

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

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.4em;
  color: var(--color-text);
}

.prose pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.5em;
  font-size: 0.875em;
  line-height: 1.7;
}

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

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9em;
  overflow-x: auto;
  display: block;
}

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

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

.prose tr:nth-child(even) td {
  background: var(--color-bg-tertiary);
}

.prose a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  text-underline-offset: 3px;
}

.prose a:hover {
  text-decoration-color: var(--color-link-hover);
}

.prose img {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin: 1.5em 0;
}

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

/* Syntax highlighting chroma adjustments */
.chroma {
  background: var(--color-code-bg) !important;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: 0.95rem;
  padding: 3rem 1rem;
}

/* ============================================================
   Site Footer
   ============================================================ */
.site-footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  text-align: center;
}

.site-footer p {
  font-size: 0.85rem;
  color: var(--color-text-tertiary);
}

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

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

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

  .main-content {
    padding: 2rem 1rem;
  }

  .home-hero {
    padding: 2.5rem 0 2rem;
  }

  .home-sections {
    grid-template-columns: 1fr;
  }

  .nav-links {
    gap: 1rem;
  }

  .nav-links a {
    display: none;
  }

  .nav-links a:last-of-type {
    display: block;
  }

  .project-card-header {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .nav-links a {
    display: none;
  }
}

/* 404 page */
.not-found {
  text-align: center;
  padding: 6rem 1rem;
}
.not-found-code {
  font-size: 8rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  margin: 0;
}
.not-found-msg {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0.5rem 0;
}
.not-found-sub {
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.not-found-links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   Split Layout (Blog & AI Experiments)
   ============================================================ */
.main-content--wide {
  max-width: var(--max-width-wide);
  padding: 0;
}

.split-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 60px - 61px);
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

.split-sidebar {
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  margin: 0;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-top: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.sidebar-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1.25rem;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.sidebar-item:hover {
  background: var(--color-bg-secondary);
  text-decoration: none;
}

.sidebar-item.active {
  background: var(--color-accent-subtle);
  border-left-color: var(--color-accent);
}

.sidebar-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.4;
}

.sidebar-item.active .sidebar-item-title {
  color: var(--color-accent);
  font-weight: 600;
}

.sidebar-item-meta {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
}

.split-main {
  overflow-y: auto;
  padding: 3rem 3.5rem;
  min-width: 0;
}

.split-article {
  max-width: 680px;
}

/* Responsive: collapse sidebar on mobile */
@media (max-width: 768px) {
  .split-layout {
    grid-template-columns: 1fr;
    border: none;
  }

  .split-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    max-height: 220px;
  }

  .sidebar-nav {
    max-height: 160px;
  }

  .split-main {
    padding: 2rem 1.25rem;
  }
}
