:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f8fafc;
  --color-text: #334155;
  --color-text-muted: #64748b;
  --color-heading: #0f172a;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-border: #e2e8f0;
  --color-card-bg: #ffffff;
  --color-nav-text: #f8fafc;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", Menlo, monospace;
  --max-width: 820px;
  --sidebar-width: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.15);
  --transition: 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

/* Scroll progress bar */
.scroll-progress {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4);
  z-index: 200;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #000000;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 2.5rem 1.5rem;
}

/* Sidebar avatar */
.sidebar-avatar {
  display: none;
}

.site-logo {
  color: #ffffff;
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 2.5rem;
  display: block;
}

.site-logo:hover {
  color: #ffffff;
  text-decoration: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-nav a {
  color: #ffffff;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 400;
  padding: 0.5rem 0;
  opacity: 0.85;
  transition: opacity var(--transition);
  display: block;
}

.sidebar-nav a:hover {
  opacity: 1;
  text-decoration: none;
}

.sidebar-nav a.active {
  opacity: 1;
}

.sidebar-social {
  display: flex;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: auto;
}

/* Sidebar search */
.sidebar-search {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.sidebar-search-input::placeholder {
  color: rgba(255,255,255,0.4);
}

.sidebar-search-input:focus {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12);
}

.sidebar-search-results {
  margin-top: 0.5rem;
}

.sidebar-search-results a {
  display: block;
  padding: 0.35rem 0;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-search-results a:hover {
  color: #ffffff;
  text-decoration: none;
}

.sidebar-social a {
  color: var(--color-nav-text);
  opacity: 0.6;
  transition: all var(--transition);
}

.sidebar-social a:hover {
  opacity: 1;
  text-decoration: none;
  transform: translateY(-2px);
}

.sidebar-social .icon {
  width: 1.2em;
  height: 1.2em;
  margin: 0;
}

/* Theme toggle button */
.theme-toggle {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--color-nav-text);
  cursor: pointer;
  padding: 0.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: all var(--transition);
  opacity: 0.7;
}

.theme-toggle:hover {
  opacity: 1;
  background: rgba(255,255,255,0.1);
  transform: scale(1.1);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Sidebar toggle button (mobile) */
.sidebar-toggle {
  display: none;
}

/* Top bar - visible when sidebar is hidden */
.top-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: #000000;
  z-index: 90;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.top-bar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
}

.top-bar-toggle svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
}

.top-bar-title {
  color: #ffffff;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 400;
}

.top-bar-title:hover {
  color: #ffffff;
  text-decoration: none;
}

.top-bar-search {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
}

.top-bar-search svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
}

/* Search overlay */
.search-overlay {
  display: none;
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  background: #ffffff;
  z-index: 200;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-overlay.active {
  display: block;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.search-input:focus {
  border-color: #3b82f6;
}

.search-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #64748b;
  padding: 0 0.5rem;
}

.search-results {
  margin-top: 1rem;
}

.search-results a {
  display: block;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  text-decoration: none;
}

.search-results a:hover {
  color: #3b82f6;
}
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  z-index: 150;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0.6rem;
  width: 42px;
  height: 42px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}

.sidebar-toggle:hover {
  box-shadow: var(--shadow-lg);
  transform: scale(1.05);
}

.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--color-heading);
  border-radius: 1px;
  transition: var(--transition);
}

.sidebar-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(4px, 4px);
}

.sidebar-toggle.active span:nth-child(2) {
  opacity: 0;
}

.sidebar-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(4px, -4px);
}

/* Preamble wrapper — contains the fixed sidebar */
#preamble {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  z-index: 100;
  overflow: visible;
}

/* Main content */
#content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem 2rem;
  padding-left: calc(var(--sidebar-width) + 2rem);
  flex: 1;
  transition: padding-left var(--transition);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-heading);
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.title {
  font-size: 2.25rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

h3 {
  font-size: 1.15rem;
}

p {
  margin-bottom: 1.25rem;
}

#content img {
  max-width: 100%;
  height: auto;
}

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

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

blockquote {
  border-left: 3px solid var(--color-primary);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--color-bg-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-bg-alt);
  padding: 0.2em 0.45em;
  border-radius: 5px;
  border: 1px solid var(--color-border);
}

pre {
  background: var(--color-bg-alt);
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--color-border);
}

pre code {
  background: none;
  padding: 0;
  border: none;
}

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

li {
  margin-bottom: 0.35rem;
}

