.motion-formation {
  position: absolute;
  inset: 0;
  overflow: hidden;
  perspective: 1200px;
  background: transparent;
  touch-action: none;
}

.motion-formation__wave {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.motion-formation__wave.is-background { z-index: 0; }

.motion-formation__mosaic {
  position: absolute;
  inset: 4px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 4px;
  transform-style: preserve-3d;
  visibility: hidden;
}

.motion-formation__mosaic.is-active { visibility: visible; }

.motion-formation__tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  background: rgba(246, 238, 220, 0.5);
  opacity: 0;
  cursor: zoom-in;
  transform-style: preserve-3d;
  will-change: transform, opacity, filter;
}

.motion-formation__tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.015);
  user-select: none;
  pointer-events: none;
}

.motion-formation__detail {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: clamp(48px, 7vw, 90px);
  background: rgba(91, 76, 55, 0.8);
  backdrop-filter: blur(18px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.motion-formation__detail.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.motion-formation__detail img {
  display: block;
  max-width: min(88vw, 1100px);
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 28px 80px rgba(12, 30, 61, 0.35);
}

.motion-formation__close {
  position: absolute;
  top: clamp(18px, 3vw, 32px);
  right: clamp(18px, 3vw, 32px);
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  color: #fff;
  background: rgba(74, 59, 42, 0.38);
  font: 700 11px/1 Inter, sans-serif;
  letter-spacing: 0.12em;
  cursor: pointer;
}

@media (max-width: 700px) {
  .motion-formation__mosaic {
    inset: 3px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: 3px;
  }
  .motion-formation__detail { padding: 54px 14px 20px; }
  .motion-formation__detail img { max-width: 94vw; max-height: 78vh; }
}

@media (prefers-reduced-motion: reduce) {
  .motion-formation__detail { transition: none; }
}
