@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg:      #FAFAF4;
  --text:    #1C1C1C;
  --accent:  #4F46E5;
  --muted:   #6B6B6B;
  --border:  #D0C4B0;
  --code-bg: #EDEADF;
  --serif:   'EB Garamond', Georgia, serif;
  --mono:    'JetBrains Mono', 'Courier New', monospace;
  --width:   680px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:      #13131A;
  --text:    #DDD8CC;
  --accent:  #7C73E6;
  --muted:   #888888;
  --border:  #2E2E3E;
  --code-bg: #1B1B24;
  color-scheme: dark;
}

html { font-size: 18px; }

body {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.2s ease;
}

.wrap {
  max-width: var(--width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ─── Header ───────────────────────────── */

.site-header {
  padding: 2rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.site-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  margin-bottom: 0.85rem;
}

.lambda {
  font-family: var(--serif);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

.site-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
}

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

.site-nav a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.04em;
}

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

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  margin-left: auto;
}

.theme-toggle:hover { color: var(--accent); }
.theme-toggle svg { display: block; }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun  { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ─── Footer ───────────────────────────── */

.site-footer {
  margin-top: 5rem;
  padding: 1.75rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

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

/* ─── Typography ───────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  margin: 2rem 0 0.6rem;
}

h1 { font-size: 2rem;   margin-top: 0; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1.1rem; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { opacity: 0.8; }

blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-style: italic;
}

hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

strong { font-weight: 600; }
em     { font-style: italic; }

/* ─── Code ─────────────────────────────── */

code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

pre code { background: none; padding: 0; font-size: 0.875rem; line-height: 1.6; }

/* ─── Lists ────────────────────────────── */

ul, ol { padding-left: 1.5rem; margin-bottom: 1.1rem; }
li { margin-bottom: 0.25rem; }

/* ─── Tables ───────────────────────────── */

table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.95em; }
th, td { text-align: left; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; border-bottom-color: var(--text); }

/* ─── Images ───────────────────────────── */

img { max-width: 100%; height: auto; }
figure { margin: 1.5rem 0; }
figcaption { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 0.4rem; font-style: italic; }

/* ─── Post List ────────────────────────── */

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

.post-entry {
  display: flex;
  gap: 1.25rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px dotted var(--border);
}

.post-entry:first-child { border-top: 1px dotted var(--border); }

.post-entry time {
  font-size: 0.83rem;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 5.5rem;
}

.post-entry a { color: var(--text); text-decoration: none; }
.post-entry a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ─── Single Post ──────────────────────── */

.post-header { margin-bottom: 2.5rem; }
.post-title  { font-size: 2.1rem; margin-top: 0; line-height: 1.15; }

.post-meta {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.post-tags {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted);
}

.tag {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.1em 0.5em;
  border-radius: 2px;
  margin: 0 0.3rem 0.3rem 0;
}

.tag:hover { color: var(--accent); border-color: var(--accent); opacity: 1; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

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

/* ─── Terminal ─────────────────────────── */

.terminal {
  background: #0D1117;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 2rem;
  border: 1px solid #30363D;
}

.terminal-chrome {
  background: #21262D;
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.t-btn { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.terminal-body { padding: 1rem 1.25rem; }

.terminal-body code {
  background: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: #58A6FF;
  line-height: 1.5;
}

.t-cursor {
  display: inline-block;
  width: 0.55em;
  height: 0.85em;
  margin-left: 1px;
  background: #58A6FF;
  vertical-align: middle;
  animation: blink 1.2s step-start infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ─── Home ─────────────────────────────── */

.home-desc {
  margin-bottom: 2.5rem;
  font-size: 1rem;
  color: var(--muted);
  font-style: italic;
}

.section-label {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-weight: 500;
  font-family: var(--mono);
}

/* ─── Archive ──────────────────────────── */

.archive-year {
  font-size: 1.25rem;
  color: var(--muted);
  font-weight: 500;
  margin: 2.5rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.archive-year:first-of-type { margin-top: 1rem; }

/* ─── Taxonomy ─────────────────────────── */

.term-list { list-style: none; padding: 0; }

.term-entry {
  padding: 0.4rem 0;
  border-bottom: 1px dotted var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.term-entry:first-child { border-top: 1px dotted var(--border); }
.term-entry a { color: var(--text); text-decoration: none; }
.term-entry a:hover { color: var(--accent); }
.term-count { font-size: 0.83rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ─── Math ─────────────────────────────── */

mjx-container[display="true"] { overflow-x: auto; margin: 1.25rem 0; }

/* ─── Responsive ───────────────────────── */

@media (max-width: 600px) {
  html { font-size: 16px; }
  .post-title { font-size: 1.75rem; }
  .lambda     { font-size: 1.75rem; }
  .post-entry { flex-direction: column; gap: 0.15rem; }
  .post-nav   { flex-direction: column; }
}
