/* ---------- base ---------- */

:root {
  --text: #111;
  --muted: #999;
  --bg: #fff;
  --tile: #f2f2f2;
  --gutter: 32px;
  --header-h: 64px;
  --fade: 600ms;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  text-transform: lowercase;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  font-size: inherit;
  font-weight: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  opacity: 0.5;
}

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

.wrap {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main {
  flex: 1;
}

.label {
  color: var(--muted);
  margin-bottom: 12px;
}

/* ---------- header + footer ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.site-header .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-h);
}

.site-header nav {
  display: flex;
  gap: 24px;
}

.site-footer {
  padding: 120px 0 32px;
  color: var(--muted);
}

/* ---------- home grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 48px 24px;
  padding-top: 32px;
  scroll-margin-top: var(--header-h);
}

.card:hover {
  opacity: 1; /* the photo fades instead of the whole card */
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--tile);
}

.card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-media .preview {
  opacity: 0;
  transition: opacity var(--fade) ease;
}

.card-media .preview.is-on {
  opacity: 1;
}

.card p {
  margin-top: 8px;
}

.card:hover p {
  opacity: 0.5;
}

/* ---------- home gallery ---------- */

.gallery {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding-top: 32px;
}

.gallery-col {
  flex: 1;
  min-width: 0;
}

.gallery-item {
  display: block;
  margin-bottom: 24px;
  break-inside: avoid;
  cursor: zoom-in;
}

.gallery-item:hover {
  opacity: 1;
}

.gallery-item img {
  width: 100%;
  height: auto;
  background: var(--tile);
  transition: opacity 300ms ease;
}

.gallery-item:hover img {
  opacity: 0.85;
}

/* ---------- focused photo view ---------- */

html.no-scroll {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 0 var(--gutter);
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, visibility 0s linear 300ms;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 300ms ease;
}

.lightbox-close {
  align-self: flex-end;
  height: var(--header-h);
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.lightbox-close:hover {
  opacity: 0.5;
}

.lightbox-photo {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox-photo img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: default;
}

.lightbox-more {
  align-self: center;
  display: flex;
  gap: 16px;
  padding: 20px 0 28px;
}

.lightbox-name {
  color: var(--muted);
}

/* ---------- about + contact ---------- */

.section {
  max-width: 480px;
  padding-top: 120px;
  scroll-margin-top: var(--header-h);
}

.section p + p {
  margin-top: 1em;
}

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

.contact-list a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.contact-page .section:first-child {
  padding-top: 32px;
}

/* ---------- project page ---------- */

.project {
  padding-top: 32px;
}

.project-head {
  max-width: 560px;
}

.project-meta {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0 16px;
  margin-top: 24px;
}

.project-meta dt {
  color: var(--muted);
}

.project-desc {
  margin-top: 24px;
}

.photos {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 64px;
}

.photos img {
  height: auto;
  background: var(--tile);
}

.back {
  display: inline-block;
  margin-top: 64px;
}

/* ---------- tablet + phone ---------- */

@media (max-width: 1024px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }

}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
    --header-h: 56px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-top: 16px;
  }

  .section {
    padding-top: 80px;
  }

  .gallery {
    gap: 16px;
    padding-top: 16px;
  }

  .gallery-item {
    margin-bottom: 16px;
  }

  .lightbox-more {
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .photos {
    gap: 12px;
    margin-top: 48px;
  }

  .site-footer {
    padding-top: 80px;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .lightbox,
  .lightbox.is-open,
  .gallery-item img {
    transition: none;
  }
}
