*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --white: #fdfcfa;
  --ink: #151515;
  --muted: #8d8a83;
  --line: #e4e1da;
  --accent: #d9442b;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
html,
body {
  height: 100%;
  background: var(--white);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
img {
  -webkit-user-drag: none;
}

/* ── 3D room: camera sits in the middle of a cylinder ───────── */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(ellipse 120% 80% at 50% 40%, #ffffff 0%, var(--white) 55%, #f3f1ec 100%);
}
#stage.dragging {
  cursor: grabbing;
}
#ring {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
.area {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  pointer-events: none;
}

.frame {
  position: absolute;
  transform-style: preserve-3d;
}

/* ── a cloud = one photo dissolving into the white ──────────────
   the mask never grows past 100% of the image, otherwise the
   photo's hard rectangle edges would show. zooming uses scale. */
/* in the 3D room the stage does its own hit-testing (see hitShot),
   browsers' 3D hit-testing is unreliable, especially Safari's */
.cloud,
#stage.can-enter {
  cursor: pointer;
}
/* only opacity and scale are ever animated here: animating the mask or
   a filter forces a repaint of every masked photo on every frame while
   it moves in 3D, which flickers. the mask and the grey are static. */
.shot img,
.cloud img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-mask-image: var(--mask, url(/assets/masks/blob.png));
  mask-image: var(--mask, url(/assets/masks/blob.png));
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 88% 88%;
  mask-size: 88% 88%;
}
.shot {
  position: absolute;
  will-change: transform, opacity;
  /* undeveloped: a small pale ghost on the paper */
  opacity: 0.55;
  scale: 0.93;
  transition:
    scale 1.4s var(--ease),
    opacity 1.4s var(--ease);
}
/* the grey copy on top fades away to "develop" the photo */
.shot .mono {
  position: absolute;
  inset: 0;
  height: 100%;
  filter: grayscale(1) contrast(0.55) brightness(1.35);
  transition: opacity 1.8s var(--ease);
}
.area.active .shot {
  opacity: 1;
  scale: 1;
  transition-delay: 0.1s;
}
.area.active .shot .mono {
  opacity: 0;
  transition-delay: 0.15s;
}
.area.active .shot.hover,
.cloud:hover {
  scale: 1.035;
  transition-delay: 0s;
}
/* walking into a cloud: fly through it, the soft edges stay soft */
.area.entering .shot.hero,
.cloud.entering {
  scale: 2.6;
}
.area.entering .shot:not(.hero),
#sub.leaving .cloud:not(.entering),
#sub.leaving .cloud figcaption {
  opacity: 0;
}

.caption {
  position: absolute;
  transform: translateZ(40px);
  transition: opacity 0.5s;
}
.k {
  font: 400 10px var(--mono);
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.caption h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(44px, 6.5vw, 96px);
  line-height: 0.9;
  letter-spacing: -0.025em;
  margin: 6px 0 10px;
  opacity: 0.25;
  transition: opacity 1.2s var(--ease);
}
.area.active .caption h2 {
  opacity: 1;
}
.area.entering .caption {
  opacity: 0;
}
/* a quiet hint that the section opens; lights up while anything in it is hovered */
.caption .open {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font: 500 10px var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transition:
    opacity 1.2s var(--ease),
    color 0.4s;
}
.caption .open i {
  width: 22px;
  height: 1px;
  background: currentColor;
  transition: width 0.5s var(--ease);
}
.area.active .caption .open {
  opacity: 1;
  transition-delay: 0.3s, 0s;
}
#stage.can-enter .area.active .caption .open {
  color: var(--ink);
}
#stage.can-enter .area.active .caption .open i {
  width: 40px;
}

