*,
*:before,
*:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Mobile entrance animations */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-40px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(60px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-60px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.distorted-gallery__description {
  margin-top: 40px;
  text-align: center;
  font-family: 'Merriweather', serif;
  font-size: 1.5rem;
  font-weight: bold;
  background: white;
  color: #333;
  padding: 10px 20px;
  border-radius: 50px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  min-height: 2em;
  opacity: 1;
  transition: opacity 0.3s ease;
  width: fit-content;
  max-width: 90%;
  display: none;
  margin-left: auto;
  margin-right: auto;
  text-transform: uppercase;
  letter-spacing: 1px;
  z-index: 150;
  position: relative;
}

@media (max-width: 768px) {
  .distorted-gallery__description {
    font-size: 1rem;
    margin-top: 20px;
    margin-bottom: 20px;
    padding: 8px 16px;
  }
}

.distorted-gallery {
  --transition-time: 800;

  overflow: visible;
  position: relative;
  height: auto;
  min-height: 500px;
  perspective: 1200px;
  transform-style: preserve-3d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.distorted-gallery__images {
  position: relative;
  width: 100%;
  height: 500px;
  max-width: 1200px;
}

.distorted-gallery__image {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 500px;
  height: 500px;
  margin-left: -250px;
  margin-top: -250px;
  object-fit: cover;
  object-position: 50% 50%;
  opacity: 0;
  transition-timing-function: ease-in-out;
  will-change: transform, opacity;
  border-radius: 20px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(0, 180, 166, 0.2);
  border: 3px solid transparent;
  background-origin: border-box;
  background-clip: padding-box, border-box;
  background-image: linear-gradient(white, white), linear-gradient(135deg, #00b4a6, #f4b3ce, #f52a09);
}

.distorted-gallery__image.s--left {
  transform-origin: 0 50%;
  transform: rotateX(5deg) rotateY(-30deg) translateX(-350px) translateZ(-60px) scale(0.8);
  opacity: 0.6;
}

.distorted-gallery__image.s--right {
  transform-origin: 100% 50%;
  transform: rotateX(-5deg) rotateY(30deg) translateX(350px) translateZ(-60px) scale(0.8);
  opacity: 0.6;
}

.distorted-gallery__image.s--prev {
  opacity: 0;
  transition: all calc(var(--transition-time) * 1ms * 0.6);
}

.distorted-gallery__image.s--prev-left {
  transform-origin: 0 100%;
  transform: rotateZ(-12deg) translateX(-150px) translateY(80px) scale(0.5);
}

.distorted-gallery__image.s--prev-right {
  transform-origin: 100% 100%;
  transform: rotateZ(12deg) translateX(150px) translateY(80px) scale(0.5);
}

.distorted-gallery__image.s--active {
  opacity: 1;
  transform: rotateX(0) rotateY(0) translateX(0) translateY(0) translateZ(0) scale(1);
  transition: transform calc(var(--transition-time) * 1ms * 0.8) calc(var(--transition-time) * 1ms * 0.2) cubic-bezier(.34, 1.56, .64, 1),
    opacity calc(var(--transition-time) * 1ms * 0.5) calc(var(--transition-time) * 1ms * 0.15) ease-out;
  z-index: 10;
}

.distorted-gallery.s--no-transition .distorted-gallery__image {
  transition: all 0s 0s !important;
}

.distorted-gallery__control {
  z-index: 100;
  position: absolute;
  left: 20px;
  top: 50%;
  width: 60px;
  height: 60px;
  margin-top: -30px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 180, 166, 0.95), rgba(26, 95, 58, 0.95));
  cursor: pointer;
  transition: all 0.3s cubic-bezier(.34, 1.56, .64, 1);
  box-shadow: 0 6px 25px rgba(0, 180, 166, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.9);
}

.distorted-gallery__control:hover {
  background: linear-gradient(135deg, rgba(0, 180, 166, 1), rgba(26, 95, 58, 1));
  transform: scale(1.25);
  box-shadow: 0 10px 35px rgba(0, 180, 166, 0.6), 0 0 20px rgba(0, 180, 166, 0.4);
}

.distorted-gallery__control:active {
  transform: scale(0.9);
}

.distorted-gallery__control:before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-bottom: none;
  border-right: none;
  transform: translateX(3px) rotate(-45deg);
}

.distorted-gallery__control--right {
  left: auto;
  right: 20px;
}

