@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500&display=swap');

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

/* ── Tokens ── */
:root {
  --accent:        #2563eb;
  --accent-light:  #eff6ff;
  --accent-muted:  #93c5fd;

  --tag:           #b45309;
  --tag-bg:        #fef3c7;
  --tag-bg-end:    #fde68a;

  --bg:            #ffffff;
  --bg-secondary:  #fafaf7;
  --card:          #ffffff;
  --nav-glass:     rgba(255, 255, 255, 0.78);
  --text-1:        #111827;
  --text-2:        #6b7280;
  --text-3:        #9ca3af;
  --border:        #e5e7eb;

  --shadow-sm:     0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:     0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px rgba(15, 23, 42, 0.03);
  --shadow-lg:     0 2px 4px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.05);

  --blob-blue:     rgba(37, 99, 235, 0.06);
  --blob-amber:    rgba(37, 99, 235, 0.03);

  --mono: 'DM Mono', ui-monospace, monospace;
  --sans: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
}

/* Dark theme tokens. The custom property block below is applied in two cases:
   1. an explicit user choice (:root[data-theme="dark"]), and
   2. the system preference when no explicit choice was made
      (:root:not([data-theme="light"]) inside the media query — covers no-JS too). */
:root[data-theme="dark"] {
  --accent-light:  rgba(37, 99, 235, 0.16);
  --accent-muted:  #60a5fa;
  --bg:           #0f0f0f;
  --bg-secondary: #1a1a18;
  --card:         #141414;
  --nav-glass:    rgba(15, 15, 15, 0.72);
  --text-1:       #f3f4f6;
  --text-2:       #9ca3af;
  --text-3:       #6b7280;
  --border:       #27272a;

  --tag:          #fbbf24;
  --tag-bg:       rgba(251, 191, 36, 0.10);
  --tag-bg-end:   rgba(251, 191, 36, 0.18);

  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:    0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg:    0 2px 4px rgba(0, 0, 0, 0.5), 0 18px 40px rgba(0, 0, 0, 0.4);

  --blob-blue:    rgba(59, 130, 246, 0.10);
  --blob-amber:   rgba(59, 130, 246, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-light:  rgba(37, 99, 235, 0.16);
    --accent-muted:  #60a5fa;
    --bg:           #0f0f0f;
    --bg-secondary: #1a1a18;
    --card:         #141414;
    --nav-glass:    rgba(15, 15, 15, 0.72);
    --text-1:       #f3f4f6;
    --text-2:       #9ca3af;
    --text-3:       #6b7280;
    --border:       #27272a;

    --tag:          #fbbf24;
    --tag-bg:       rgba(251, 191, 36, 0.10);
    --tag-bg-end:   rgba(251, 191, 36, 0.18);

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:    0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg:    0 2px 4px rgba(0, 0, 0, 0.5), 0 18px 40px rgba(0, 0, 0, 0.4);

    --blob-blue:    rgba(59, 130, 246, 0.10);
    --blob-amber:   rgba(59, 130, 246, 0.04);
  }
}

/* ── Base ── */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Nav ── */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 80px;
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--nav-glass);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  z-index: 100;
}

.nav-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

.logo {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-1);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.logo span { color: var(--accent); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-group {
  display: flex;
  align-items: center;
  gap: 14px;
}
.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.nav-link {
  font-size: 14px;
  color: var(--text-1);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.01em;
  opacity: 0.78;
  transition: opacity 0.15s;
}
.nav-link:hover { opacity: 1; }

.lang-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
}
.lang-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.lang-link:hover { color: var(--text-1); }

.gh-link { display: flex; align-items: center; }
.gh-icon {
  width: 16px;
  height: 16px;
  fill: var(--text-2);
  transition: fill 0.15s;
}
.gh-link:hover .gh-icon { fill: var(--text-1); }

/* ── Theme toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.theme-icon {
  width: 16px;
  height: 16px;
  fill: var(--text-2);
  stroke: var(--text-2);
  transition: fill 0.15s, stroke 0.15s;
}
.theme-toggle:hover .theme-icon { fill: var(--text-1); stroke: var(--text-1); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ── Search button ── */
.search-btn {
  display: flex;
  align-items: center;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.search-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-2);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.15s;
}
.search-btn:hover .search-icon { stroke: var(--text-1); }
.search-btn:focus-visible { outline: none; }
.search-btn:focus-visible .search-icon { stroke: var(--text-1); }

/* ── Home intro ── */
.home-intro {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 72px 32px 24px;
  overflow: visible;
}
.home-intro::before,
.home-intro::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: -1;
}
.home-intro::before {
  width: 280px;
  height: 280px;
  top: -20px;
  left: -20px;
  background: var(--blob-blue);
}
.home-intro::after {
  width: 220px;
  height: 220px;
  top: 10px;
  left: 220px;
  background: var(--blob-amber);
}
.home-intro-title {
  position: relative;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 14px;
  color: var(--text-1);
}
.home-intro-text {
  position: relative;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 62ch;
}

/* ── Post list (minimal line list) ── */
.posts {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 32px 80px;
  display: flex;
  flex-direction: column;
}

.post {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 16px 4px;
  border-bottom: 0.5px solid var(--border);
  text-decoration: none;
}

.post-title {
  flex: 1;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text-1);
  transition: color 0.18s ease;
}
.post:hover .post-title {
  color: var(--accent);
}

.post-date {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--text-2);
}

/* ── Post page ── */
.post-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}

.post-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 720px) 220px;
  gap: 64px;
  align-items: start;
}

.post-page-inner {
  min-width: 0;
}

