/* ---------- Colour tokens ---------- */
:root {
  --bg: #f5f3eb;
  --text: #1a1a18;
  --muted: #76746c;
  --line: #dcd9cd;
  --placeholder: #e8e5da;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413;
    --text: #ecebe4;
    --muted: #8d8b83;
    --line: #2d2c29;
    --placeholder: #22211f;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141413;
  --text: #ecebe4;
  --muted: #8d8b83;
  --line: #2d2c29;
  --placeholder: #22211f;
  color-scheme: dark;
}

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

html {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .2s, color .2s;
}

main { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 24px; }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

h1, h2, h3 { font-weight: 500; margin: 0; }

/* ---------- Header & footer ---------- */
.site-header,
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 20px 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.site-name { font-weight: 700; }

.site-nav { display: flex; gap: 20px; align-items: baseline; }
.site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 3px; }

.theme-toggle {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.theme-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }

.site-footer { color: var(--muted); font-size: 12px; margin-top: 64px; }
.site-footer__links { display: flex; gap: 16px; }

/* ---------- Homepage grid ---------- */
.intro { max-width: 640px; margin: 24px 0 48px; color: var(--muted); }

.project-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 40px 24px;
}

.project-card a { display: block; }
.project-card a:hover { text-decoration: none; }
.project-card a:hover .project-card__title { text-decoration: underline; text-underline-offset: 3px; }

.project-card__image,
.placeholder {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  background: var(--placeholder);
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.project-card__meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }
.project-card__subtitle { color: var(--muted); }
.project-card__year { color: var(--muted); white-space: nowrap; }

/* ---------- Project page ---------- */
.project { max-width: 900px; margin: 24px auto 0; }

.project__header { margin-bottom: 40px; }
.project__header h1 { font-size: 1.6rem; line-height: 1.25; }
.project__meta { color: var(--muted); margin-top: 8px; }

.prose { max-width: 640px; margin-bottom: 48px; }
.prose p { margin: 0 0 1em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }

.gallery { display: flex; flex-direction: column; gap: 48px; }
.gallery figure { margin: 0; }
.gallery figcaption { color: var(--muted); font-size: 12px; margin-top: 10px; }

.project-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  margin-top: 72px;
  padding-top: 20px;
}
.project-nav__next { text-align: right; margin-left: auto; }

/* ---------- Simple pages ---------- */
.page { max-width: 640px; margin: 24px 0 0; }
.page h1 { font-size: 1.6rem; margin-bottom: 24px; }

@media (max-width: 600px) {
  main, .site-header, .site-footer { padding-left: 16px; padding-right: 16px; }
  .site-footer { flex-direction: column; gap: 8px; }
}

picture { display: block; }
