/* ── Reset ─────────────────────────────────────────────────── */

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

/* ── Theme tokens ─────────────────────────────────────────── */

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --surface: #f5f5f5;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-mid: #555555;
  --text-dim: #999999;
  --accent: #1a1a1a;
  --accent-fg: #ffffff;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --max-width: 720px;
  --nav-height: 56px;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-subtle: #111111;
  --surface: #161616;
  --border: #262626;
  --text: #e5e5e5;
  --text-mid: #888888;
  --text-dim: #555555;
  --accent: #e5e5e5;
  --accent-fg: #0a0a0a;
}

/* ── Base ──────────────────────────────────────────────────── */

html {
  font-size: 12px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.2s, color 0.2s;
}

a {
  color: var(--text);
  text-decoration: none;
  transition: opacity 0.15s;
}

a:hover {
  opacity: 0.6;
}

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

img + em {
  display: block;
  text-align: center;
  font-style: normal;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1, h2, h3 { font-size: 1rem; }

p {
  color: var(--text-mid);
  line-height: 1.7;
}

/* ── Layout ───────────────────────────────────────────────── */

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

main {
  flex: 1;
}

/* ── Navigation ───────────────────────────────────────────── */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-family: var(--font);
  font-weight: inherit;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-brand:hover {
  opacity: 1;
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
}

.nav-links a {
  font-family: var(--font);
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.65rem;
  transition: color 0.15s;
}

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

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

.theme-toggle {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.4rem;
  font-family: var(--font);
  line-height: 1;
  margin-left: 0.5rem;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  opacity: 0.6;
}


.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-mid);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 4px;
  line-height: 1;
}

.nav-toggle svg {
  width: 18px;
  height: 18px;
}

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

.home-content {
  padding: 3rem 0;
}

.home-content p {
  line-height: 1.8;
}

.home-content a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Page body (generic section wrapper) ──────────────────── */

.page-body {
  padding: 2.5rem 0 4rem;
}

/* ── Page prose (for content pages: about, publications, etc) */

.page-prose h2 {
  margin: 2rem 0 0.75rem;
}

.page-prose h2:first-child {
  margin-top: 0;
}

.page-prose h3 {
  margin: 1.5rem 0 0.5rem;
}

.page-prose p {
  margin-bottom: 0.85rem;
}

.page-prose ul,
.page-prose ol {
  color: var(--text-mid);
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.page-prose li {
  margin-bottom: 0.3rem;
  line-height: 1.7;
}

.page-prose strong {
  color: var(--text);
  font-weight: 600;
}

.page-prose a {
  text-decoration: underline;
  text-decoration-color: var(--text-dim);
  text-underline-offset: 3px;
}

.page-prose a:hover {
  text-decoration-color: var(--text);
  opacity: 1;
}

.page-prose blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  margin: 1.25rem 0;
  color: var(--text-mid);
}

.page-prose code {
  font-family: var(--font);
  background: var(--surface);
  padding: 0.15em 0.4em;
  border: 1px solid var(--border);
}

.page-prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.page-prose pre code {
  background: none;
  border: none;
  padding: 0;
}

/* ── About layout ─────────────────────────────────────────── */

.about-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.about-portrait {
  flex: 0 0 40%;
}

.about-portrait img {
  width: 100%;
  height: auto;
  display: block;
}

.about-text {
  flex: 1;
}

@media (max-width: 700px) {
  .about-layout {
    flex-direction: column;
  }

  .about-portrait {
    flex: none;
    width: 100%;
  }
}

/* ── Project List ─────────────────────────────────────────── */

.project-item {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.project-image {
  flex-shrink: 0;
  width: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 4px;
  padding: 1rem 0;
}

.project-image img {
  max-width: 60%;
  max-height: 60%;
  display: block;
  border-radius: 4px;
}

.project-image.plain {
  background: none;
  width: 160px;
  height: auto;
}

.project-image.plain img {
  max-width: 100%;
  max-height: none;
}

.project-image:hover {
  opacity: 0.8;
}

.project-details {
  flex: 1;
}

@media (max-width: 768px) {
  .project-item {
    flex-direction: column;
  }

  .project-image {
    width: 200px;
  }
}

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

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

.post-item {
  padding: 0.3rem 0;
  line-height: 1.7;
}

.post-item a {
  font-weight: 500;
}

.post-item .post-date {
  color: var(--text-dim);
}

/* ── Post single ──────────────────────────────────────────── */

.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  margin-bottom: 0.4rem;
}

.post-header .post-subtitle {
  color: var(--text-mid);
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.post-header .post-date {
  color: var(--text-dim);
  font-size: 1rem;
}

.post-header .post-external-link {
  display: inline-block;
  margin-left: 0.75rem;
  color: var(--text-dim);
  font-size: 1rem;
}

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

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  transition: background 0.2s;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-dim);
}

.footer-links {
  display: flex;
  gap: 0.75rem;
}

.footer-links a {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-links a:hover {
  color: var(--text-mid);
  opacity: 1;
}

/* ── 404 ──────────────────────────────────────────────────── */

.error-page {
  padding: 6rem 0;
  text-align: center;
}

.error-page h1 {
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-dim);
}

.error-page p {
  margin-bottom: 2rem;
}

.error-page a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
    align-items: center;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    gap: 0;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.5rem 0;
    display: block;
    width: 100%;
  }

  .site-nav .container {
    position: relative;
  }

  .footer-inner {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
}
