/* ========== CORE STYLES, VARIABLES, LAYOUTS, COMPONENTS ========== */

/* CSS variables */
:root {
  /* primary colors */
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #60a5fa;
  --secondary: #10b981;
  --secondary-dark: #059669;
  --accent: #f59e0b;
  --danger: #ef4444;
  
  /* grayscale */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --text-light: #9ca3af;
  
  /* backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-dark: #1f2937;
  
  /* borders */
  --border: #e5e7eb;
  --border-dark: #d1d5db;
  
  /* typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Monaco', 'Menlo', monospace;
  
  /* spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  
  /* layout */
  --max-width: 1200px;
  --content-width: 900px;
  --article-width: 800px;
  
  /* shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  
  /* transitions */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

/* base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

/* typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

h1 { 
  font-size: 2.5rem;
  letter-spacing: -0.025em;
}

h2 { 
  font-size: 2rem;
  letter-spacing: -0.02em;
}

h3 { 
  font-size: 1.5rem;
  letter-spacing: -0.015em;
}

h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: var(--space-lg);
  color: var(--text-secondary);
}

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

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

/* lists */
ul, ol {
  padding-left: 2rem;
  margin-left: 0;
}

/* layout components */
.wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.page-content {
  min-height: calc(100vh - 200px);
  padding: var(--space-2xl) 0;
}

/* header and nav */
.site-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
}

.site-header .wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
}

.site-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.nav-menu {
  display: flex;
  gap: var(--space-xl);
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  padding: var(--space-sm) 0;
  position: relative;
  transition: color var(--transition);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width var(--transition-slow);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link:hover::after {
  width: 100%;
}

.nav-toggle {
  display: none;
}

.nav-toggle-label {
  display: none;
}

/* hero section */
.hero {
  padding: var(--space-3xl) 0;
  margin-bottom: var(--space-3xl);
}

.hero-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 800;
  margin: 0 0 var(--space-sm);
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  font-weight: 500;
}

.hero-description {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.7;
}

/* action cards */
.hero-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  max-width: 900px;
  margin: 0 auto;
}

.action-card {
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: 1rem;
  padding: var(--space-xl);
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
  display: block;
}

.action-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-slow);
}

.action-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  background: var(--bg-secondary);
}

.action-card:hover::before {
  transform: scaleX(1);
}

.card-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-md);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  transition: all var(--transition-slow);
}

.action-card:hover .card-icon {
  transform: scale(1.1) rotate(5deg);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.card-description {
  font-size: 0.95rem;
  color: var(--text-tertiary);
  line-height: 1.5;
  margin: 0;
}

/* content sections */
.section-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-xl);
  color: var(--text-primary);
  position: relative;
  padding-bottom: var(--space-sm);
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 2px;
}

.section-footer {
  text-align: center;
  margin-top: var(--space-xl);
}

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  color: var(--primary);
  font-weight: 600;
  transition: all var(--transition);
}

.view-all-link:hover {
  background: var(--primary);
  color: white;
  transform: translateX(5px);
}

/* posts */
.post-preview {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--border);
}

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

.post-preview h3 {
  margin-top: 0;
  margin-bottom: var(--space-sm);
}

.post-preview h3 a {
  color: var(--text-primary);
  font-weight: 700;
  transition: color var(--transition);
}

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

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-md);
}

.post-meta time {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.post-excerpt {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
  line-height: 1.7;
}

.read-more {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  font-weight: 500;
  transition: all var(--transition);
}

.read-more:hover {
  gap: var(--space-sm);
  color: var(--primary-dark);
}

/* projects */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.project-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.project-image {
  margin: 2rem 0;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--bg-tertiary);
  height: auto;
  max-height: 500px;
}

.project-image img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  max-height: 500px;
  background: var(--bg-tertiary);
}

.project-card:hover .project-image img {
  transform: scale(1.05);
}

