/* ── Themes ── */
:root,
[data-theme="github"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1e2530;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --text-faint: #6e7681;
  --accent: #58a6ff;
  --accent-2: #7ee787;
  --accent-hover: #79c0ff;
  --danger: #f85149;
  --code-bg: #1e2530;
  --code-text: #e6edf3;
  --header-bg: #0d1117;
  --header-border: #30363d;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.22);
  --blockquote-bg: rgba(88, 166, 255, 0.06);
  --selection-bg: rgba(88, 166, 255, 0.28);

  --syn-keyword: #ff7b72;
  --syn-string: #a5d6ff;
  --syn-comment: #8b949e;
  --syn-function: #d2a8ff;
  --syn-number: #79c0ff;
  --syn-operator: #ff7b72;
  --syn-class: #ffa657;
  --syn-variable: #ffa657;
  --syn-constant: #79c0ff;
  --syn-tag: #7ee787;
  --syn-attr: #79c0ff;
  --syn-builtin: #ffa657;
  --syn-regex: #a5d6ff;
  --syn-error: #f85149;
}

[data-theme="warm-light"] {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f4f3f1;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #525252;
  --text-faint: #737373;
  --accent: #e8590c;
  --accent-2: #2f9e44;
  --accent-hover: #d9480f;
  --danger: #c92a2a;
  --code-bg: #f4f3f1;
  --code-text: #1a1a1a;
  --header-bg: #ffffff;
  --header-border: #e5e5e5;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --blockquote-bg: rgba(232, 89, 12, 0.05);
  --selection-bg: rgba(232, 89, 12, 0.15);

  --syn-keyword: #cf222e;
  --syn-string: #0a3069;
  --syn-comment: #6e7781;
  --syn-function: #8250df;
  --syn-number: #0550ae;
  --syn-operator: #cf222e;
  --syn-class: #953800;
  --syn-variable: #953800;
  --syn-constant: #0550ae;
  --syn-tag: #116329;
  --syn-attr: #0550ae;
  --syn-builtin: #953800;
  --syn-regex: #0a3069;
  --syn-error: #a40e26;
}

/* ── Layout constants ── */
:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --max-width: 820px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ── Reset & Base ── */
html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

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

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

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.site-title {
  color: var(--text);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  flex-shrink: 0;
}

.site-title span {
  color: var(--accent);
}

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

/* ── Navigation ── */
.site-nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-left: 24px;
  transition: color 0.15s;
}

.site-nav a:first-child {
  margin-left: 0;
}

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

/* ── Mobile hamburger ── */
.nav-toggle {
  display: none;
}

.nav-hamburger {
  display: none;
  cursor: pointer;
  width: 28px;
  height: 20px;
  position: relative;
  flex-shrink: 0;
}

.nav-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  position: absolute;
  left: 0;
  transition: all 0.25s;
}

.nav-hamburger span:nth-child(1) { top: 0; }
.nav-hamburger span:nth-child(2) { top: 9px; }
.nav-hamburger span:nth-child(3) { top: 18px; }

.nav-toggle:checked ~ .nav-hamburger span:nth-child(1) {
  transform: rotate(45deg);
  top: 9px;
}

.nav-toggle:checked ~ .nav-hamburger span:nth-child(2) {
  opacity: 0;
}

.nav-toggle:checked ~ .nav-hamburger span:nth-child(3) {
  transform: rotate(-45deg);
  top: 9px;
}

.nav-toggle:checked ~ .site-nav {
  display: flex;
}

@media (max-width: 640px) {
  .nav-hamburger {
    display: block;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--header-border);
    flex-direction: column;
    padding: 16px 24px;
    gap: 12px;
  }

  .site-nav a {
    margin-left: 0;
    padding: 4px 0;
  }
}

/* ── Main ── */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px;
  flex: 1;
  width: 100%;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
}

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

.footer-nav a {
  color: var(--text-muted);
  margin-left: 20px;
  font-size: 0.875rem;
}

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

@media (max-width: 640px) {
  .footer-inner {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .footer-nav a {
    margin: 0 10px;
  }
}

/* ── Hero ── */
.hero {
  margin-bottom: 48px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: clamp(1.75rem, 1.5rem + 2vw, 2.5rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
  color: var(--text);
}

.hero h1 span {
  color: var(--accent);
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin: 0;
  max-width: 60ch;
}

/* ── Category filter pills ── */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.category-pill {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.category-pill:hover,
.category-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--blockquote-bg);
  text-decoration: none;
}

/* ── Year sections ── */
.year-section {
  margin-bottom: 40px;
}

.year-heading {
  font-size: 1.1rem;
  color: var(--text-faint);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Post cards ── */
.post-feed {
  display: flex;
  flex-direction: column;
}

.post-card {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

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

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.post-card-date {
  color: var(--text-faint);
}

.post-card-category {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.post-card h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  line-height: 1.35;
  font-weight: 600;
}

.post-card h3 a {
  color: var(--text);
}

.post-card h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.55;
}

/* ── Single post ── */
.post {
  max-width: var(--max-width);
  margin: 0 auto 64px;
}

.post-header {
  margin-bottom: 36px;
}

.post-meta-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.post-category-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
}

.post-category-badge:hover {
  background: var(--blockquote-bg);
  text-decoration: none;
}

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

.post-title {
  font-size: clamp(1.75rem, 1.5rem + 2vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
  color: var(--text);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.meta-sep {
  color: var(--text-faint);
}

/* ── Post content typography ── */
.post-content p {
  margin: 0 0 18px;
  max-width: 72ch;
}

.post-content h2 {
  margin: 42px 0 14px;
  font-size: 1.45rem;
  line-height: 1.25;
  color: var(--text);
}

.post-content h3 {
  margin: 28px 0 10px;
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--text);
}

.post-content h4 {
  margin: 22px 0 8px;
  font-size: 1rem;
  color: var(--text-muted);
}

.post-content ul,
.post-content ol {
  margin: 0 0 18px 22px;
}

.post-content li {
  margin-bottom: 8px;
}

.post-content strong {
  color: var(--text);
}

.post-content blockquote {
  margin: 24px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--blockquote-bg);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text);
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

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

/* ── Code ── */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.45em;
  border-radius: 5px;
  border: 1px solid var(--border);
}

