/* ==========================================================================
   Gallery, selected work, lightbox and the contextual cursor.
   ========================================================================== */

/* ── The grid ───────────────────────────────────────────────────────── */
/* A curated composition, not six equal squares. Twelve columns with items
   placed deliberately; ratios vary so the eye moves through the set.
   Below the breakpoints this becomes a single vertical sequence. */
.gallery__grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(1rem, 2.4vw, 2.5rem);
}

.gallery__item { grid-column: span 12; }

/* The arrangement. Each rule is one deliberate placement, and the pattern
   repeats every six items so a longer set keeps its rhythm. */
@media (min-width: 800px) {
  .gallery__item:nth-child(6n + 1) { grid-column: span 7; }
  .gallery__item:nth-child(6n + 2) { grid-column: span 5; align-self: end; }
  .gallery__item:nth-child(6n + 3) { grid-column: 3 / span 5; }
  .gallery__item:nth-child(6n + 4) { grid-column: span 4; align-self: center; }
  .gallery__item:nth-child(6n + 5) { grid-column: span 8; }
  .gallery__item:nth-child(6n + 6) { grid-column: 5 / span 6; }
}

.gallery__link {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

/* The ratio decides the shape; this decides how much screen any one item is
   allowed to take. Without it a portrait image in a wide column runs to
   nearly a full viewport, and the grid stops reading as a composition. */
.gallery__frame {
  display: block;
  position: relative;
  overflow: hidden;
  max-height: min(64vh, 560px);
}

.gallery__frame::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--bg);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.gallery__link:hover .gallery__frame::after,
.gallery__link:focus-visible .gallery__frame::after { opacity: 0.22; }
.gallery__link:hover .gallery__frame > img { transform: scale(1.03); }

.gallery__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  align-items: baseline;
  margin-top: var(--sp-4);
}
.gallery__cat {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-dim);
}
.gallery__title { font-size: var(--fs-sm); color: var(--text-muted); }
.gallery__link:hover .gallery__title { color: var(--text); }

.gallery__more { margin-top: clamp(2rem, 3vw, 3rem); }

/* ── Selected work ──────────────────────────────────────────────────── */
.work__list { display: grid; gap: clamp(3rem, 7vw, 6rem); }

.work__item {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: end;
}
.work__item:nth-child(even) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.work__item:nth-child(even) .work__media { order: 2; }

.work__media { overflow: hidden; }
.work__media img { transition: transform var(--dur-slow) var(--ease); }
.work__item:hover .work__media img { transform: scale(1.02); }

.work__name { font-size: var(--fs-2xl); margin-bottom: var(--sp-4); }
.work__facts {
  display: grid;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-dim);
}
.work__facts div { display: flex; justify-content: space-between; gap: var(--sp-4);
  border-bottom: 1px solid var(--hairline); padding-bottom: var(--sp-3); }
.work__facts dd { margin: 0; color: var(--text-muted); }
.work__summary { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-5); }

/* ── Lightbox ───────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(5, 15, 34, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-5) var(--gutter-safe);
  color: #eef1f7;
}
.lightbox__count { font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: var(--track-wide); color: #6a778c; }

.lightbox__close, .lightbox__nav {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  color: #eef1f7;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255, 255, 255, 0.08); }
.lightbox__nav[disabled] { opacity: 0.3; cursor: default; }

.lightbox__stage {
  display: grid;
  place-items: center;
  padding-inline: var(--gutter-safe);
  min-height: 0;
}
.lightbox__media {
  max-width: min(1200px, 100%);
  max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
}

.lightbox__foot {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--gutter-safe) var(--sp-7);
  color: #eef1f7;
}
.lightbox__cat { font-family: var(--font-mono); font-size: var(--fs-2xs);
  letter-spacing: var(--track-wide); text-transform: uppercase; color: #6a778c; }
.lightbox__title { font-family: var(--font-display); font-size: var(--fs-lg); }
.lightbox__caption { color: #9aa6b8; font-size: var(--fs-sm); max-width: 60ch; }
.lightbox__controls { display: flex; gap: var(--sp-3); }

/* ── Contextual cursor ──────────────────────────────────────────────── */
/* The one place the native cursor is supplemented — a VIEW badge that
   follows the pointer over gallery media. Never a replacement cursor for
   the whole site, and never on touch. */
.viewcursor {
  position: fixed;
  top: 0; left: 0;
  z-index: var(--z-cursor);
  display: grid;
  place-items: center;
  width: 76px; height: 76px;
  margin: -38px 0 0 -38px;
  border-radius: 50%;
  background: var(--accent-500);
  color: #050f22;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: var(--track-wide);
  pointer-events: none;
  opacity: 0;
  /* JS supplies only the position, through these two custom properties.
     CSS keeps ownership of the scale, so the two can never disagree. */
  transform: translate(var(--vx, 0px), var(--vy, 0px)) scale(0.6);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.viewcursor.is-visible {
  opacity: 1;
  transform: translate(var(--vx, 0px), var(--vy, 0px)) scale(1);
}

@media (hover: none), (pointer: coarse) {
  .viewcursor { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .viewcursor { display: none; }
}