.project-content {
  padding: var(--space-lg);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.project-content h3 {
  margin-top: 0;
  margin-bottom: var(--space-sm);
}

.project-content h3 a {
  color: var(--text-primary);
  transition: color var(--transition);
}

.project-content h3 a:hover {
  color: var(--primary);
}

.project-content p {
  flex-grow: 1;
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.tag {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.025em;
}

/* footer */
.site-footer {
  background: var(--bg-dark);
  color: #e2e8f0;
  padding: var(--space-2xl) 0;
  margin-top: var(--space-3xl);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xl);
}

.footer-col p {
  margin: 0;
  color: #cbd5e1;
}

.social-links {
  display: flex;
  gap: var(--space-md);
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: #cbd5e1;
  transition: all var(--transition);
}

.social-links a:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

/* code blocks */
.code-block-wrapper {
  margin: var(--space-xl) 0;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: #282c34;
}

.code-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: var(--space-sm) var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-language {
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-button {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.copy-button.copied {
  background: var(--secondary);
  border-color: var(--secondary);
}

/* pre blocks */
.code-block-wrapper pre {
  margin: 0;
  padding: 1rem;
  padding-left: 60px;
  background: #282c34;
  border: none;
  border-radius: 0;
  overflow-x: auto;
  position: relative;
  color: #abb2bf;
}

pre {
  background: #282c34;
  color: #abb2bf;
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: var(--space-lg);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  position: relative;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* line numbers */
.line-numbers {
  position: absolute;
  left: 0;
  top: 1rem; /* match the padding-top of pre */
  bottom: 1rem; /* match the padding-bottom of pre */
  width: 45px;
  background-color: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0 5px;
  text-align: right;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  color: #5c6370;
  overflow: hidden;
}

.line-numbers span {
  display: block;
  height: 1.5em;
  line-height: 1.5;
}

/* ensure consistent spacing */
.code-block-wrapper pre code {
  display: block;
  line-height: 1.5;
  font-size: 0.875rem;
  padding: 0;
  background: transparent;
  color: #abb2bf;
}

/* remove highlight wrapper margins */
.code-block-wrapper .highlight {
  margin: 0;
  background: transparent;
}

.highlight pre {
  margin: 0;
}

/* disable font ligatures in code blocks */
code, 
pre, 
.highlight,
.code-block-wrapper {
  font-variant-ligatures: none !important;
  -webkit-font-variant-ligatures: none !important;
  text-rendering: optimizeSpeed !important;
}

/* inline code */
p code, 
li code {
  background: var(--bg-tertiary);
  color: #d63384;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-weight: 500;
  font-size: 0.875em;
}

/* citations */
.citation {
  display: inline-block;
  vertical-align: super;
  font-size: 0.75rem;
  line-height: 0;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  margin: 0 1px;
}

.citation:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* bibliography/references section */
.references {
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 2px solid var(--border);
}

.references h2 {
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

.reference-list {
  list-style: none;
  padding: 0;
  counter-reset: reference;
}

.reference-list li {
  counter-increment: reference;
  margin-bottom: var(--space-md);
  padding-left: 2rem;
  position: relative;
}

.reference-list li::before {
  content: "[" counter(reference) "]";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 600;
}

/* blockquote for citations */
blockquote.citation-quote {
  border-left: 4px solid var(--primary);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  position: relative;
}

blockquote.citation-quote footer {
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-tertiary);
  font-style: normal;
}

blockquote.citation-quote footer::before {
  content: "— ";
}

/* responsive design */
@media (max-width: 768px) {
  /* typography */
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 1.25rem;
  }
  
  .hero-description {
    font-size: 1rem;
  }
  
  /* layout */
  .wrapper {
    padding: 0 var(--space-md);
  }
  
  /* nav */
  .nav-toggle-label {
    display: block;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-primary);
  }
  
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    flex-direction: column;
    padding: var(--space-lg);
    box-shadow: var(--shadow-lg);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    min-width: 200px;
  }
  
  .nav-toggle:checked ~ .nav-menu {
    display: flex;
  }

  /* code blocks */
  .code-block-wrapper pre,
  pre {
    font-size: 0.75rem;
    padding: 0.75rem;
    padding-left: 45px;
  }
  
  .line-numbers {
    width: 35px;
    font-size: 0.75rem;
    top: 0.75rem;
    bottom: 0.75rem;
  }
  
  /* hero actions */
  .hero-actions {
    grid-template-columns: 1fr;
  }
  
  /* project grid */
  .project-grid {
    grid-template-columns: 1fr;
  }
  
  /* footer */
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

/* utility classes */
.text-center { text-align: center; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }