/* ═══════════════════════════════════════
   CSS Custom Properties (light / dark)
═══════════════════════════════════════ */

:root {
  --bg:             #ffffff;
  --surface:        #f7f7f7;
  --border-strong:  #000000;
  --border-subtle:  #e8e8e8;
  --text-primary:   #000000;
  --text-body:      #1a1a1a;
  --text-secondary: #555555;
  --text-muted:     #999999;
  --text-faint:     #bbbbbb;
}

[data-theme="dark"] {
  --bg:             #111111;
  --surface:        #1a1a1a;
  --border-strong:  #f0f0f0;
  --border-subtle:  #222222;
  --text-primary:   #f0f0f0;
  --text-body:      #e8e8e8;
  --text-secondary: #888888;
  --text-muted:     #555555;
  --text-faint:     #444444;
}

/* ═══════════════════════════════════════
   Reset
═══════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }

/* ═══════════════════════════════════════
   Base
═══════════════════════════════════════ */

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-body);
  font-size: 17px;
  line-height: 1.5;
  transition: background 0.15s, color 0.15s;
}

a { color: inherit; }

/* ═══════════════════════════════════════
   Navigation
═══════════════════════════════════════ */

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 48px;
  border-bottom: 2px solid var(--border-strong);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.15s;
}

.logo {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.5px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-primary);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
}

.nav-links a {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-decoration: none;
  color: var(--text-muted);
}

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

.theme-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  border: 2px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  padding: 0;
  transition: border-color 0.15s;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(16px);
  background: var(--text-primary);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-primary);
  line-height: 1;
}

/* ═══════════════════════════════════════
   Page wrapper
═══════════════════════════════════════ */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

.page--wide {
  max-width: 1100px;
}

/* ═══════════════════════════════════════
   Site header (homepage tagline)
═══════════════════════════════════════ */

.site-header {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--border-subtle);
}

.site-header .site-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.site-header p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ═══════════════════════════════════════
   Hero post (homepage latest)
═══════════════════════════════════════ */

.hero-post {
  display: block;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border-subtle);
}

.hero-image {
  width: 100%;
  height: 320px;
  margin-top: 32px;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 55%);
}

.hero-image-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 28px;
  z-index: 1;
}

.hero-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.75);
  margin-bottom: 8px;
}

.hero-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1.05;
  color: #fff;
}

.hero-excerpt {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  line-height: 1.5;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-meta {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin-top: 10px;
}

.hero-post:hover .hero-title {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ═══════════════════════════════════════
   Post list (homepage older posts)
═══════════════════════════════════════ */

.section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-faint);
  padding: 28px 0 0;
}

/* ═══════════════════════════════════════
   Post grid (homepage 2-column)
═══════════════════════════════════════ */

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  padding: 24px 0 48px;
}

.post-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s;
}

.post-card:hover {
  border-color: var(--border-strong);
}

.post-card:hover .post-card-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-card-thumb {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: var(--surface);
  flex-shrink: 0;
}

.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-card-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.post-card-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.post-card-excerpt {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-date {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 14px;
}

/* ═══════════════════════════════════════
   Project grid
═══════════════════════════════════════ */

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  padding: 24px 0 48px;
}

.project-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s;
}

.project-card:hover {
  border-color: var(--border-strong);
}

.project-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 12px;
}

.project-card-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.25;
  color: var(--text-primary);
  text-decoration: none;
}

.project-card-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.project-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.project-tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-tech-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1.5px solid var(--border-strong);
  padding: 3px 8px;
  color: var(--text-primary);
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
}

.project-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 8px;
}

.project-status--active {
  background: var(--border-strong);
  color: var(--bg);
}

.project-status--archived {
  color: var(--text-muted);
  border: 1.5px solid var(--border-subtle);
}

.project-card-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.project-github-link,
.project-docs-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.project-github-link:hover,
.project-docs-link:hover {
  color: var(--text-primary);
}

.post-list { list-style: none; }

.post-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none;
  color: inherit;
}

.post-row:hover .post-row-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-thumb {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface);
}

.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-info { flex: 1; min-width: 0; }

.post-row-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.post-row-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.25;
  color: var(--text-primary);
}

.post-row-excerpt {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-row-date {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  margin-left: 8px;
}

/* ═══════════════════════════════════════
   Pagination
═══════════════════════════════════════ */

.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}

.pagination a,
.pagination span {
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-muted);
  border: 1.5px solid var(--border-subtle);
  padding: 6px 14px;
}

.pagination a:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.pagination .current {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ═══════════════════════════════════════
   Post page
═══════════════════════════════════════ */

.post-header {
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 40px;
}

.post-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.post-header h1 {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.05;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.post-byline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.author-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
}

.author-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

.byline-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.byline-text strong {
  font-weight: 700;
  color: var(--text-primary);
}

.post-hero-image {
  width: 100%;
  height: 360px;
  margin-bottom: 40px;
  overflow: hidden;
  background: var(--surface);
}

.post-hero-image img { width: 100%; height: 100%; object-fit: cover; }

/* ═══════════════════════════════════════
   Article body
═══════════════════════════════════════ */

.article-body {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-body);
}

.article-body p { margin-bottom: 24px; }

.article-body h2 {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.6px;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 48px 0 16px;
  border-top: 2px solid var(--border-strong);
  padding-top: 16px;
}

.article-body h3 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  margin: 32px 0 12px;
}

.article-body a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 20px;
  margin: 28px 0;
  font-size: 18px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.6;
}

.article-body code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  background: var(--surface);
  padding: 2px 6px;
}