/* ── second layer: one flat screen of clouds ────────────────── */
#sub {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--white);
  overflow-y: auto;
  display: none;
}
/* still scrollable, just without a visible scrollbar */
#sub,
#sheet {
  scrollbar-width: none;
}
#sub::-webkit-scrollbar,
#sheet::-webkit-scrollbar {
  display: none;
}
#sub.open {
  display: block;
}
#sub-head {
  padding: 84px 24px 0 9vw;
}
#sub-head h2 {
  font: 400 clamp(52px, 8vw, 120px) / 0.9 var(--serif);
  letter-spacing: -0.03em;
  margin-top: 8px;
}
/* the overview arrives as one piece: built in its final state under
   the white veil, then the whole group fades and settles together */
#clouds {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  align-items: start;
  padding: 2vh 10vw 110px;
  opacity: 0;
  translate: 0 18px;
  transition:
    opacity 0.9s var(--ease),
    translate 1.2s var(--ease);
}
@media (min-width: 701px) {
  #clouds.one-row {
    padding-bottom: 0;
  }
}
#sub.developed #clouds {
  opacity: 1;
  translate: 0 0;
}
/* each cloud is wider than its cell, so neighbours overlap and their
   soft edges melt into each other */
.cloud {
  position: relative;
  justify-self: center;
  /* as wide as its cell allows, but never so tall it runs off screen (--fit-h, see fitClouds) */
  width: min(calc(130% * var(--pw, 1)), 620px, calc(var(--fit-h, 9999px) * var(--ar, 1.5)));
  transition:
    scale 1.1s var(--ease),
    opacity 0.9s var(--ease);
}
.cloud:nth-child(even) {
  margin-top: 7vh;
}
.cloud:hover {
  z-index: 1;
}
.cloud figcaption {
  position: relative;
  margin: -6% 0 0 14%;
  transition: opacity 0.5s var(--ease);
}
.cloud figcaption b {
  display: block;
  font: 400 clamp(26px, 2.6vw, 38px) / 1 var(--serif);
  letter-spacing: -0.01em;
}
.cloud figcaption span {
  font: 400 10px var(--mono);
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cloud:hover figcaption b {
  font-style: italic;
}

/* ── chrome: header, arrows, dots ───────────────────────────── */
#hdr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* only holds the Overview / Back button */
  display: flex;
  justify-content: flex-end;
  padding: 20px 24px;
  z-index: 35;
  pointer-events: none;
  font: 500 11px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#hdr > * {
  pointer-events: auto;
}
#back {
  all: unset;
  cursor: pointer;
  font: 500 11px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: none;
  /* all: unset makes pointer-events inherit "none" from #hdr */
  pointer-events: auto;
}
#back:hover {
  color: var(--accent);
}
body.deep #back {
  display: inline;
}
.nav {
  position: fixed;
  top: 50%;
  z-index: 10;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 16px;
  font: 500 9px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s;
}
.nav:hover {
  color: var(--ink);
}
.nav .c {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--ink);
  transition:
    transform 0.4s var(--ease),
    border-color 0.3s;
}
.nav:hover .c {
  border-color: var(--ink);
}
#prev {
  left: 4px;
}
#prev:hover .c {
  transform: translateX(-4px);
}
#next {
  right: 4px;
}
#next:hover .c {
  transform: translateX(4px);
}
#dots {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
}
#dots button {
  all: unset;
  cursor: pointer;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
  transition:
    background 0.3s,
    transform 0.3s;
}
#dots button.on {
  background: var(--ink);
  transform: scale(1.4);
}
#grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
#veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--white);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
#veil.on {
  opacity: 1;
  pointer-events: auto;
}