@media (max-width: 1000px) {
  .post-page-grid {
    grid-template-columns: minmax(0, 720px);
  }
}

.post-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 0.5px solid var(--border);
}

.post-page-title {
  font-size: 40px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--text-1);
  margin-top: 0;
  margin-bottom: 16px;
}

.post-page-desc {
  font-size: 18px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 20px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  margin: 0;
}

/* ── TOC (right sidebar) ── */
.toc {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.toc-title {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.toc ul { list-style: none; }
.toc ul ul { margin-left: 12px; margin-top: 6px; }
.toc li { margin-bottom: 8px; line-height: 1.45; }
.toc a {
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  display: block;
  transition: color 0.15s;
}
.toc a:hover {
  color: var(--accent);
}
.toc a.toc-active {
  color: var(--accent);
  font-weight: 500;
}

@media (max-width: 1000px) {
  .toc { display: none; }
}

/* ── Post content ── */
.post-content {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-1);
}

.post-content h2 {
  font-size: 28px;
  font-weight: 500;
  margin: 64px 0 18px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.post-content h2:first-child { margin-top: 0; }
.post-content h3 {
  font-size: 22px;
  font-weight: 500;
  margin: 40px 0 14px;
  letter-spacing: -0.015em;
  line-height: 1.3;
}
.post-content h4 {
  font-size: 18px;
  font-weight: 500;
  margin: 32px 0 12px;
  line-height: 1.4;
}
.post-content p { margin-bottom: 22px; }
.post-content ul, .post-content ol {
  margin: 0 0 20px 20px;
}
.post-content li { margin-bottom: 6px; }
.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.post-content code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}
.post-content pre,
.post-content .highlight pre {
  border-radius: 10px;
  padding: 20px 22px;
  overflow-x: auto;
  margin: 0 0 24px;
  box-shadow: none;
  border: none;
}
.post-content .highlight {
  margin: 0 0 24px;
  border-radius: 10px;
  overflow: hidden;
}
.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.7;
}
.post-content blockquote {
  border-left: 2px solid var(--accent);
  padding: 4px 0 4px 20px;
  color: var(--text-2);
  margin: 0 0 20px;
  font-style: italic;
}
.post-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 8px 0 20px;
}
.post-content hr {
  border: none;
  border-top: 0.5px solid var(--border);
  margin: 32px 0;
}
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 15px;
}
.post-content th, .post-content td {
  padding: 8px 12px;
  border: 0.5px solid var(--border);
  text-align: left;
}
.post-content th {
  background: var(--bg-secondary);
  font-weight: 500;
}

/* ── Post footer ── */
.post-footer { margin-top: 56px; padding-top: 24px; border-top: 0.5px solid var(--border); }
.back-link {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover {
  color: var(--accent);
}

/* ── About page ── */
.about-page {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 56px 32px 80px;
}
.about-content {
  max-width: 62ch;
}
.about-blob {
  position: absolute;
  top: -60px;
  left: -160px;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, var(--blob-blue), transparent 70%);
  filter: blur(24px);
  pointer-events: none;
  z-index: -1;
}
.about-hero {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 44px;
}
.about-monogram {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-md);
}
.about-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.about-name {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text-1);
}
.about-role {
  font-size: 15px;
  color: var(--text-2);
  margin-top: 3px;
}
.about-title {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text-1);
  margin-bottom: 32px;
}
.about-content > p:first-of-type {
  font-size: 20px;
  line-height: 1.55;
  color: var(--text-1);
  margin-bottom: 20px;
}
.about-content > p {
  color: var(--text-2);
  margin-bottom: 18px;
}
.about-links {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 0.5px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
}
.about-links-label {
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.about-links a {
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.15s;
}
.about-links a:hover { color: var(--accent); }

@media (max-width: 600px) {
  .about-page { padding: 48px 20px 72px; }
  .about-hero { gap: 18px; margin-bottom: 36px; }
  .about-monogram { width: 60px; height: 60px; font-size: 20px; }
  .about-name { font-size: 26px; }
  .about-content > p:first-of-type { font-size: 18px; }
}

/* ── Search overlay ── */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.search-overlay.open {
  display: flex;
}
.search-modal {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.search-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  font-family: var(--sans);
  color: var(--text-1);
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--border);
  outline: none;
}
.search-input::placeholder { color: var(--text-3); }
.search-results { max-height: 400px; overflow-y: auto; }
.search-result {
  display: block;
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--border);
  text-decoration: none;
  cursor: pointer;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-secondary); }
.search-result-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--tag);
  margin-bottom: 4px;
}
.search-result-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-1);
}
.search-result-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 3px;
  line-height: 1.5;
}
.search-empty {
  padding: 24px 20px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .nav-inner { padding: 0 16px; }
  .search { min-width: 0; }
  .search-text { display: none; }
  .home-intro { padding: 48px 16px 16px; overflow: hidden; }
  .home-intro::before { width: 180px; height: 180px; left: -40px; top: -20px; }
  .home-intro::after  { width: 140px; height: 140px; left: 90px; top: 10px; }
  .home-intro-title { font-size: 26px; }
  .home-intro-text { font-size: 16px; }
  .posts { padding: 16px 16px 60px; }
  .post { gap: 12px; padding: 16px 2px; }
  .post-title { font-size: 17px; }
  .post-page { padding: 32px 16px 60px; }
  .post-page-title { font-size: 30px; }
  .post-page-desc { font-size: 17px; }
  .post-content h2 { font-size: 24px; margin-top: 48px; padding-top: 32px; }
  .post-content h3 { font-size: 20px; margin-top: 32px; }
  .post-page-inner h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .post-title { transition: none; }
}