/* Icons */
.icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  margin-right: 0.4em;
  flex-shrink: 0;
}

/* Home page - hero section */
.hero {
  text-align: center;
  padding: 4.5rem 2rem;
  margin: -3rem -3rem 3rem -3rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 25%, #0f172a 50%, #1a1a2e 75%, #0f172a 100%);
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  background-clip: padding-box;
}

/* Animated gradient border */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6, #06b6d4, #3b82f6);
  background-size: 300% 300%;
  animation: borderGlow 4s ease infinite;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.1) 0%, transparent 40%),
    radial-gradient(ellipse at 60% 80%, rgba(6,182,212,0.08) 0%, transparent 45%);
  pointer-events: none;
}

/* Sparkle particles */
.hero .sparkle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  pointer-events: none;
  animation: sparkleFloat 3s ease-in-out infinite;
}

.hero .sparkle:nth-child(1) { top: 20%; left: 10%; animation-delay: 0s; animation-duration: 3.5s; }
.hero .sparkle:nth-child(2) { top: 60%; left: 85%; animation-delay: 0.5s; animation-duration: 4s; }
.hero .sparkle:nth-child(3) { top: 30%; left: 70%; animation-delay: 1s; animation-duration: 3s; }
.hero .sparkle:nth-child(4) { top: 75%; left: 25%; animation-delay: 1.5s; animation-duration: 3.8s; }
.hero .sparkle:nth-child(5) { top: 15%; left: 45%; animation-delay: 2s; animation-duration: 4.2s; }
.hero .sparkle:nth-child(6) { top: 85%; left: 60%; animation-delay: 0.8s; animation-duration: 3.2s; }
.hero .sparkle:nth-child(7) { top: 45%; left: 15%; animation-delay: 2.3s; animation-duration: 3.6s; }
.hero .sparkle:nth-child(8) { top: 50%; left: 90%; animation-delay: 1.2s; animation-duration: 4.5s; }

.hero h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.04em;
  color: #ffffff;
  position: relative;
}

.hero .subtitle {
  font-size: 1.1rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 2.5rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  position: relative;
}

.hero .social-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  position: relative;
}

.hero .social-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  transition: all var(--transition);
  background: rgba(255,255,255,0.03);
}

.hero .social-links a:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

