/* ============ Design Tokens ============ */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --accent: #ff9900;
  --accent-dim: rgba(255, 153, 0, 0.12);
  --text: #e6edf3;
  --muted: #8b949e;
  --link: #79c0ff;
  --radius: 8px;
  --max-w: 1100px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ============ Reading Progress Bar ============ */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 3px;
  background: var(--accent);
  z-index: 200;
  transition: width 0.1s linear;
}

/* ============ Sticky Nav ============ */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  flex-shrink: 0;
  margin-right: auto;
}
.nav-brand:hover { text-decoration: none; }

.nav-brand img { height: 30px; width: auto; }

.nav-brand-name { color: var(--text); }
.nav-brand-name .accent { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.nav-social {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.nav-social a {
  display: flex;
  align-items: center;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.nav-social a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-social svg { width: 18px; height: 18px; fill: currentColor; }

/* ============ Container ============ */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ============ Hero ============ */
.hero {
  padding: 88px 24px 80px;
  max-width: var(--max-w);
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.hero-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 20px;
}

.hero-tagline {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 500px;
  margin-bottom: 36px;
  line-height: 1.65;
}

.hero-btns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1;
}
.hero-btn:hover { text-decoration: none; }

.hero-btn-primary { background: var(--accent); color: #000; }
.hero-btn-primary:hover { background: #e68a00; }

.hero-btn-ghost { border: 1px solid var(--border); color: var(--text); }
.hero-btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }

.hero-btn svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }

/* ============ Home Sections ============ */
.home-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px 24px;
  border-bottom: 1px solid var(--border);
}

.home-section:last-child { border-bottom: none; }

.section-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}

/* Featured post */
.featured-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.featured-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  text-decoration: none;
}

.featured-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.tag {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.featured-card h2 {
  font-size: clamp(1.3rem, 2.8vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 14px;
  color: var(--text);
}

.featured-excerpt {
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 24px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

/* Posts grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.post-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  text-decoration: none;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.post-card-cat {
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-card h3 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 8px;
}

.post-card-excerpt {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Projects strip */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.project-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.project-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.project-tile img {
  width: 100%;
  height: 68px;
  object-fit: cover;
  object-position: top;
}

.project-tile-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 10px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ Post Page ============ */
.post-header {
  border-bottom: 1px solid var(--border);
  padding: 56px 24px 48px;
  max-width: var(--max-w);
  margin: 0 auto;
}

.post-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.post-header h1 {
  font-size: clamp(1.7rem, 3.5vw, 2.7rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text);
}

/* Two-col post body: article + TOC */
.post-body {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px 80px;
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 64px;
  align-items: start;
}

/* Sticky TOC */
.post-toc {
  position: sticky;
  top: 76px;
}

.post-toc-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

#toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--border);
}

#toc-list li { margin: 0; }

#toc-list a {
  display: block;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  line-height: 1.45;
  transition: color 0.15s, border-color 0.15s;
}
#toc-list a:hover { color: var(--text); text-decoration: none; }
#toc-list a.active { color: var(--accent); border-left-color: var(--accent); }
#toc-list li.toc-h3 a { padding-left: 22px; font-size: 0.75rem; }

/* Article content */
.post-content { min-width: 0; }

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5em 0 0.75em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.post-content h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2em 0 0.5em;
  color: var(--text);
}

.post-content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5em 0 0.4em;
  color: var(--text);
}

.post-content p { margin-bottom: 1.25em; }

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

.post-content ul, .post-content ol { margin: 0 0 1.25em 1.5em; }
.post-content li { margin-bottom: 0.35em; }

.post-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84em;
  background: var(--surface-2);
  padding: 2px 5px;
  border-radius: 4px;
  color: #e06c75;
}

.post-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin-bottom: 1.5em;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.88rem;
  border-radius: 0;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 14px 20px;
  margin: 1.5em 0;
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  font-style: italic;
}

.post-content img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 1.5em 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9rem;
}

.post-content th, .post-content td {
  border: 1px solid var(--border);
  padding: 8px 14px;
  text-align: left;
}

.post-content th { background: var(--surface); font-weight: 600; }

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

/* ============ Page layout (About, etc.) ============ */
.page-body {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

.page-body h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 36px;
  color: var(--text);
}

.page-body h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2em 0 0.75em;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.page-body p, .page-body li { margin-bottom: 1em; }
.page-body a { color: var(--link); }
.page-body ul, .page-body ol { margin: 0 0 1em 1.5em; }

/* ============ Footer ============ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 36px 0;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 20px;
  list-style: none;
}

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

/* ============ Mobile ============ */
@media (max-width: 900px) {
  .post-body { grid-template-columns: 1fr; gap: 0; }
  .post-toc { display: none; }
}

@media (max-width: 768px) {
  .nav-social { display: none; }
  .hero { padding: 56px 20px 48px; }
  .home-section { padding: 40px 20px; }
  .posts-grid { grid-template-columns: 1fr; }
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .featured-card { padding: 24px; }
  .post-header { padding: 40px 20px 32px; }
  .post-body { padding: 32px 20px 56px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
