@import url('https://fonts.googleapis.com/css2?family=League+Spartan:wght@300;400;500;600;700&display=swap');

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

:root {
  --bg:        #FFF5E4;
  --ink:        #1a1a18;
  --ink-muted:  #555550;
  --line:       #1a1a18;
  --content-w:  640px;
  --gutter:     2rem;
  --font:       'League Spartan', sans-serif;
}

html { font-size: 18px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.65;
  min-height: 100vh;
  padding: var(--gutter);
}

/* ─── Document wrapper ──────────────────────────────── */
.page {
  max-width: var(--content-w);
  margin: 0 auto;
  padding-top: 2.5rem;
}

/* ─── Header ────────────────────────────────────────── */
.site-header {
  margin-bottom: 1rem;
}

.site-name {
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0.3rem;
  margin-bottom: 0.5rem;
  display: block;
  text-decoration: none;
  color: inherit;
}

.site-nav {
  display: flex;
  justify-content: flex-end;
  gap: 1.6rem;
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.site-nav a {
  color: var(--ink);
  text-decoration: none;
}
.site-nav a:hover { text-decoration: underline; }
.site-nav a.active {
  text-decoration: underline;
  pointer-events: none;
  cursor: default;
}

/* ─── Main content ───────────────────────────────────── */
main {
  margin-top: 2.2rem;
}

/* ─── Typography ─────────────────────────────────────── */
p {
  margin-bottom: 1rem;
  font-weight: 300;
  font-size: 0.95rem;
}

ul {
  padding-left: 1.4rem;
  margin-bottom: 1rem;
}
ul li {
  font-weight: 300;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  letter-spacing: 0.01em;
}

/* ─── Project list (projects.html) ───────────────────── */
.project-list {
  margin-top: 1.5rem;
}

.project-entry {
  margin-bottom: 3rem;
  display: block;
  text-decoration: none;
  color: inherit;
}

.project-entry h2 {
  margin-bottom: 0.5rem;
}

.project-entry:hover h2 {
  text-decoration: underline;
}

/* ─── Image grid ─────────────────────────────────────── */
.image-grid {
  width: 100%;
  border: 1px solid var(--ink);
  background: #fff;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

/* 1 image */
.image-grid[data-count="1"] img {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 16/9;
}

/* 2 images — 2/3 left + 1/3 right */
.image-grid[data-count="2"] {
  display: grid;
  grid-template-columns: 2fr 1fr;
  aspect-ratio: 16/9;
}
.image-grid[data-count="2"] img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
}
.image-grid[data-count="2"] img:first-child {
  border-right: 1px solid var(--ink);
}

/* 3 images — full left, 2-stack right */
.image-grid[data-count="3"] {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 16/9;
}
.image-grid[data-count="3"] img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
}
.image-grid[data-count="3"] img:first-child {
  grid-row: 1 / 3;
  border-right: 1px solid var(--ink);
}
.image-grid[data-count="3"] img:nth-child(2) {
  border-bottom: 1px solid var(--ink);
}


/* 3 images — portrait side images detected: switch to 3 equal columns */
.image-grid[data-count="3"][data-layout="portrait-sides"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;
  aspect-ratio: unset;
}
.image-grid[data-count="3"][data-layout="portrait-sides"] img {
  width: 100%;
  height: auto;
  aspect-ratio: 2/3;
  object-fit: cover;
  object-position: center top;
  grid-row: unset;
  border-right: 1px solid var(--ink);
  border-bottom: none;
}
.image-grid[data-count="3"][data-layout="portrait-sides"] img:last-child {
  border-right: none;
}
.image-grid[data-count="3"][data-layout="portrait-sides"] img:nth-child(2) {
  border-bottom: none;
}
/* 4 images — 2x2 grid */
.image-grid[data-count="4"] {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  aspect-ratio: 4/3;
}
.image-grid[data-count="4"] img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.image-grid[data-count="4"] img:nth-child(2) { border-right: none; }
.image-grid[data-count="4"] img:nth-child(3) { border-bottom: none; }
.image-grid[data-count="4"] img:nth-child(4) { border-right: none; border-bottom: none; }

/* 5+ images — big top + 4-col strip */
.image-grid[data-count="many"] {
  display: grid;
  grid-template-rows: auto auto;
  height: auto;
}
.image-grid[data-count="many"] .row-top img {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 16/7;
  border-bottom: 1px solid var(--ink);
}
.image-grid[data-count="many"] .row-strip {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  height: 130px;
}
.image-grid[data-count="many"] .row-strip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-right: 1px solid var(--ink);
}
.image-grid[data-count="many"] .row-strip img:last-child {
  border-right: none;
}

.project-caption {
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--ink-muted);
  margin-bottom: 0;
}

/* placeholder when no image (broken) */
img { display: block; }

/* ─── Individual project page ─────────────────────────── */
.project-hero {
  width: 100%;
  margin-bottom: 1.5rem;
  border: 1px solid var(--ink);
}
.project-hero img {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 16/9;
}

.project-body {
  margin-top: 1.5rem;
}
.project-body h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
}
.project-body p {
  margin-bottom: 1rem;
}

/* ─── Gallery page ───────────────────────────────────── */
.gallery-grid {
  columns: 2;
  column-gap: 8px;
  margin-top: 1rem;
}
.gallery-grid img {
  width: 100%;
  margin-bottom: 8px;
  display: block;
  border: 1px solid var(--ink);
  break-inside: avoid;
}

/* ─── Contact ────────────────────────────────────────── */
.contact-link {
  color: var(--ink);
  font-weight: 500;
}

/* ─── Mobile ─────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { --gutter: 1.1rem; }
  html { font-size: 16px; }

  .page { padding-top: 1.5rem; }

  .image-grid[data-count="2"],
  .image-grid[data-count="3"] {
    grid-template-columns: 1fr;
    grid-template-rows: unset;
    height: auto;
  }
  .image-grid[data-count="2"] img,
  .image-grid[data-count="3"] img:first-child {
    grid-row: unset;
    border-right: none;
    border-bottom: 1px solid var(--ink);
    aspect-ratio: 4/3;
    height: auto;
  }
  .image-grid[data-count="3"] img:nth-child(2) {
    border-bottom: 1px solid var(--ink);
  }
  .image-grid[data-count="4"] {
    height: auto;
  }
  .image-grid[data-count="4"] img {
    aspect-ratio: 4/3;
    height: auto;
  }
  .gallery-grid {
    columns: 1;
  }
  .image-grid[data-count="many"] .row-strip {
    height: 80px;
  }
}