:root {
  --min-scale-target: 0.2;
}

/**
 * Main container
 */
.circles-wrapper {
	position: relative;
	width: 100vw;
  max-width: 100%;
	height: 80vh;
	background-color: #FFF;
	overflow: visible;
}

/**
 * Circle Animator: Handles Position and the "Pop-In" Animation
 */
.circle-animator {
	position: absolute;
	left: var(--x);
	top: var(--y);
	width: 0;
	height: 0;
	z-index: var(--z-index);
	
	/* Entry Animation for the entire group */
	opacity: 0;
	transform: scale(0);
	animation: circle-pop-in 0.8s ease-out forwards;
	animation-delay: var(--delay);
}

@keyframes circle-pop-in {
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/**
 * Elevate z-index using :has() when the child is hovered
 */
.circle-animator:has(.circle-item:hover) {
	z-index: 999999;
}

/**
 * Circle Item: Handles scaling (Z-depth) and the Zoom-Effect
 */
.circle-item {
	--final-scale: var(--base-scale, 1);
	position: absolute;
	display: block;
	width: var(--size);
	height: var(--size);
	/* Centering the circle on the animator's point */
	left: 0;
	top: 0;
	transform: translate(-50%, -50%) scale(var(--final-scale));
	
	text-decoration: none;
	border-radius: 50%;
  opacity: 1;
	
	/* Round clip-path for precise mouse interaction */
	clip-path: circle(50% at 50% 50%);
	
	/* Transition only for hover effects, not for entry animation */
	transition: transform 0.4s ease-out;

	/* bugfix for safari touch */
	touch-action: manipulation;
}

/**
 * Hover zoom
 */
.circle-item:hover,
.is-active .circle-item {
	transform: translate(-50%, -50%) scale(calc(var(--final-scale) * var(--zoom)));
}

.circle-content {
	position: relative;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	box-sizing: border-box;
	border: 0.625vw solid var(--border-color);
	overflow: hidden;
}

.circle-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: grayscale(100%);
	transition: filter 0.5s ease-out;
}

.is-active .circle-item .circle-image {
	filter: grayscale(0%);
}
/**
 * Circle Text: Zoom-in from center
 */
.circle-text {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	color: white;
	font-family: sans-serif;
	font-weight: bold;
	text-align: center;
	font-size: clamp(1rem, 2.5vw, 4rem);
	text-shadow: 1px 1px 4px rgba(0,0,0,0.8);
	pointer-events: none;
	width: 85%;
	
	opacity: 0;
	transform: translate(-50%, -50%) scale(0);
	transition: opacity 0.4s ease-out, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@media (hover: hover) and (pointer: fine) {
	/* set media query only for desktop, so that it does not interfere with mobile devices */
	.circle-item:hover .circle-image {
		filter: grayscale(0%);
	}
	.circle-item:hover .circle-text {
		opacity: 1;
		transform: translate(-50%, -50%) scale(1);
	}
}

.circle-button {
  display: none;
}

@media (pointer: coarse) {
  .circle-button {
    display: block;
		margin-top: .5em;
  }
  .circle-button button {
    padding: .1em .4em;
		font-size: 12px;
		text-shadow: none;
		border-radius: .4em;
  }
}


@media screen and ( orientation: portrait ) {
  
  .circles-wrapper {
    height: 80vh;
  }
  
  .circle-animator {
    top: var(--x);
    left: var(--y);
  }
}


@media screen and ( max-width: 767px ) {
  :root {
    --scaled-value: calc(
      var(--base-scale) * (1 - var(--min-scale-target)) + var(--min-scale-target)
    );

    --final-scale: calc(var(--base-scale) * (1 - var(--min-scale-target)) + var(--min-scale-target));
  }
  .circle-item {
		--final-scale: calc(var(--base-scale) * (1 - var(--min-scale-target)) + var(--min-scale-target));
    width: calc( var(--size) * 1.8 );
    height: calc( var(--size) * 1.8 );
  }
  .circle-content {
    border-width: 1vw;
  }
}

/* center circles on mobile devices */
@media (max-width: 767px) and (pointer: coarse) {

  .circle-animator.is-active {
    position: fixed !important;
    left: 50vw !important;
    top: 50vh !important;
    z-index: 9999999 !important;
    opacity: 1;
    transition: all 0.4s ease-in;
  }

  .circle-animator.is-active .circle-item {
    width: 75vw !important;
    height: 75vw !important;

    --final-scale: 1 !important;

    transform: translate(-50%, -50%) scale(1) !important;
  }

	.circle-animator.is-active .circle-item .circle-text {
		opacity: 1;
		transform: translate(-50%, -50%) scale(1);
	}

}