/* ---------- Tokens ---------- */
:root {
  --bg: #fff;
  --ink: #1a1a1a;
  --ink-soft: #555;
  --muted: #9a9a9a;
  --rule: #e8e8e8;
  --placeholder: #f3f3f2;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4.4vw, 64px);
  --gap: clamp(16px, 2.5vw, 36px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, video { display: block; max-width: 100%; height: auto; }
picture { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

/* ---------- Header / footer ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 32px;
  padding: 40px var(--gutter) 56px;
  view-transition-name: site-header;
}
.site-name {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: .28em;
  text-transform: uppercase;
}
.site-nav { display: flex; gap: 32px; }
.site-nav a {
  font-size: 14px;
  color: var(--muted);
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color .3s var(--ease), border-color .3s var(--ease);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

.site-footer {
  padding: 48px var(--gutter) 40px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .04em;
}

/* ---------- Section heading ---------- */
.section-heading {
  margin: 0 0 36px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  font-weight: 300;
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* "#" link shown beside a heading so the section can be linked to. */
.anchor-link {
  margin-left: .6em;
  color: var(--muted);
  opacity: 0;
  transition: opacity .3s var(--ease), color .3s var(--ease);
}
.section-heading:hover .anchor-link, .anchor-link:focus-visible { opacity: 1; }
.anchor-link:hover { color: var(--ink); }
@media (hover: none) { .anchor-link { opacity: 1; } }
[id] { scroll-margin-top: 24px; }

/* ---------- Gallery ---------- */
.gallery-section { padding: 0 var(--gutter) 72px; }
.gallery-section + .gallery-section { padding-top: 24px; }

/* Without JS: CSS columns (top-to-bottom). With JS: site.js lays cards out
   left-to-right into .masonry-col columns. */
.masonry { columns: 3; column-gap: var(--gap); }
.masonry.is-laid-out { columns: auto; display: flex; gap: var(--gap); align-items: flex-start; }
.masonry-col { flex: 1; min-width: 0; }
@media (max-width: 1099px) { .masonry { columns: 2; } }
@media (max-width: 639px)  { .masonry { columns: 1; } }

.card {
  display: block;
  break-inside: avoid;
  margin-bottom: 40px;
}
.card-media {
  overflow: hidden;
  background: var(--placeholder);
}
.card-media img {
  width: 100%;
  transition: transform 1.1s var(--ease), opacity .6s var(--ease);
}
.card:hover .card-media img { transform: scale(1.03); }
.card:hover .card-title { color: var(--ink); }
.card-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 14px;
}
.card-title { color: #333; transition: color .3s var(--ease); }

/* Gentle fade-up as cards scroll into view (JS only, motion-safe). */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .9s var(--ease), transform .9s var(--ease);
  }
  .js .reveal.is-visible { opacity: 1; transform: none; }
}

/* ---------- Piece page ---------- */
/* Photo on the left at its natural shape; the text sits right beside it. */
.piece-top {
  display: flex;
  gap: clamp(32px, 5vw, 72px);
  padding: 0 var(--gutter);
  align-items: flex-start;
}
.piece-hero { margin: 0; flex: 0 1 auto; min-width: 0; }
.piece-info { flex: 0 0 clamp(260px, 26vw, 380px); }
/* The main photo keeps its own shape, up to most of the screen height. */
.piece-hero img { width: auto; max-width: 100%; max-height: 76vh; }
.piece-info { padding-top: 4px; }
.back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  transition: color .3s var(--ease);
}
.back-link:hover { color: var(--ink); }
.piece-title {
  margin: 0 0 24px;
  font-size: clamp(26px, 2.6vw, 34px);
  font-weight: 300;
  line-height: 1.2;
  letter-spacing: -.01em;
}
.piece-text { font-size: 15px; color: var(--ink-soft); }
.piece-text p { margin: 0 0 1em; }
.piece-meta { margin: 28px 0 0; font-size: 13px; }
.piece-meta div { display: flex; gap: 16px; padding: 7px 0; border-top: 1px solid var(--rule); }
.piece-meta div:last-child { border-bottom: 1px solid var(--rule); }
.piece-meta dt { width: 80px; flex: none; color: var(--muted); }
.piece-meta dd { margin: 0; }

.hero-btn, .rail-item {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* Carousel of smaller photos */
.rail-wrap { position: relative; margin-top: 16px; }
.rail-btn {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 40px;
  height: 40px;
  margin-top: -26px; /* centre on the photos, ignoring the bottom padding */
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .12);
  color: var(--ink);
  cursor: pointer;
  transition: opacity .3s var(--ease);
}
.rail-btn[hidden] { display: block; opacity: 0; pointer-events: none; }
.rail-prev { left: calc(var(--gutter) + 12px); }
.rail-next { right: 12px; }
.rail-btn:hover { background: #fff; }
.rail {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding: 0 var(--gutter);
  padding: 0 var(--gutter) 12px;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item { position: relative; flex: none; scroll-snap-align: start; }
/* About half the height of the main photo (which is up to 76vh). */
.rail-item img {
  height: clamp(200px, 38vh, 420px);
  width: auto;
  max-width: none;
  transition: opacity .4s var(--ease);
}
.rail-item:hover img { opacity: .85; }
.rail-item.is-video img { background: #000; }
.play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .88);
}
.play::after {
  content: "";
  position: absolute;
  left: 21px;
  top: 17px;
  border-style: solid;
  border-width: 9px 0 9px 14px;
  border-color: transparent transparent transparent var(--ink);
}

.piece-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin: 72px var(--gutter) 0;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
}
.piece-nav a { display: flex; flex-direction: column; gap: 4px; transition: opacity .3s var(--ease); }
.piece-nav a:hover { opacity: .6; }
.piece-nav span { font-size: 12px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.piece-nav .next { text-align: right; margin-left: auto; }

@media (max-width: 899px) {
  .piece-top { flex-direction: column; gap: 28px; }
  .piece-info { flex: none; width: 100%; }
  .piece-hero img { max-height: 70vh; }
  .back-link { margin-bottom: 16px; }
  .rail-wrap { margin-top: 28px; }
  .rail-item img { height: clamp(200px, 32vh, 300px); }
}

/* ---------- Lightbox ---------- */
.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(56px, 6vw, 72px) clamp(16px, 7vw, 96px);
  border: 0;
  background: var(--bg);
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: transparent; }
.lightbox-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lightbox-stage img, .lightbox-stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.lightbox-btn, .lightbox-close {
  position: fixed;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .3s var(--ease);
}
.lightbox-btn:hover, .lightbox-close:hover { color: var(--ink); }
.lightbox-btn { top: 50%; transform: translateY(-50%); font-size: 22px; padding: 16px; }
.lightbox-prev { left: clamp(4px, 2vw, 24px); }
.lightbox-next { right: clamp(4px, 2vw, 24px); }
.lightbox-close { top: 14px; right: 20px; font-size: 32px; font-weight: 200; line-height: 1; padding: 4px; }
.lightbox-count {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--muted);
}
.lightbox.single .lightbox-btn, .lightbox.single .lightbox-count { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] { animation: fade-in .35s var(--ease); }
  .lightbox-stage > * { animation: zoom-in .4s var(--ease); }
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes zoom-in { from { opacity: 0; transform: scale(.98); } }

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(40px, 6vw, 88px);
  padding: 0 var(--gutter);
  align-items: start;
}
.about-photo { margin: 0; }
.about-photo img { width: 100%; max-height: 80vh; object-fit: cover; }
.about-photo-placeholder {
  height: 78vh;
  display: grid;
  place-items: center;
  background: var(--placeholder);
  color: #aaa;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.about-copy { padding-top: 24px; max-width: 520px; }
.page-title { margin: 0 0 28px; font-size: clamp(26px, 2.6vw, 34px); font-weight: 300; }
.about-text { font-size: 17px; color: var(--ink-soft); margin-bottom: 56px; }
.about-text p { margin: 0 0 1em; }
.contact-icons { list-style: none; margin: 32px 0 0; padding: 0; display: flex; gap: 2px; margin-left: -11px; }
.contact-icons a { display: grid; place-items: center; width: 44px; height: 44px; color: var(--ink); transition: opacity .3s var(--ease); }
/* Hovering one icon fades the others. */
.contact-icons:hover a:not(:hover), .contact-icons:focus-within a:not(:focus-visible) { opacity: .3; }
@media (max-width: 799px) {
  .about { grid-template-columns: 1fr; }
  .about-photo-placeholder { height: 50vh; }
  .about-copy { padding-top: 0; }
}

/* ---------- Page transitions (supported browsers) ---------- */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: .35s var(--ease) both vt-out; }
  ::view-transition-new(root) { animation: .5s var(--ease) both vt-in; }
  ::view-transition-group(*) { animation-duration: .55s; animation-timing-function: var(--ease); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Small screens ---------- */
@media (max-width: 639px) {
  .site-header { padding: 24px var(--gutter) 32px; }
  .site-name { font-size: 13px; letter-spacing: .22em; }
  .site-nav { gap: 22px; }
  .card { margin-bottom: 32px; }
  .gallery-section { padding-bottom: 48px; }
  .piece-nav { margin-top: 56px; }
}
