/* === CSS Custom Properties === */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --text: #212529;
  --text-secondary: #6c757d;
  --accent: #0066cc;
  --accent-hover: #004999;
  --border: #dee2e6;
  --code-bg: #f4f4f4;
  --shadow: rgba(0, 0, 0, 0.08);
  --max-width: 1100px;
  --sidebar-width: 280px;
  --radius: 6px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

[data-theme='dark'] {
  --bg: #1a1a2e;
  --bg-secondary: #16213e;
  --text: #e0e0e0;
  --text-secondary: #a0a0b0;
  --accent: #4da6ff;
  --accent-hover: #80c0ff;
  --border: #2a2a4a;
  --code-bg: #0f3460;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

/* === Base === */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  transition: background-color 0.3s, color 0.3s;
}

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

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

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

/* === Header === */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

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

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
}

.theme-toggle:hover {
  background: var(--border);
}

/* === Site Content === */
.site-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: calc(100vh - 140px);
}

/* === Home Layout === */
.home-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 3rem;
}

/* === Sidebar === */
.sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
}

.avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: block;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
}

.sidebar-bio {
  text-align: center;
  margin-bottom: 1.5rem;
}

.sidebar-bio h2 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.role {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.bio {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.sidebar-section {
  margin-bottom: 1.25rem;
}

.sidebar-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

.projects-list {
  list-style: none;
  font-size: 0.85rem;
}

.projects-list li {
  padding: 0.35rem 0;
  line-height: 1.4;
}

.project-stats {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 0.4rem;
}

.project-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

.social-icon {
  font-size: 0.85rem;
  font-weight: 700;
}

.resume-link {
  display: block;
  text-align: center;
  padding: 0.5rem;
  background: var(--accent);
  color: #fff !important;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
}

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

/* === Post List === */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.post-link {
  display: block;
  padding: 1rem 0;
  color: var(--text);
  transition: background 0.15s;
}

.post-link:hover {
  text-decoration: none;
}

.post-link:hover h2 {
  color: var(--accent);
}

.post-link time {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.post-link h2 {
  font-size: 1.15rem;
  margin: 0.15rem 0 0.25rem;
  transition: color 0.15s;
}

.post-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.category {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-secondary);
}

/* === Post Page === */
.post-page,
.resume-page {
  max-width: 780px;
  margin: 0 auto;
}

.back-link {
  display: inline-block;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

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

.featured-image {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.post-page h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.post-date {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.post-page > .post-categories {
  margin-bottom: 1.5rem;
}

/* === Post Content (Markdown) === */
.post-content h1 {
  font-size: 1.6rem;
  margin: 2rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

.post-content h2 {
  font-size: 1.35rem;
  margin: 1.75rem 0 0.5rem;
}

.post-content h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

.post-content p {
  margin-bottom: 1rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.25rem;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.post-content img {
  border-radius: var(--radius);
  margin: 1rem 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

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

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

/* === Video Embeds === */
.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 1rem 0;
  border-radius: var(--radius);
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* === Loading / Error === */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.error {
  text-align: center;
  padding: 3rem;
}

.error h1 {
  margin-bottom: 0.5rem;
}

/* === highlight.js theme overrides === */
.hljs {
  color: var(--text);
  background: var(--code-bg);
}

[data-theme='dark'] .hljs-keyword,
[data-theme='dark'] .hljs-selector-tag,
[data-theme='dark'] .hljs-literal,
[data-theme='dark'] .hljs-section,
[data-theme='dark'] .hljs-link {
  color: #569cd6;
}

[data-theme='dark'] .hljs-string,
[data-theme='dark'] .hljs-title,
[data-theme='dark'] .hljs-name,
[data-theme='dark'] .hljs-type,
[data-theme='dark'] .hljs-attribute,
[data-theme='dark'] .hljs-symbol,
[data-theme='dark'] .hljs-bullet,
[data-theme='dark'] .hljs-addition,
[data-theme='dark'] .hljs-variable,
[data-theme='dark'] .hljs-template-tag,
[data-theme='dark'] .hljs-template-variable {
  color: #ce9178;
}

[data-theme='dark'] .hljs-comment,
[data-theme='dark'] .hljs-quote,
[data-theme='dark'] .hljs-deletion,
[data-theme='dark'] .hljs-meta {
  color: #6a9955;
}

[data-theme='dark'] .hljs-number,
[data-theme='dark'] .hljs-regexp,
[data-theme='dark'] .hljs-built_in {
  color: #b5cea8;
}

/* Light mode syntax highlighting */
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section,
.hljs-link {
  color: #0000ff;
}

.hljs-string,
.hljs-title,
.hljs-name,
.hljs-type,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable {
  color: #a31515;
}

.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta {
  color: #008000;
}

.hljs-number,
.hljs-regexp,
.hljs-built_in {
  color: #098658;
}

/* === Responsive === */
@media (max-width: 768px) {
  .home-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .sidebar {
    position: static;
  }

  .post-page h1 {
    font-size: 1.5rem;
  }

  .header-inner {
    padding: 0.5rem 1rem;
  }

  .site-content {
    padding: 1.5rem 1rem;
  }
}