/* ── photo page: the scrollable album ───────────────────────── */
#sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--white);
  overflow-y: auto;
  display: none;
}
#sheet.open {
  display: block;
}
#sheet-head {
  padding: 84px 28px 28px 9vw;
}
#sheet-head h2 {
  font: 400 clamp(44px, 6vw, 88px) / 0.95 var(--serif);
  letter-spacing: -0.025em;
  margin-top: 8px;
}
#sheet-body {
  padding: 12px 28px 120px;
}
.feed {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 56px;
}
/* each block is nudged sideways by --shift (scaled down on mobile) */
.blk {
  --s: calc(var(--shift, 0px) * var(--shift-k, 1));
  width: calc(100% - max(0px, var(--s)) - max(0px, -1 * var(--s)));
  margin-left: max(0px, var(--s));
  gap: 14px;
}
.blk.duo-offset,
.blk.duo-even,
.blk.trio {
  display: grid;
  align-items: center;
}
.blk.duo-offset {
  grid-template-columns: 3fr 2fr;
}
.blk.duo-even {
  grid-template-columns: 1fr 1fr;
}
.blk.trio {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.blk.solo-left,
.blk.solo-right {
  display: flex;
}
.blk.solo-right {
  justify-content: flex-end;
}
.blk.solo-left figure,
.blk.solo-right figure {
  width: 56%;
}
.feed figure {
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity 0.9s,
    transform 0.9s var(--ease);
}
.feed figure.in {
  opacity: 1;
  transform: none;
}
.feed img {
  display: block;
  width: 100%;
  cursor: zoom-in;
}
#zoom {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(253, 252, 250, 0.97);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#zoom.open {
  display: flex;
}
#zoom img {
  max-width: 92vw;
  max-height: 88vh;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18);
}

/* ── contact: a flat layer that slides and fades with the rotation ── */
#contact {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 12;
  width: min(560px, 80vw);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
#contact.live {
  pointer-events: auto;
}
#contact h2 {
  font: 400 clamp(44px, 6.5vw, 96px) / 0.9 var(--serif);
  letter-spacing: -0.025em;
  margin-bottom: 36px;
}
#contact .field {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 10px;
}
#contact .field {
  color: var(--ink);
  text-decoration: none;
  align-items: center;
}
#contact .field span:first-child {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font: 400 17px/1.5 "Inter", system-ui, sans-serif;
  padding: 8px 0;
}
/* deliberately unlike the round → room arrows: a solid pill that opens mail */
#contact .write {
  flex: none;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font: 500 11px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 0.3s;
}
#contact .field:hover .write {
  background: var(--accent);
}
#contact .ig {
  display: inline-block;
  margin-top: 22px;
  font: 500 11px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
#contact .ig:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 700px) {
  /* end just above the mid-height arrows, whatever the screen height */
  #contact {
    top: auto;
    bottom: calc(50% + 34px);
    --ty: 0;
  }
  /* address on its own line (no mid-word breaks), the pill below it */
  #contact .field {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  #contact .field span:first-child {
    overflow-wrap: normal;
    font-size: 16px;
    padding: 0;
  }
  .nav span:not(.c) {
    display: none;
  }
  #sub-head,
  #sheet-head {
    padding-left: 20px;
  }
  #clouds {
    grid-template-columns: 1fr;
    padding-inline: 6vw;
  }
  .cloud {
    width: calc(100% * var(--pw, 1));
  }
  .cloud:nth-child(even) {
    margin-top: -4vh;
  }
  /* more than two albums: two per row, the right column a little lower */
  #clouds.pairs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-inline: 4vw;
  }
  #clouds.pairs .cloud {
    width: calc(118% * var(--pw, 1));
  }
  #clouds.pairs .cloud:nth-child(even) {
    margin-top: 8vh;
  }
  #clouds.pairs .cloud figcaption b {
    font-size: 22px;
  }
  #clouds.pairs .cloud figcaption span {
    font-size: 9px;
  }
  .feed {
    gap: 32px;
  }
  .blk {
    --shift-k: 0.25;
    gap: 10px;
  }
  .blk.solo-left figure,
  .blk.solo-right figure {
    width: 60%;
  }
  #sheet-body {
    padding-left: 16px;
    padding-right: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .shot img,
  .cloud img,
  .shot,
  .cloud,
  .caption * {
    transition-duration: 0.01s !important;
  }
}