pre {
  overflow-x: auto;
  margin: 22px 0;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--code-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--code-text);
  display: block;
  line-height: 1.6;
  font-size: 0.88rem;
}

/* ── Syntax highlighting ── */
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr,
.highlight .kc, .highlight .kt, .highlight .kv {
  color: var(--syn-keyword);
  font-weight: bold;
}

.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc,
.highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx,
.highlight .dl {
  color: var(--syn-string);
}

.highlight .sr {
  color: var(--syn-regex);
}

.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp,
.highlight .ch, .highlight .cd {
  color: var(--syn-comment);
  font-style: italic;
}

.highlight .nf, .highlight .fm {
  color: var(--syn-function);
}

.highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il {
  color: var(--syn-number);
}

.highlight .o, .highlight .ow {
  color: var(--syn-operator);
}

.highlight .nc, .highlight .nn {
  color: var(--syn-class);
}

.highlight .nv, .highlight .vi, .highlight .vc, .highlight .vg, .highlight .vm {
  color: var(--syn-variable);
}

.highlight .no, .highlight .na {
  color: var(--syn-attr);
}

.highlight .nb, .highlight .bp {
  color: var(--syn-builtin);
}

.highlight .nt {
  color: var(--syn-tag);
}

.highlight .ni, .highlight .ne {
  color: var(--syn-constant);
}

.highlight .ge {
  font-style: italic;
}

.highlight .gs {
  font-weight: bold;
}

.highlight .err {
  color: var(--syn-error);
  background: transparent;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 0.92rem;
}

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

th {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

td {
  background: rgba(255, 255, 255, 0.01);
}

/* ── Tags ── */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.tag {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
}

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

/* ── Post navigation ── */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.post-nav a {
  display: flex;
  flex-direction: column;
  max-width: 48%;
}

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

.post-nav-label {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.post-nav-title {
  color: var(--accent);
  font-size: 0.95rem;
}

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

@media (max-width: 640px) {
  .post-nav {
    flex-direction: column;
    gap: 16px;
  }

  .post-nav a {
    max-width: 100%;
  }

  .post-nav-next {
    text-align: left;
    margin-left: 0;
  }
}

/* ── Projects page ── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.project-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
}

.project-card h3 a {
  color: var(--text);
}

.project-card h3 a:hover {
  color: var(--accent);
}

.project-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 12px;
  line-height: 1.5;
}

.project-card .project-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-card .stack-tag {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ── About page ── */
.about-page h1 {
  font-size: clamp(1.75rem, 1.5rem + 2vw, 2.25rem);
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}

.about-page p {
  margin: 0 0 18px;
  max-width: 65ch;
}

.about-page blockquote {
  margin: 28px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--blockquote-bg);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.about-page blockquote p:last-child {
  margin-bottom: 0;
}

.about-interests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.interest-tag {
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Category page ── */
.category-page h1 {
  font-size: clamp(1.75rem, 1.5rem + 2vw, 2.25rem);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.category-page > p {
  color: var(--text-muted);
  margin: 0 0 32px;
}

.category-list {
  margin-bottom: 48px;
}

.category-list h2 {
  font-size: 1.25rem;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.category-list h2 a {
  color: var(--text);
}

.category-list h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.category-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-list li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.category-list li:last-child {
  border-bottom: none;
}

.category-list .cat-date {
  color: var(--text-faint);
  font-size: 0.82rem;
  flex-shrink: 0;
  min-width: 80px;
}

.category-list .cat-link {
  color: var(--text);
  font-size: 0.95rem;
}

.category-list .cat-link:hover {
  color: var(--accent);
}

/* ── 404 page ── */
.page-404 {
  text-align: center;
  padding: 60px 0;
}

.page-404 h1 {
  font-size: 6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0;
  color: var(--text-faint);
  line-height: 1;
}

.page-404 p {
  color: var(--text-muted);
  font-size: 1.15rem;
  margin: 16px 0 28px;
}

.page-404 a {
  display: inline-block;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.95rem;
  transition: background 0.15s;
}

.page-404 a:hover {
  background: var(--blockquote-bg);
  text-decoration: none;
}

/* ── Selection & focus ── */
::selection {
  background: var(--selection-bg);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── Utilities ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Theme toggle ── */
.theme-toggle {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: inline;
}

[data-theme="warm-light"] .theme-toggle .icon-sun {
  display: inline;
}

[data-theme="warm-light"] .theme-toggle .icon-moon {
  display: none;
}

/* ── Language switcher ── */
.lang-link {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: border-color 0.15s, color 0.15s;
}

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

.lang-switch-link {
  color: var(--accent);
  font-size: 0.88rem;
}

.lang-switch-link:hover {
  text-decoration: underline;
}

.lang-notice {
  padding: 12px 16px;
  margin-bottom: 28px;
  border-radius: var(--radius-md);
  background: var(--blockquote-bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.92rem;
}
