@import url('https://fonts.cdnfonts.com/css/ica-rubrik-black');
@import url('https://fonts.cdnfonts.com/css/poppins');

/* =========================
   ROOT & DEFAULTS
========================= */
.cy-carousel,
.cy-carousel * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.cy-carousel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #D2D2D2;

  /* GRID CONFIG */
  --grid-rgb: 82 46 112;
  --grid-size: 84px;
  --grid-line: 1px;
  --grid-alpha: 0.55;
}

/* =========================
   CINEMATIC MODAL ANIMATION
========================= */
.cy-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.5s;
}

.cy-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cy-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
}

.cy-modal__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(1100px, 92vw);
  height: min(720px, 88vh);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 3px solid rgba(255, 0, 80, 0.35);
  box-shadow: 0 30px 80px rgba(0,0,0,0.65);
  overflow: hidden;
  z-index: 10;
  transform: translate(-50%, -45%) scale(0.92);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);

  clip-path: polygon(
    22px 0,
    calc(50% - 55px) 0,
    50% 14px,
    calc(50% + 55px) 0,
    calc(100% - 22px) 0,
    100% 22px,
    100% calc(100% - 22px),
    calc(100% - 22px) 100%,
    calc(50% + 55px) 100%,
    50% calc(100% - 14px),
    calc(50% - 55px) 100%,
    22px 100%,
    0 calc(100% - var(--cut)),
    0 22px
  );
}

.cy-modal.is-open .cy-modal__panel {
  transform: translate(-50%, -50%) scale(1);
}

.cy-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 100;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.45);
  color: #fff;
  cursor: pointer;
}

/* =========================
   PROPER CYBER GLITCH REVEAL
========================= */
.cy-carousel .banner {
  opacity: 0;
  position: relative;
  transform-style: preserve-3d;
}

/* The RGB Split Glitch Layers */
.cy-carousel.is-ready .banner {
  opacity: 1;
  animation: mainGlitch 0.4s cubic-bezier(.25, .46, .45, .94) both;
}

/* Glitch layers MUST stay behind actual content */
.cy-carousel.is-ready .banner::before,
.cy-carousel.is-ready .banner::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: inherit;
  visibility: visible;
  opacity: 0.5;
  z-index: 0; /* ✅ behind everything inside banner */
  pointer-events: none;
}