.article-body pre {
  background: var(--surface);
  border-left: 3px solid var(--border-strong);
  padding: 20px;
  margin: 24px 0;
  overflow-x: auto;
}

.article-body pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
}

.article-body img { margin: 28px 0; }

.article-body ul,
.article-body ol {
  padding-left: 24px;
  margin-bottom: 24px;
}

.article-body li { margin-bottom: 6px; }

/* Rouge syntax highlighting */
.highlight { background: var(--surface); border-left: 3px solid var(--border-strong); padding: 20px; margin: 24px 0; overflow-x: auto; }
.highlight pre { background: none; border: none; padding: 0; margin: 0; }
.highlight .c, .highlight .c1, .highlight .cm { color: var(--text-muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn { color: var(--text-primary); font-weight: 700; }
.highlight .s, .highlight .s1, .highlight .s2 { color: var(--text-secondary); }
.highlight .n, .highlight .na { color: var(--text-body); }

/* ═══════════════════════════════════════
   Post footer
═══════════════════════════════════════ */

.post-footer {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 2px solid var(--border-strong);
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.post-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1.5px solid var(--border-strong);
  padding: 4px 10px;
  color: var(--text-primary);
  text-decoration: none;
}

.post-tag:hover { background: var(--border-strong); color: var(--bg); }

.author-card {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 24px;
  background: var(--surface);
  margin-bottom: 40px;
}

.author-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--border-subtle);
}

.author-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

.author-card-name {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.author-card-bio {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.post-nav a {
  flex: 1;
  text-decoration: none;
  color: var(--text-primary);
}

.nav-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.nav-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.3;
}

.post-nav a:hover .nav-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-nav .next { text-align: right; }

/* ═══════════════════════════════════════
   Generic page (page.html layout)
═══════════════════════════════════════ */

.page-header {
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 40px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text-primary);
}

.page-body {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-body);
  padding-bottom: 64px;
}

.page-body p { margin-bottom: 20px; }
.page-body a { text-decoration: underline; text-underline-offset: 3px; }
.page-body h2 { font-size: 20px; font-weight: 900; letter-spacing: -0.5px; color: var(--text-primary); margin: 36px 0 14px; }

/* ═══════════════════════════════════════
   About page
═══════════════════════════════════════ */

.about-profile {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  padding: 48px 0 40px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 40px;
}

.about-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
}

.about-avatar img { width: 100%; height: 100%; object-fit: cover; }

.about-name {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.about-bio {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.about-links {
  display: flex;
  gap: 16px;
  list-style: none;
}

.about-links a {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-decoration: none;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border-subtle);
  padding-bottom: 2px;
}

.about-links a:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ═══════════════════════════════════════
   Nav dropdown
═══════════════════════════════════════ */

.has-dropdown { position: relative; }

.dropdown-toggle::after {
  content: ' ▾';
  font-size: 7px;
  vertical-align: middle;
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: -16px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-top: 2px solid var(--border-strong);
  min-width: 160px;
  z-index: 200;
  list-style: none;
  padding: 6px 0;
}

.has-dropdown:hover .nav-dropdown { display: block; }

.nav-dropdown li a {
  display: block;
  padding: 8px 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-decoration: none;
}

.nav-dropdown li a:hover {
  color: var(--text-primary);
  background: var(--surface);
}

.nav-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 0;
}

/* ═══════════════════════════════════════
   Archive / Blog pages
═══════════════════════════════════════ */

.archive-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 32px;
}

.archive-header h1 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.archive-count {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.archive-post-list {
  list-style: none;
  padding-bottom: 48px;
}

.archive-post-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none;
  color: inherit;
  gap: 16px;
}

.archive-post-row:hover .archive-post-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.archive-post-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.archive-post-date {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ═══════════════════════════════════════
   Footer
═══════════════════════════════════════ */

.site-footer {
  max-width: 720px;
  margin: 64px auto 0;
  padding: 28px 24px;
  border-top: 2px solid var(--border-strong);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.3px;
  text-transform: uppercase;
  color: var(--text-primary);
}

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

.footer-links a {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover { color: var(--text-primary); }

.footer-copy {
  font-size: 10px;
  color: var(--text-faint);
}

/* ═══════════════════════════════════════
   Responsive — mobile (≤ 640px)
═══════════════════════════════════════ */

@media (max-width: 640px) {
  .site-nav { padding: 16px 20px; }

  .nav-right .nav-links { display: none; }
  .nav-right .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 2px solid var(--border-strong);
    padding: 20px;
    gap: 16px;
    z-index: 99;
  }

  .nav-toggle { display: block; }

  .post-grid { grid-template-columns: 1fr; }
  .project-grid { grid-template-columns: 1fr; }

  .nav-dropdown {
    position: static;
    border: none;
    border-top: 1px solid var(--border-subtle);
    border-left: 2px solid var(--border-strong);
    margin: 8px 0 0 8px;
    padding: 4px 0;
    display: none;
  }
  .nav-dropdown.open { display: block; }
  .has-dropdown:hover .nav-dropdown { display: none; }
  .has-dropdown:hover .nav-dropdown.open { display: block; }

  .page { padding: 0 16px; }

  .hero-image { height: 220px; }
  .hero-title { font-size: 20px; }

  .post-header h1 { font-size: 26px; }
  .post-hero-image { height: 220px; }

  .site-footer { flex-direction: column; gap: 14px; text-align: center; }
  .post-nav { flex-direction: column; }
  .post-nav .next { text-align: left; }

  .about-profile { flex-direction: column; }
}
