/* ==========================================================================
   INSTRUCTION CAROUSEL STYLES (AAA MOBILE GAME STYLE - RESPONSIVE & ACCESSIBLE)
   ========================================================================== */

:root {
  --carousel-bg: #1A1C2C;
  --carousel-text-primary: #FFFFFF;
  --carousel-text-secondary: #E2E8F0;
  --carousel-btn-border: rgba(255, 255, 255, 0.3);
  --carousel-btn-hover: rgba(255, 255, 255, 0.1);
  --carousel-dot-inactive: rgba(255, 255, 255, 0.3);
  --carousel-shadow-glow: rgba(255, 255, 255, 0.1);
}

/* Force rulesOverlay to be a full-screen, high-z-index view */
#rulesOverlay.avatar-overlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  padding: 0 !important;
  margin: 0 !important;
  background: var(--carousel-bg) !important;
  z-index: 9999 !important;
  display: none;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden !important;
  box-sizing: border-box !important;
}

#rulesOverlay.avatar-overlay.open {
  display: block !important;
  opacity: 1 !important;
}

/* Base Carousel Container */
.instruction-carousel {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: clamp(1rem, 3vh, 2rem) clamp(1rem, 4vw, 2.5rem);
  background: radial-gradient(circle at center, rgba(119, 90, 255, 0.08) 0%, transparent 80%), var(--carousel-bg);
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--carousel-text-primary);
  user-select: none;
  overflow: hidden;
}

/* Close button - Top Corner */
.carousel-close-btn {
  position: absolute;
  top: clamp(0.75rem, 2vh, 1.5rem);
  left: clamp(0.75rem, 2vw, 1.5rem);
  background: transparent;
  border: none;
  color: var(--carousel-text-secondary);
  font-size: clamp(2rem, 4vh, 2.5rem);
  cursor: pointer;
  z-index: 10;
  width: clamp(40px, 6vh, 48px);
  height: clamp(40px, 6vh, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  line-height: 1;
}

.carousel-close-btn:hover,
.carousel-close-btn:focus {
  color: var(--carousel-text-primary);
  background: var(--carousel-btn-hover);
  transform: rotate(90deg);
  outline: none;
}

/* Horizontal Slides Wrapper */
.carousel-slides-wrapper {
  flex-grow: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-top: clamp(2.5rem, 6vh, 4rem);
  margin-bottom: clamp(1rem, 2.5vh, 2rem);
}

/* Slides track - moves horizontally */
.carousel-slides-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* Individual Slide */
.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 clamp(0.5rem, 2vw, 1.5rem);
  box-sizing: border-box;
  overflow: hidden;
}

/* Slide elements layout spacing */
.carousel-slide-title {
  font-size: clamp(1.6rem, 3.5vh, 2.5rem);
  font-weight: 800;
  margin: 0 0 clamp(0.75rem, 2vh, 1.5rem) 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: carousel-fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 90%;
}

.carousel-slide-icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(100px, 18vh, 160px);
  height: clamp(100px, 18vh, 160px);
  margin-bottom: clamp(1rem, 2.5vh, 2.25rem);
  position: relative;
  flex-shrink: 0;
}

.carousel-slide-icon-container::before {
  content: '';
  position: absolute;
  width: 80%;
  height: 80%;
  background: var(--accent-color, var(--msf-purple));
  opacity: 0.15;
  border-radius: 50%;
  filter: blur(20px);
  animation: carousel-pulse 3s infinite alternate;
}

.carousel-slide-icon {
  font-size: clamp(4.5rem, 12vh, 6.25rem);
  display: inline-block;
  line-height: 1;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
  transform: translateZ(0);
  animation: carousel-float 4s ease-in-out infinite, carousel-scale-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.carousel-slide-text {
  font-size: clamp(1.05rem, 2.2vh, 1.35rem);
  font-weight: 500;
  line-height: 1.5;
  color: var(--carousel-text-secondary);
  max-width: 650px;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  animation: carousel-fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  /* Prevent text clipping while preserving max-height and allowing wrap */
  display: block;
  overflow: hidden;
}

/* Dots and Action Area */
.carousel-footer {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 2.5vh, 1.75rem);
  margin-top: auto;
  flex-shrink: 0;
}

/* Dot Navigation indicator */
.carousel-dots {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}

.carousel-dot {
  width: clamp(10px, 1.5vh, 13px);
  height: clamp(10px, 1.5vh, 13px);
  border: none;
  padding: 0;
  border-radius: 50%;
  background-color: var(--carousel-dot-inactive);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.carousel-dot.active {
  background-color: var(--accent-color, var(--msf-purple));
  transform: scale(1.3);
  box-shadow: 0 0 10px var(--accent-color, var(--msf-purple));
}

/* Navigation Buttons Container */
.carousel-nav-buttons {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  min-height: clamp(48px, 7vh, 60px);
  position: relative;
}

/* Base button design */
.carousel-btn {
  font-family: inherit;
  font-size: clamp(0.95rem, 2vh, 1.15rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: clamp(0.7rem, 1.5vh, 0.9rem) clamp(1.5rem, 3vw, 2.2rem);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: clamp(110px, 15vw, 140px);
  border: none;
}

/* Secondary Button (Anterior) */
.carousel-btn.btn-prev {
  background: transparent;
  color: var(--carousel-text-secondary);
  border: 2px solid var(--carousel-btn-border);
}

.carousel-btn.btn-prev:hover {
  color: var(--carousel-text-primary);
  border-color: var(--carousel-text-primary);
  background: var(--carousel-btn-hover);
  transform: translateY(-2px);
}

/* Primary Button (Siguiente, ¡Entendido!) */
.carousel-btn.btn-next,
.carousel-btn.btn-finish {
  background: var(--accent-color, var(--msf-purple));
  color: #FFFFFF;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(255, 255, 255, 0.1);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.carousel-btn.btn-next:hover,
.carousel-btn.btn-finish:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4), 0 0 20px var(--accent-color, var(--msf-purple));
  filter: brightness(1.1);
}

.carousel-btn:active {
  transform: translateY(0) scale(1);
}

/* Keep buttons centered in layout if one is hidden */
.carousel-nav-buttons:has(.btn-prev[style*="display: none"]) {
  justify-content: flex-end;
}

/* Animations */
@keyframes carousel-float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
  100% { transform: translateY(0px); }
}

@keyframes carousel-pulse {
  0% { transform: scale(1); opacity: 0.15; }
  100% { transform: scale(1.15); opacity: 0.25; }
}

@keyframes carousel-scale-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes carousel-fade-in-up {
  from {
    transform: translateY(15px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
