@property --scale {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

img {
  position: relative;
  z-index: 900;
}

.image-container {
  background: var(--accent-color);
  clip-path: polygon(5% 0, 100% 0, 95% 100%, 0 100%);
  pointer-events: none;
  overflow: visible;
  background-size: cover;
  background-position: center;
  position: relative;
  z-index: 900;
  --tx: 0px;
  --ty: 0px;
  --scale: 0;
  --rx: 0deg;
  --ry: 0deg;
  --rz: 0deg;
  --prz: 0deg;
  --mx: 50%;
  --my: 50%;
  transform-origin: center;
  transform: perspective(800px) translate(var(--tx), var(--ty))
    scaleY(var(--scale)) rotateX(var(--rx)) rotateY(var(--ry)) rotate(var(--rz))
    rotate(var(--prz));
  opacity: 0;
  transition:
    opacity 0.4s ease,
    --scale 0.4s ease;
}

.image-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 4px solid var(--accent-color);
  pointer-events: none;
  clip-path: polygon(5% 0, 100% 0, 95% 100%, 0 100%);
  transform-origin: center;
  animation: frame-tilt 8s ease-in-out infinite;
}

@keyframes frame-tilt {
  0%,
  100% {
    transform: rotate(-1deg);
  }
  50% {
    transform: rotate(1deg);
  }
}

.image-container.show {
  --scale: 1;
  opacity: 1;
}

.image-container.in-text {
  position: relative;
  height: 0;
  margin: 0 auto;
}

.image-container.side {
  position: absolute;
}

.image-container.interactive {
  pointer-events: auto;
  cursor: pointer;
}

.image-details {
  background: var(--bg-color);
  border: 2px solid var(--accent-color);
  color: var(--text-color);
  padding: 4px 8px;
  margin-top: 1em;
}

.image-details-template {
  display: none;
}

.image-container.full {
  position: static;
}

.image-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.image-panel.active {
  display: block;
}

.image-panel.visible {
  opacity: 1;
}

.image-panel .image-container.full,
.image-panel .image-details {
  position: absolute;
}

.image-panel .image-container.full {
  --pscale: 1;
}

.image-panel .image-container.full::before {
  border-width: calc(4px * var(--pscale));
}

.image-panel .image-container.full::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0) 45%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 55%
  );
  background-size: calc(200% * var(--pscale)) calc(200% * var(--pscale));
  background-position: var(--mx) var(--my);
  mix-blend-mode: screen;
}

.image-panel .image-details {
  overflow: hidden;
  --drx: 0deg;
  --dry: 0deg;
  --drz: 0deg;
  --skewX: 0deg;
  --dscale: 1;
  --tx: 0px;
  --ty: 20px;
  opacity: 0;
  transform: perspective(800px) translate(var(--tx), var(--ty))
    rotateX(var(--drx)) rotateY(var(--dry)) skewX(var(--skewX))
    rotate(var(--drz)) scale(var(--dscale));
  padding: 0 2vw;
  transition:
    transform 0.4s ease,
    opacity 0.4s ease;
}

.image-panel.visible .image-details {
  opacity: 1;
  --ty: 0px;
}