.distorted-gallery__control--right:before {
  transform: translateX(-3px) rotate(135deg);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .distorted-gallery__image {
    width: 400px;
    height: 400px;
    margin-left: -200px;
    margin-top: -200px;
  }

  .distorted-gallery {
    min-height: 420px;
  }

  .distorted-gallery__images {
    height: 400px;
  }

  .distorted-gallery__image.s--left {
    transform: rotateX(5deg) rotateY(-30deg) translateX(-280px) translateZ(-60px) scale(0.8);
  }

  .distorted-gallery__image.s--right {
    transform: rotateX(-5deg) rotateY(30deg) translateX(280px) translateZ(-60px) scale(0.8);
  }
}

/* Mobile mode - enhanced for better UX */
@media (max-width: 768px) {
  .distorted-gallery {
    min-height: auto;
    height: auto;
    padding: 20px 0 10px;
    flex-direction: column;
    gap: 15px;
  }

  .distorted-gallery__image {
    width: 85%;
    max-width: 85%;
    height: auto;
    aspect-ratio: 1;
    margin-left: -42.5%;
    margin-top: -42.5%;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(0, 180, 166, 0.15);
    animation: zoomIn 600ms ease-out;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .distorted-gallery__images {
    height: auto;
    min-height: 320px;
    width: 100%;
    padding: 0 15px;
  }

  .distorted-gallery__image.s--left {
    display: none;
  }

  .distorted-gallery__image.s--right {
    display: none;
  }

  .distorted-gallery__image.s--prev,
  .distorted-gallery__image.s--prev-left,
  .distorted-gallery__image.s--prev-right {
    display: none;
  }

  .distorted-gallery__control {
    display: flex;
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    margin: 0;
    width: 56px;
    height: 56px;
    animation: slideInUp 500ms ease-out 100ms both;
    box-shadow: 0 8px 30px rgba(0, 180, 166, 0.5);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .distorted-gallery__control:active {
    transform: scale(0.92);
    box-shadow: 0 4px 15px rgba(0, 180, 166, 0.4);
  }

  .distorted-gallery__controls-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 0 20px;
    width: 100%;
    margin-top: 5px;
  }

  .distorted-gallery__control--right {
    left: auto;
    right: auto;
    animation: slideInUp 500ms ease-out 200ms both;
  }

  .distorted-gallery__dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    width: 100%;
    animation: slideInUp 500ms ease-out 300ms both;
    margin-top: 5px;
  }

  .distorted-gallery__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(0, 180, 166, 0.3);
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .distorted-gallery__dot.s--active {
    background: linear-gradient(135deg, #00b4a6, #008c7a);
    transform: scale(1.4);
    box-shadow: 0 0 16px rgba(0, 180, 166, 0.6), 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
  }

  .distorted-gallery__dot:active {
    transform: scale(1.2);
    background: rgba(0, 180, 166, 0.7);
  }

  .distorted-gallery__image.s--active {
    opacity: 1;
    transform: rotateX(0) rotateY(0) translateX(0) translateY(0) translateZ(0) scale(1);
    transition: transform calc(var(--transition-time) * 1ms * 0.8) calc(var(--transition-time) * 1ms * 0.2) cubic-bezier(.34, 1.56, .64, 1),
      opacity calc(var(--transition-time) * 1ms * 0.5) calc(var(--transition-time) * 1ms * 0.15) ease-out;
  }

  /* Swipe hint indicator */
  .distorted-gallery__controls-wrapper::before {
    content: '← Swipe →';
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(0, 180, 166, 0.5);
    animation: fadeInOut 4s infinite;
    pointer-events: none;
  }

  @keyframes fadeInOut {

    0%,
    100% {
      opacity: 0.2;
    }

    50% {
      opacity: 0.6;
    }
  }
}

@media (max-width: 480px) {
  .distorted-gallery {
    padding: 15px 0 10px;
  }

  .distorted-gallery__image {
    width: 90%;
    margin-left: -45%;
    margin-top: -45%;
    animation: zoomIn 600ms ease-out;
    border-radius: 18px;
  }

  .distorted-gallery__images {
    min-height: 280px;
  }

  .distorted-gallery__control {
    width: 52px;
    height: 52px;
    animation: slideInUp 500ms ease-out 100ms both;
  }

  .distorted-gallery__control:before {
    width: 16px;
    height: 16px;
    border-width: 2.5px;
  }

  .distorted-gallery__controls-wrapper {
    gap: 25px;
    padding: 0 15px;
  }

  .distorted-gallery__control--right {
    animation: slideInUp 500ms ease-out 200ms both;
  }

  .distorted-gallery__dots {
    gap: 8px;
    padding: 12px 15px;
    animation: slideInUp 500ms ease-out 300ms both;
  }

  .distorted-gallery__dot {
    width: 11px;
    height: 11px;
  }

  .distorted-gallery__dot.s--active {
    transform: scale(1.35);
  }

  .distorted-gallery__controls-wrapper::before {
    font-size: 0.8rem;
    top: -32px;
  }
}