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

/* ── Tokens ────────────────────────────────────────────────────────── */
:root {
  --text:         #1a1a18;
  --text-muted:   #666660;
  --text-faint:   #999992;
  --bg:           #fefefd;
  --border:       #ecebe8;
  --link:         #1a1a18;
  --link-hover:   #555550;

  --tag-article-bg:   #eef2ff;
  --tag-article-text: #3b4bab;
  --tag-project-bg:   #f0fdf4;
  --tag-project-text: #166534;
  --tag-research-bg:  #fff7ed;
  --tag-research-text:#9a3412;

  --status-progress-bg:   #fff7ed;
  --status-progress-text: #9a3412;
  --status-complete-bg:   #f0fdf4;
  --status-complete-text: #166534;
  --status-abandoned-bg:  #f5f5f4;
  --status-abandoned-text:#78716c;

  --font-body:  'Georgia', serif;
  --font-ui:    system-ui, sans-serif;

  --max-width: 680px;
  --gap:       2rem;
}

/* ── Base ──────────────────────────────────────────────────────────── */
html {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

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

/* ── Nav ───────────────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: baseline;
  gap: 2rem;
  margin-bottom: 3.5rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.site-name {
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

nav ul a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}

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

/* ── Page headings ─────────────────────────────────────────────────── */
h1 {
  font-size: 1.5rem;
  font-weight: normal;
  letter-spacing: -0.01em;
  margin-bottom: 2rem;
}

/* ── Homepage intro ────────────────────────────────────────────────── */
.intro {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.intro p {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 560px;
}

.intro p + p {
  margin-top: 0.5rem;
}

.intro-threads a {
  color: var(--text);
  text-decoration-color: var(--border);
}

/* ── Stream (homepage) ─────────────────────────────────────────────── */
.section-label {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 1.25rem;
}

.stream {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stream-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.stream-item:first-of-type {
  border-top: 1px solid var(--border);
}

.item-title {
  font-size: 1rem;
  text-decoration: none;
  color: var(--text);
  line-height: 1.4;
}

.item-title:hover {
  color: var(--link-hover);
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-ui);
}

.item-date {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.item-series {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.item-series a {
  color: var(--text-muted);
  text-decoration-color: var(--border);
}

.item-series a:hover {
  color: var(--text);
}

/* ── Tags ──────────────────────────────────────────────────────────── */
.tag {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.tag-essay    { background: var(--tag-article-bg);  color: var(--tag-article-text); }
.tag-project  { background: var(--tag-project-bg);  color: var(--tag-project-text); }
.tag-research { background: var(--tag-research-bg); color: var(--tag-research-text); }

/* ── Essays list ───────────────────────────────────────────────────── */
.essay-list {
  display: flex;
  flex-direction: column;
}

/* standalone essays that belong to no series */
.list-item--standalone {
  border-top: 1px solid var(--border);
  padding: 0.7rem 0;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.list-item:first-child {
  border-top: 1px solid var(--border);
}

.list-item .item-title {
  font-size: 1rem;
}

.list-item .item-date {
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ── Research list ─────────────────────────────────────────────────── */
.topic-group {
  margin-bottom: 2.5rem;
}

.topic-label {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.75rem;
}

.research-item {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.topic-items .research-item:first-child {
  border-top: 1px solid var(--border);
}

.research-item .item-meta {
  margin-top: 0.25rem;
}

.item-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-family: var(--font-ui);
  line-height: 1.5;
}

/* ── Status badges ─────────────────────────────────────────────────── */
.status {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
}

.status-progress  { background: var(--status-progress-bg);  color: var(--status-progress-text); }
.status-complete  { background: var(--status-complete-bg);  color: var(--status-complete-text); }
.status-abandoned { background: var(--status-abandoned-bg); color: var(--status-abandoned-text); }

/* ── Projects list ─────────────────────────────────────────────────── */
.status-group {
  margin-bottom: 2.5rem;
}

.status-label {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.75rem;
}

.project-item {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.status-items .project-item:first-child {
  border-top: 1px solid var(--border);
}

.status-group--archived .item-title {
  color: var(--text-muted);
}

/* ── Series grouping in article list ───────────────────────────────── */
.series-group {
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}

.series-group-label {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.1rem;
  text-decoration: none;
}

a.series-group-label:hover {
  color: var(--text);
}

.series-group-parts .list-item {
  border-top: none;
  padding-left: 1rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.series-group-parts .list-item:last-child {
  border-bottom: none;
}

/* ── Series nav ────────────────────────────────────────────────────── */
.series-nav {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  margin: 2rem 0;
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.series-index {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
}

.series-index:hover { color: var(--text); }

.series-steps {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.series-prev,
.series-next {
  color: var(--text);
  text-decoration: none;
}

.series-prev:hover,
.series-next:hover { color: var(--link-hover); }

.series-blank { visibility: hidden; }

/* ── Footer ────────────────────────────────────────────────────────── */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ── Article / content pages ───────────────────────────────────────── */
.content h1 {
  font-size: 1.8rem;
  font-weight: normal;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

.content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2rem 0 0.6rem;
  letter-spacing: -0.005em;
}

.content h4 {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-ui);
  margin: 1.5rem 0 0.5rem;
  color: var(--text-muted);
}

.content-meta {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-bottom: 2.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.content p {
  margin-bottom: 1.25rem;
  max-width: 62ch;
}

/* ── Article headings ──────────────────────────────────────────────── */

.content h1 .anchor-link,
.content h2 .anchor-link,
.content h3 .anchor-link,
.content h4 .anchor-link {
  opacity: 0;
  margin-left: 0.4em;
  font-size: 0.75em;
  font-family: var(--font-ui);
  color: var(--text-faint);
  text-decoration: none;
  transition: opacity 0.15s;
}

.content h1:hover .anchor-link,
.content h2:hover .anchor-link,
.content h3:hover .anchor-link,
.content h4:hover .anchor-link {
  opacity: 1;
}

.content pre {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  background: #f5f3f0;
  border-radius: 4px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  background: #f5f3f0;
  border-radius: 3px;
  padding: 0.1em 0.35em;
}

.content pre code {
  padding: 0;
  background: none;
  border-radius: 0;
}

.content blockquote {
  margin: 1.75rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.97rem;
  line-height: 1.7;
}

.content blockquote p {
  margin-bottom: 0.6rem;
  max-width: none;
}

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

.content blockquote ul,
.content blockquote ol {
  font-style: normal;
  padding-left: 1.25rem;
  margin-bottom: 0.6rem;
}

.content blockquote ul:last-child,
.content blockquote ol:last-child {
  margin-bottom: 0;
}

.content blockquote li + li {
  margin-top: 0.25rem;
}

.content blockquote cite {
  display: block;
  margin-top: 0.5rem;
  font-style: normal;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-faint);
}

.content blockquote cite::before {
  content: "— ";
}

/* ── Sidenotes ─────────────────────────────────────────────────────── */
.content {
  position: relative;
}

.content aside {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.content aside b {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}

.content aside p {
  margin-bottom: 0;
}

@media (min-width: 1080px) {
  .content aside {
    position: absolute;
    right: calc(-240px - 2rem);
    width: 240px;
    border-left: 2px solid var(--border);
    padding: 0.15rem 0 0.15rem 1rem;
  }
}

@media (max-width: 1079px) {
  .content aside {
    margin: 1.75rem 0;
    padding: 0.75rem 1.25rem;
    border-left: 3px solid var(--text-faint);
    background: #f5f3f0;
    border-radius: 0 4px 4px 0;
    font-size: 0.92rem;
    line-height: 1.65;
  }
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  body { padding: 1.5rem 1rem 3rem; }
  nav  { gap: 1.25rem; margin-bottom: 2.5rem; }
  .year-group { grid-template-columns: 1fr; }
  .year-label { margin-bottom: 0.25rem; }
  .list-item  { flex-direction: column; gap: 0.1rem; }
}
