/* ---------- 3D Gallery: 9 framed photos on a ring around the viewer ---------- */
.gallery {
  position: fixed;
  inset: 0;
  z-index: 70;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 42%, #fdfcf9 0%, #f0eee8 55%, #dedbd2 100%);
  color: #0a0a0a;
  font-family: var(--font);
  opacity: 0;
  transition: opacity 280ms ease;
}
.gallery[hidden] { display: none; }
.gallery.is-visible { opacity: 1; }
body.g-open { overflow: hidden; }

.g-viewport {
  position: absolute;
  inset: 0;
  perspective: 800px;               /* set from JS to fit the screen */
  perspective-origin: 50% 50%;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.g-viewport.is-dragging { cursor: grabbing; }

.g-camera {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.g-frame {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--fw, 300px);
  height: var(--fh, 375px);
  margin-left: calc(var(--fw, 300px) / -2);
  margin-top: calc(var(--fh, 375px) / -2);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-tap-highlight-color: transparent;
}
.g-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  transition: transform 220ms ease;
}
.g-frame:hover img { transform: scale(1.03); }
.g-frame::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -9%;
  height: 7%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(60, 45, 20, 0.28) 0%, rgba(60, 45, 20, 0) 70%);
  pointer-events: none;
}
.g-frame:focus-visible { outline: 3px solid #0a0a0a; outline-offset: 6px; }

/* soft floor so the room has a ground */
.g-floor {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--floor, 2400px);
  height: var(--floor, 2400px);
  margin-left: calc(var(--floor, 2400px) / -2);
  margin-top: calc(var(--floor, 2400px) / -2);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.9) 0%, rgba(226, 222, 212, 0.95) 45%, rgba(214, 209, 197, 0) 70%);
  pointer-events: none;
}

/* top bar */
.g-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 0 20px;
  pointer-events: none;
}
.g-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-weight: 900;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.g-title small {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: #3a3a3a;
}
.g-close, .g-pop-close {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #0a0a0a;
  color: #fff;
  cursor: pointer;
  transition: transform 160ms ease;
}
.g-close:hover, .g-pop-close:hover { transform: scale(1.06); }
.g-close:focus-visible, .g-pop-close:focus-visible { outline: 3px solid #0a0a0a; outline-offset: 3px; }

/* bottom controls */
.g-controls {
  position: absolute;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}
.g-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #0a0a0a;
  cursor: pointer;
  transition: background 140ms ease;
}
.g-btn:hover { background: rgba(0, 0, 0, 0.07); }
.g-btn:focus-visible { outline: 3px solid #0a0a0a; outline-offset: 1px; }
.g-sep { width: 1px; height: 24px; background: rgba(0, 0, 0, 0.14); }
.g-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  z-index: 2;
  margin: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #3a3a3a;
  pointer-events: none;
  transition: opacity 600ms ease;
}
.g-hint.is-faded { opacity: 0; }
.gallery.has-pop .g-controls, .gallery.has-pop .g-hint, .gallery.has-pop .g-bar { visibility: hidden; }

/* ---------- Pop-up (closer look) ---------- */
.g-pop {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(76px + env(safe-area-inset-top, 0px)) 72px calc(64px + env(safe-area-inset-bottom, 0px));
  background: rgba(10, 10, 10, 0.84);
  opacity: 0;
  transition: opacity 220ms ease;
}
.g-pop[hidden] { display: none; }
.g-pop.is-visible { opacity: 1; }
.g-pop-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform: scale(0.94);
  transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 30px 40px rgba(0, 0, 0, 0.5));
}
.g-pop.is-visible .g-pop-img { transform: none; }
.g-pop-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: 16px;
  background: #fff;
  color: #0a0a0a;
}
.g-pop-close:focus-visible { outline-color: #fff; }
.g-pop-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #0a0a0a;
  cursor: pointer;
}
.g-pop-nav:hover { background: #fff; }
.g-pop-nav:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.g-pop-prev { left: 12px; }
.g-pop-next { right: 12px; }
.g-pop-count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  margin: 0;
  text-align: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.22em;
}

@media (max-width: 640px) {
  .g-pop { padding-left: 12px; padding-right: 12px; padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .g-pop-nav { top: auto; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: none; width: 48px; height: 48px; }
  .g-pop-prev { left: 16px; }
  .g-pop-next { right: 16px; }
  .g-pop-count { bottom: calc(30px + env(safe-area-inset-bottom, 0px)); }
  .g-title small { display: none; }
  .g-hint .g-hint-long { display: none; }
}

@media (min-width: 641px) { .g-hint .g-hint-short { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .gallery, .g-pop, .g-pop-img, .g-frame img, .g-hint { transition: none; }
}