/* Page header backgrounds */
.page-hero {
  margin: -3rem -3rem 2.5rem;
  padding: 3.5rem 3rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #1a1a2e 100%);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 150%;
  height: 200%;
  background:
    radial-gradient(ellipse at 70% 50%, rgba(59,130,246,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 30% 80%, rgba(139,92,246,0.06) 0%, transparent 40%);
  pointer-events: none;
}

.page-hero h1 {
  color: #ffffff;
  margin: 0 0 0.4rem;
  font-size: 2.2rem;
  border: none;
  padding: 0;
  letter-spacing: -0.03em;
  position: relative;
}

.page-hero p {
  color: rgba(255,255,255,0.55);
  margin: 0;
  font-size: 1rem;
  position: relative;
}

/* Hero images */
.hero-image {
  margin: 0;
  overflow: hidden;
  position: relative;
}

.hero-image::after {
  display: none;
}

.hero-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-image:hover img {
  transform: scale(1.03);
}

/* Home greeting */
.home-greeting {
  display: none;
}

.home-greeting h1 {
  font-size: 2.4rem;
  letter-spacing: -0.04em;
  margin: 0 0 0.4rem;
  background: linear-gradient(135deg, var(--color-heading), var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-greeting p {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  margin: 0;
  font-weight: 400;
}

/* Introduction paragraphs */
.intro {
  font-size: 1.05rem;
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 0;
}

.intro p {
  margin-bottom: 1.5rem;
  color: var(--color-text);
  line-height: 1.85;
}

.intro p:first-child::first-letter {
  font-size: 2.4em;
  font-weight: 700;
  color: var(--color-primary);
  float: left;
  line-height: 1;
  margin-right: 0.1em;
  margin-top: 0.05em;
}

/* Blog cards */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.blog-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all var(--transition);
  position: relative;
}

.blog-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(59,130,246,0.03), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

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

.blog-card:hover {
  border-color: rgba(59,130,246,0.3);
  box-shadow: 0 12px 28px rgba(59,130,246,0.1), 0 4px 12px rgba(0,0,0,0.05);
  transform: translateY(-4px);
}

.blog-card a {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
  text-decoration: none;
  position: relative;
}

.blog-card a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.blog-card .card-desc {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  line-height: 1.5;
  position: relative;
}

/* Blog card category tags */
.card-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card-tag:hover {
  transform: scale(1.05);
}

.card-tag.tag-active {
  box-shadow: 0 0 0 2px currentColor;
  transform: scale(1.1);
}

.card-date {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-left: 0.5rem;
}

.tag-control {
  background: rgba(59,130,246,0.1);
  color: #3b82f6;
  border: 1px solid rgba(59,130,246,0.2);
}

.tag-rl {
  background: rgba(139,92,246,0.1);
  color: #8b5cf6;
  border: 1px solid rgba(139,92,246,0.2);
}

.tag-inference {
  background: rgba(6,182,212,0.1);
  color: #06b6d4;
  border: 1px solid rgba(6,182,212,0.2);
}

.tag-ml {
  background: rgba(234,88,12,0.1);
  color: #ea580c;
  border: 1px solid rgba(234,88,12,0.2);
}

.tag-av {
  background: rgba(22,163,74,0.1);
  color: #16a34a;
  border: 1px solid rgba(22,163,74,0.2);
}

.tag-tools {
  background: rgba(100,116,139,0.1);
  color: #64748b;
  border: 1px solid rgba(100,116,139,0.2);
}

/* Publications */
.pub-section {
  margin-bottom: 2.5rem;
}

.pub-entry {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--color-border);
  transition: all 0.3s ease;
  padding-left: 0;
  border-left: 3px solid transparent;
}

.pub-entry:last-child {
  border-bottom: none;
}

.pub-entry:hover {
  padding-left: 1rem;
  border-left-color: var(--color-primary);
  background: var(--color-bg-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.pub-title {
  font-weight: 600;
  color: var(--color-heading);
  font-size: 0.95rem;
  line-height: 1.4;
}

.pub-authors {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.pub-venue {
  font-style: italic;
  font-size: 0.85rem;
  margin-top: 0.15rem;
  color: var(--color-text-muted);
}

.pub-links {
  margin-top: 0.5rem;
}

.pub-links a {
  font-size: 0.82rem;
  margin-right: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* About page - timeline */
.timeline {
  position: relative;
  padding-left: 1.5rem;
  margin-top: 2rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 2rem;
  width: 2px;
  background: linear-gradient(to bottom, var(--color-primary), var(--color-border));
  border-radius: 1px;
}

.timeline-item {
  position: relative;
  padding-bottom: 2.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.5rem;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-primary);
  transition: all var(--transition);
}

.timeline-item:hover::before {
  transform: scale(1.3);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}

.timeline-item h3 {
  margin-top: 0;
  font-size: 1.1rem;
}

.timeline-item .period {
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.timeline-item p {
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* Postamble wrapper — hide visually, keep scripts running */
#postamble {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Footer via content ::after */
#content::after {
  content: '\00A9 2024 Chenggang Liu';
  display: block;
  text-align: center;
  padding: 2.5rem 0 1rem;
  margin-top: 3rem;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  opacity: 0.5;
  border-top: 1px solid var(--color-border);
  letter-spacing: 0.02em;
}

/* Table of contents (blog posts) */
#table-of-contents {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

#table-of-contents h2 {
  font-size: 0.9rem;
  border: none;
  padding: 0;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

#table-of-contents ul {
  margin: 0;
}

#table-of-contents li {
  margin-bottom: 0.25rem;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes borderGlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes sparkleFloat {
  0%, 100% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translateY(-5px) scale(1);
  }
  80% {
    opacity: 0.6;
    transform: translateY(-15px) scale(0.8);
  }
}

/* Hero animations */
.hero {
  animation: fadeIn 1s ease-out;
}

.hero h1 {
  animation: fadeInUp 0.7s ease-out 0.2s both;
}

.hero .subtitle {
  animation: fadeInUp 0.7s ease-out 0.4s both;
}

.hero .social-links {
  animation: fadeInUp 0.7s ease-out 0.6s both;
}

/* Page hero animation */
.page-hero {
  animation: fadeIn 0.7s ease-out;
}

.page-hero h1 {
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

.page-hero p {
  animation: fadeInUp 0.6s ease-out 0.25s both;
}

/* Scroll fade in / fade out */
.fade-item {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-item.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered blog card entrances */
.blog-card.fade-item:nth-child(1) { transition-delay: 0s; }
.blog-card.fade-item:nth-child(2) { transition-delay: 0.06s; }
.blog-card.fade-item:nth-child(3) { transition-delay: 0.12s; }
.blog-card.fade-item:nth-child(4) { transition-delay: 0.18s; }
.blog-card.fade-item:nth-child(5) { transition-delay: 0.24s; }
.blog-card.fade-item:nth-child(6) { transition-delay: 0.3s; }
.blog-card.fade-item:nth-child(7) { transition-delay: 0.36s; }
.blog-card.fade-item:nth-child(8) { transition-delay: 0.42s; }
.blog-card.fade-item:nth-child(9) { transition-delay: 0.48s; }
.blog-card.fade-item:nth-child(10) { transition-delay: 0.54s; }
.blog-card.fade-item:nth-child(11) { transition-delay: 0.6s; }
.blog-card.fade-item:nth-child(12) { transition-delay: 0.66s; }
.blog-card.fade-item:nth-child(13) { transition-delay: 0.72s; }
.blog-card.fade-item:nth-child(14) { transition-delay: 0.78s; }

/* Timeline item stagger */
.timeline-item.fade-item:nth-child(1) { transition-delay: 0s; }
.timeline-item.fade-item:nth-child(2) { transition-delay: 0.1s; }
.timeline-item.fade-item:nth-child(3) { transition-delay: 0.2s; }
.timeline-item.fade-item:nth-child(4) { transition-delay: 0.3s; }
.timeline-item.fade-item:nth-child(5) { transition-delay: 0.4s; }
.timeline-item.fade-item:nth-child(6) { transition-delay: 0.5s; }


/* Dark mode — triggered by data-theme attribute or system preference */
[data-theme="dark"],
html:not([data-theme]) {
}

[data-theme="dark"] {
  --color-bg: #1a1a2e;
  --color-bg-alt: #16213e;
  --color-text: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-heading: #f1f5f9;
  --color-border: rgba(255,255,255,0.08);
  --color-card-bg: #1e293b;
}

[data-theme="dark"] body {
  background: linear-gradient(160deg, #0a0a0a 0%, #0f172a 50%, #0a0a0a 100%);
}

[data-theme="dark"] #content {
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 4px 40px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="dark"] .blog-card {
  background: var(--color-card-bg);
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .blog-card:hover {
  border-color: rgba(59,130,246,0.4);
  box-shadow: 0 12px 28px rgba(59,130,246,0.15), 0 4px 12px rgba(0,0,0,0.2);
}

[data-theme="dark"] .hero-image {
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

[data-theme="dark"] .sidebar-toggle {
  background: var(--color-card-bg);
  border-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .sidebar-toggle span {
  background: var(--color-heading);
}

[data-theme="dark"] .home-greeting h1 {
  background: linear-gradient(135deg, #f1f5f9, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .intro p:first-child::first-letter {
  color: #60a5fa;
}

[data-theme="dark"] code {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] pre {
  background: rgba(0,0,0,0.3);
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] #table-of-contents {
  background: var(--color-bg-alt);
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .pub-entry:hover {
  background: rgba(255,255,255,0.03);
}

[data-theme="dark"] .timeline-item::before {
  border-color: var(--color-bg);
}

/* Theme toggle icon visibility */
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .fade-item {
    opacity: 1;
    transform: none;
  }
}

/* Responsive — sidebar auto-hide */
@media (max-width: 1100px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: none;
  }

  .top-bar {
    display: flex;
  }

  #content {
    margin-left: 0;
    padding-left: 2rem;
    padding-top: calc(48px + 1rem);
  }

  body.sidebar-open #content {
    padding-left: calc(var(--sidebar-width) + 2rem);
  }

  .scroll-progress {
    left: 0;
  }
}

/* Responsive — small screens */
@media (max-width: 768px) {
  #content {
    margin: 0;
    padding: 2rem 1.25rem;
    padding-top: 4rem;
    border-radius: 0;
    border: none;
  }

  .hero {
    margin: -4rem -1.25rem 2rem -1.25rem;
    padding: 5rem 1.5rem 3rem;
    border-radius: 0;
  }

  .page-hero {
    margin: -4rem -1.25rem 2rem -1.25rem;
    padding: 5rem 1.5rem 2.5rem;
    border-radius: 0;
  }

  .hero-image {
    margin: 2rem -1.25rem;
    border-radius: 0;
  }

  .title {
    font-size: 1.75rem;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .blog-grid {
    grid-template-columns: 1fr;
  }

  .hero .social-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .intro p:first-child::first-letter {
    font-size: 2em;
  }
}
