:root {
  --bg: #f2f2ef;
  --ink: #151515;
  --muted: #8b8b86;
  --line: rgba(21, 21, 21, 0.1);
  --plate: #e4e4e0;
  --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.caps {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.075em;
  line-height: 1.3;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.sr-only:focus-within {
  /* keyboard users get a visible list when they tab into it */
  width: auto;
  height: auto;
  clip: auto;
  clip-path: none;
  z-index: 30;
  top: 12px;
  left: 12px;
  padding: 10px 12px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  white-space: normal;
  max-width: 260px;
  max-height: 70vh;
  overflow: auto;
}
.sr-only button { display: block; padding: 4px 0; font-size: 12px; text-align: left; }

/* ---------- Canvas ---------- */
#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#gl.is-dragging { cursor: grabbing; }
#gl.is-hover { cursor: pointer; }

/* ---------- Phone grid (plain HTML, normal scrolling) ---------- */
.dgrid { display: none; }

html.is-phone,
html.is-phone body { height: auto; overflow: auto; overflow-x: hidden; }
html.is-phone.is-locked,
html.is-phone.is-locked body { overflow: hidden; }
html.is-phone #gl,
html.is-phone .hint { display: none; }

html.is-phone .dgrid {
  --pad: 20px;
  --img: clamp(72px, 26vw, 120px); /* bigger squares on phones, still 3 across */
  --cap-gap: 9px;
  --cap: 13px; /* one caption line */
  --tile: calc(var(--img) + var(--cap-gap) + var(--cap));
  display: grid;
  grid-template-columns: repeat(3, var(--img));
  justify-content: space-between; /* first column flush left, last flush right */
  /* 3 rows per screen: first image at the top padding, third caption at the bottom padding */
  row-gap: calc((100vh - 2 * var(--pad) - 3 * var(--tile)) / 2);
  row-gap: calc((100svh - 2 * var(--pad) - 3 * var(--tile)) / 2);
  padding: var(--pad);
}

.cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--img);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.cell:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
.cell__img {
  display: block;
  width: var(--img);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--plate);
}
.cell__img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.8s var(--ease);
}
.cell__img img.is-loaded { opacity: 1; }
.cell__cap {
  /* at least the image's width, at most a little wider */
  width: max-content;
  min-width: 100%;
  max-width: calc(var(--img) + 44px);
  margin-top: var(--cap-gap);
  line-height: var(--cap);
  height: var(--cap); /* fixed, so a 2-line caption never changes the row rhythm */
  overflow: visible;
}
/* edge columns: a wide caption lines up with the image's outer edge, inside the padding */
.cell:nth-child(3n + 1) .cell__cap { align-self: flex-start; }
.cell:nth-child(3n) .cell__cap { align-self: flex-end; }

/* ---------- Hint ---------- */
.hint {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 8px 24px rgba(0, 0, 0, 0.06);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  z-index: 5;
}
.hint__dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }
.hint.is-hidden { opacity: 0; transform: translate(-50%, 8px); }

/* ---------- Project view ---------- */
.pv {
  position: fixed;
  inset: 0;
  z-index: 10;
  visibility: hidden;
  pointer-events: none;
}
.pv.is-open { visibility: visible; pointer-events: auto; }
.pv__bg { position: absolute; inset: 0; background: var(--bg); opacity: 0; }

.pv__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px clamp(12px, 2vw, 24px);
  pointer-events: none;
}
.pv__bar > * { pointer-events: auto; }
.pv__close {
  padding: 8px 12px;
  margin-left: -12px;
  border-radius: 999px;
  transition: background-color 0.3s;
}
.pv__close:hover { background: rgba(0, 0, 0, 0.05); }
.pv__close:focus-visible,
.pv__next:focus-visible,
.sr-only button:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
.pv__count { color: var(--muted); font-variant-numeric: tabular-nums; }

.pv__scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(21, 21, 21, 0.25) transparent;
}
.pv__inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: clamp(64px, 9vh, 96px) clamp(12px, 2vw, 24px) 48px;
}

.pv__head {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(24px, 5vw, 96px);
  align-items: end;
}
.pv__hero {
  width: min(100%, calc(100vh - 170px));
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--plate);
}
.pv__hero img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pv__info { padding-bottom: 4px; max-width: 460px; }
.pv__kicker { color: var(--muted); margin-bottom: 18px; }
.pv__title {
  font-size: clamp(26px, 3.4vw, 48px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  text-wrap: balance;
}
.pv__text {
  margin-top: 22px;
  font-size: 14px;
  line-height: 1.55;
  color: #3a3a37;
  max-width: 40ch;
  text-wrap: pretty;
}
.pv__meta {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.pv__meta dt { font-size: 10px; font-weight: 500; letter-spacing: 0.075em; text-transform: uppercase; color: var(--muted); }
.pv__meta dd { margin-top: 4px; font-size: 13px; }

.pv__gallery {
  margin-top: clamp(56px, 10vw, 140px);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 20px);
  align-items: start;
}
.pv__gallery figure { background: var(--plate); overflow: hidden; }
.pv__gallery img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s var(--ease);
}
.pv__gallery img.is-loaded { opacity: 1; }
.pv__gallery figure:nth-child(4n + 1) { grid-column: 1 / span 8; }
.pv__gallery figure:nth-child(4n + 2) { grid-column: 9 / span 4; margin-top: 30%; }
.pv__gallery figure:nth-child(4n + 3) { grid-column: 2 / span 4; }
.pv__gallery figure:nth-child(4n + 4) { grid-column: 6 / span 7; margin-top: 12%; }

.pv__next {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin-top: clamp(64px, 10vw, 140px);
  padding: 22px 0 8px;
  border-top: 1px solid var(--line);
  text-align: left;
}
.pv__next span { color: var(--muted); }
.pv__next-title {
  font-size: clamp(22px, 3vw, 40px);
  font-weight: 500;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  line-height: 1;
  transition: transform 0.6s var(--ease);
}
.pv__next:hover .pv__next-title { transform: translateX(10px); }

/* ---------- Flyer ---------- */
.flyer {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  display: none;
  overflow: hidden;
  pointer-events: none;
  transform-origin: 0 0;
  background: var(--plate);
  will-change: transform;
}
.flyer img { display: block; width: 100%; height: 100%; object-fit: cover; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; }

@media (max-width: 760px) {
  .pv__head { grid-template-columns: 1fr; align-items: start; }
  .pv__hero { width: 100%; }
  .pv__gallery { grid-template-columns: 1fr; }
  .pv__gallery figure:nth-child(n) { grid-column: 1 / -1; margin-top: 0; }
  .hint { font-size: 9px; gap: 8px; }
}