.cy-carousel.is-ready .banner::before {
  animation: rgbRed 0.4s cubic-bezier(.25, .46, .45, .94) both;
  filter: drop-shadow(-2px 0 #ff00c1) hue-rotate(300deg);
}

.cy-carousel.is-ready .banner::after {
  animation: rgbBlue 0.4s cubic-bezier(.25, .46, .45, .94) reverse both;
  filter: drop-shadow(2px 0 #00fff9) hue-rotate(90deg);
}

@keyframes mainGlitch {
  0% { transform: translate(0); }
  20% { transform: translate(-3px, 2px) skewX(2deg); }
  40% { transform: translate(3px, -1px) skewX(-3deg); }
  60% { transform: translate(-1px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

@keyframes rgbRed {
  0% { transform: translate(0); clip-path: inset(10% 0 40% 0); }
  30% { transform: translate(-5px, 2px); clip-path: inset(50% 0 10% 0); }
  70% { transform: translate(5px, -2px); clip-path: inset(20% 0 60% 0); }
  100% { transform: translate(0); opacity: 0; }
}

@keyframes rgbBlue {
  0% { transform: translate(0); clip-path: inset(40% 0 10% 0); }
  30% { transform: translate(5px, -2px); clip-path: inset(10% 0 50% 0); }
  70% { transform: translate(-5px, 2px); clip-path: inset(60% 0 20% 0); }
  100% { transform: translate(0); opacity: 0; }
}

/* =========================
   BACKGROUND & GRID LAYERS
========================= */
.cy-carousel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: top center;
  background-size: 90%;
  pointer-events: none;
  z-index: 1;
}

.cy-carousel::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;

  background-image:
    repeating-linear-gradient(
      to right,
      rgb(var(--grid-rgb) / var(--grid-alpha)) 0 var(--grid-line),
      transparent var(--grid-line) var(--grid-size)
    ),
    repeating-linear-gradient(
      to bottom,
      rgb(var(--grid-rgb) / var(--grid-alpha)) 0 var(--grid-line),
      transparent var(--grid-line) var(--grid-size)
    );

  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 92%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 92%);
}

/* =========================
   LOADING OVERLAY
========================= */
.cy-loader {
  position: absolute;
  inset: 0;
  background: #D2D2D2;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10001;
  transition: opacity 0.6s ease;
}

.cy-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.cy-loader__circle {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(closest-side, #D2D2D2 79%, transparent 80% 100%),
              conic-gradient(#ef4444 0%, #25283b22 0%);
}

.cy-modal.is-open .cy-loader__circle {
  animation: fillCircle 1.8s forwards;
}

@keyframes fillCircle {
  0% { background: radial-gradient(closest-side, #D2D2D2 79%, transparent 80% 100%), conic-gradient(#ef4444 0%, #25283b22 0%); }
  100% { background: radial-gradient(closest-side, #D2D2D2 79%, transparent 80% 100%), conic-gradient(#ef4444 100%, #25283b22 0%); }
}

.cy-loader__text {
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #18181b;
}

/* =========================
   3D SCENE & STACKING ORDER
========================= */
.cy-carousel .banner {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 2000px;
  transform-style: preserve-3d;
  z-index: 3;
}

/* Hand */
.cy-carousel .banner .model {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(900px, 120vw);
  height: 90%;
  transform: translateX(-50%) translateZ(0px);
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
  pointer-events: none;
  z-index: 4;
}

/* Slider */
.cy-carousel .banner .slider {
  position: absolute;
  top: 10%;
  left: 50%;
  width: 240px;
  height: 340px;
  transform-style: preserve-3d;
  transform: translateX(-50%);
  animation: cyAutoRun 22s linear infinite;
  z-index: 10;
}

@keyframes cyAutoRun {
  from { transform: translateX(-50%) rotateX(-12deg) rotateY(0deg) scale(0.8); }
  to { transform: translateX(-50%) rotateX(-12deg) rotateY(360deg) scale(0.8); }
}

.cy-carousel .banner .slider .item {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  backface-visibility: visible;
  transform: rotateY(calc((var(--position) - 1) * (360 / var(--quantity)) * 1deg)) translateZ(480px);
}

.cy-carousel .banner .slider .item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

/* =========================
   CONTENT (UI OVERLAY)
========================= */
.cy-carousel .banner .content {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;

  /* ✅ DO NOT translateZ here (it causes clipping in overflow/perspective contexts) */
  transform: none;

  width: 100%;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;

  /* ✅ force above slider + glitch */
  z-index: 50;

  pointer-events: none;
}

.cy-carousel .banner .content h1 {
  position: relative;
  font-family: 'ICA Rubrik', sans-serif;
  font-size: clamp(3rem, 7vw, 7.5rem);
  line-height: 0.9;
  color: #3bed9a;
  pointer-events: auto;
}

.cy-carousel .banner .content h1 .stroke {
  color: transparent;
  -webkit-text-stroke: 2px #ffffff;
}

.cy-carousel .banner .content h1::after {
  content: attr(data-content);
  position: absolute;
  inset: 0;
  -webkit-text-stroke: 2px #d2d2d2;
  color: transparent;
  z-index: -1;
}

.cy-carousel .banner .content .author {
  font-family: 'Poppins', sans-serif;
  text-align: right;
  max-width: 250px;
  color: #25283b;
  pointer-events: auto;
}

.cy-carousel .banner .content .author h2 {
  font-size: 1.6rem;
  color: #3bed9a;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1023px) {
  .cy-carousel .banner .content {
    bottom: 40px;
    justify-content: center;
  }
  .cy-carousel .banner .content .author {
    display: none;
  }
}
/* Default: pause */
.cy-carousel .banner .slider {
  animation-play-state: paused;
}

/* Only run when modal is open */
#carouselModal.is-open .cy-carousel .banner .slider {
  animation-play-state: running;
}
/* When not open, kill 3D + painting cost */
#carouselModal:not(.is-open) .cy-carousel .banner {
  perspective: none;
  transform-style: flat;
}

#carouselModal:not(.is-open) .cy-carousel .banner .slider,
#carouselModal:not(.is-open) .cy-carousel .banner .slider .item {
  transform: none !important;
}
@media (max-width: 768px) {
  .cy-modal__panel {
    clip-path: none;
    border-radius: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .cy-carousel .banner .slider { animation: none !important; }
  .cy-carousel.is-ready .banner { animation: none !important; }
  .cy-carousel.is-ready .banner::before,
  .cy-carousel.is-ready .banner::after { animation: none !important; }
}