:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1b1a18;
  --muted: #6b665e;
  --line: #e2ddd4;
  --accent: #b4481a;
  --code-bg: #ece7df;
  --radius: 10px;
  --max: 1120px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131211;
    --surface: #1d1b19;
    --ink: #ece8e1;
    --muted: #a19b91;
    --line: #2f2c28;
    --accent: #f0874f;
    --code-bg: #26231f;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

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

/* Header */
.site-header { padding: 28px 0; }
.site-header .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { font: 600 22px/1.2 var(--serif); text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; gap: 22px; font-size: 15px; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }

/* Home */
.hero { padding-block: 56px 64px; }
.hero h1 {
  font: 400 clamp(34px, 5.6vw, 64px)/1.08 var(--serif);
  letter-spacing: -0.02em;
  margin: 0;
  max-width: 17ch;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p { color: var(--muted); margin: 20px 0 0; font-size: 18px; }

.section-label {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); margin: 0 0 20px; padding-top: 24px; border-top: 1px solid var(--line);
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 40px 28px; padding-bottom: 80px; }
.card { text-decoration: none; display: block; }
.card .thumb { aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius); background: var(--line); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.card:hover .thumb img { transform: scale(1.03); }
.card h2 { font: 500 23px/1.25 var(--serif); margin: 16px 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card:hover h2 { color: var(--accent); }

/* Project pages */
.project-head { padding-block: 40px 32px; }
.eyebrow { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin: 0 0 12px; }
.project-head h1 { font: 400 clamp(36px, 6vw, 60px)/1.05 var(--serif); letter-spacing: -0.02em; margin: 0; }
.project-head .lede { font-size: 20px; color: var(--muted); margin: 14px 0 0; max-width: 40ch; }

.cover { border-radius: var(--radius); overflow: hidden; margin-bottom: 48px; }
.cover img { width: 100%; max-height: 680px; object-fit: cover; }
.cover.contain { background: var(--surface); padding: 24px; border: 1px solid var(--line); }
.cover.contain img { object-fit: contain; max-height: 520px; margin: 0 auto; width: auto; }

.prose { max-width: 680px; padding-bottom: 32px; }
.prose p { margin: 0 0 1.1em; }
.prose h2 { font: 500 28px/1.25 var(--serif); margin: 1.8em 0 0.5em; }
.prose h3 { font: 600 17px/1.4 var(--sans); margin: 1.6em 0 0.4em; }
.prose code {
  font: 0.88em/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--code-bg); padding: 2px 6px; border-radius: 5px; overflow-wrap: anywhere;
}
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 0.5em; }

.figure { margin: 8px 0 48px; }
.figure img { border-radius: var(--radius); background: var(--surface); }
.figure figcaption, .gallery figcaption { color: var(--muted); font-size: 14px; margin-top: 10px; line-height: 1.5; }

/* Tape Escape puzzles */
.puzzles { display: grid; gap: 56px; padding: 16px 0 72px; }
.puzzle { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 36px; align-items: center; }
.puzzle img { border-radius: var(--radius); width: 100%; max-height: 560px; object-fit: cover; }
.puzzle h2 { font: 500 26px/1.25 var(--serif); margin: 0 0 10px; }
.puzzle p { margin: 0; }
.puzzle:nth-child(even) .puzzle-img { order: 2; }

/* Projection gallery */
.gallery { columns: 3 300px; column-gap: 24px; padding-bottom: 72px; }
.gallery figure { break-inside: avoid; margin: 0 0 28px; }
.gallery img { border-radius: var(--radius); width: 100%; }
.gallery figcaption strong { color: var(--ink); font-weight: 500; display: block; }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 56px; align-items: center; padding-block: 32px 96px; }
.about img { border-radius: var(--radius); }
.about h1 { font: 400 clamp(34px, 5vw, 52px)/1.1 var(--serif); letter-spacing: -0.02em; margin: 0 0 20px; }
.about p { font-size: 19px; margin: 0 0 1em; }

.back { display: inline-block; margin: 8px 0 72px; font-size: 15px; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--accent); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: 15px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--ink); }

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .hero { padding-block: 32px 44px; }
  .puzzle, .about { grid-template-columns: 1fr; gap: 20px; }
  .puzzle:nth-child(even) .puzzle-img { order: 0; }
  .about { gap: 28px; padding-block-start: 8px; }
  .grid { grid-template-columns: 1fr; }
}

/* Home: plain project index, photo appears behind on hover */
.home { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
.home main { flex: 1; display: flex; align-items: center; }
.project-index { width: 100%; padding-block: 48px; }
.project-index ul { list-style: none; margin: 0; padding: 0; text-align: center; position: relative; z-index: 1; }
.project-index li + li { margin-top: 22px; }
.project-index a { text-decoration: none; }
.project-index span {
  display: inline-block; padding: 3px 8px;
  font: 600 18px/1.3 var(--sans);
  text-transform: uppercase; letter-spacing: 0.08em;
  transition: background-color 0.2s, color 0.2s;
}
.project-index a:hover span, .project-index a:focus-visible span { color: var(--accent); }
.project-index ul:has(a:hover) span { background: var(--bg); }

.project-index img {
  position: fixed; z-index: -1;
  inset: 88px max(16px, 6vw) 120px;
  width: calc(100% - 2 * max(16px, 6vw)); height: calc(100% - 208px);
  object-fit: cover; border-radius: var(--radius);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease;
}
.project-index a:hover img { opacity: 1; }
.home .site-header, .home .site-footer { position: relative; z-index: 1; }
@media (hover: none) { .project-index img { display: none; } }
