/**
 * Instagram 3D Carousel Component
 * A modern 3D carousel for displaying Instagram feed with perspective effect
 */

/* Container */
.instagram-feed-section {
  padding: 0;
  overflow: visible;
  position: relative;
}

.instagram-feed-section .section-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.instagram-feed-section .section-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-dark);
  margin-bottom: var(--space-md);
  font-family: var(--font-family-heading);
}

.instagram-feed-section .section-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

.instagram-feed-section .instagram-handle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  margin-top: var(--space-md);
  transition: var(--transition-base);
}

.instagram-feed-section .instagram-handle:hover {
  color: var(--color-primary-dark);
  transform: translateY(-2px);
}

.instagram-feed-section .instagram-icon {
  width: 24px;
  height: 24px;
}

/* 3D Carousel Container */
.instagram-carousel-wrapper {
  position: relative;
  width: 100%;
  height: 500px;
  perspective: 1200px;
  perspective-origin: 50% 50%;
  margin: 0;
  padding-bottom: 60px; /* Space for indicators */
}

.instagram-carousel {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Instagram Post Cards */
.instagram-post {
  position: absolute;
  width: 350px;
  height: 450px;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.instagram-post-inner {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: all 0.3s ease;
}

.instagram-post:hover .instagram-post-inner {
  box-shadow: 0 30px 50px -10px rgba(0, 0, 0, 0.2);
  transform: translateZ(10px);
}

/* Post Image */
.instagram-post-image {
  position: relative;
  width: 100%;
  height: 70%;
  overflow: hidden;
  background: var(--color-light-gray);
}

.instagram-post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.instagram-post:hover .instagram-post-image img {
  transform: scale(1.05);
}

/* Video Indicator */
.instagram-post-video-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.instagram-post:hover .instagram-post-video-indicator {
  background: var(--color-primary);
  transform: translate(-50%, -50%) scale(1.1);
}

.instagram-post-video-indicator svg {
  fill: var(--color-dark);
  transition: fill 0.3s ease;
}

.instagram-post:hover .instagram-post-video-indicator svg {
  fill: var(--color-white);
}

/* Post Loading State */
.instagram-post-image.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Post Overlay */
.instagram-post-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.7) 100%);
  display: flex;
  align-items: flex-end;
  padding: var(--space-lg);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.instagram-post:hover .instagram-post-overlay {
  opacity: 1;
}

.instagram-post-stats {
  display: flex;
  gap: var(--space-lg);
  color: var(--color-white);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.instagram-post-stat {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.instagram-post-stat svg {
  width: 18px;
  height: 18px;
}

/* Post Content */
.instagram-post-content {
  padding: var(--space-lg);
  height: 30%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.instagram-post-caption {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.instagram-post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-gray);
}

.instagram-post-date {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.instagram-post-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  transition: var(--transition-fast);
}

.instagram-post-link:hover {
  color: var(--color-primary-dark);
}

/* Carousel Navigation */
.instagram-carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

.instagram-carousel-nav.prev {
  left: 5%;
}

.instagram-carousel-nav.next {
  right: 5%;
}

.instagram-carousel-nav button {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  background: var(--color-white);
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--color-dark);
}

.instagram-carousel-nav button:hover {
  background: var(--color-primary);
  color: var(--color-white);
  transform: scale(1.1);
  box-shadow: var(--shadow-xl);
}

.instagram-carousel-nav button:active {
  transform: scale(0.95);
}

.instagram-carousel-nav svg {
  width: 24px;
  height: 24px;
}

/* Carousel Indicators */
.instagram-carousel-indicators {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  z-index: 5;
}

/* When inside paragraph-section-wrapper with background, position absolutely at bottom */
.paragraph--type--instagram_feed.paragraph-section-wrapper {
  position: relative;
}

.paragraph--type--instagram_feed.paragraph-section-wrapper .instagram-carousel-wrapper {
  position: static;
}

.paragraph--type--instagram_feed.paragraph-section-wrapper .instagram-carousel-indicators {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--space-lg);
  margin-top: 0;
}

.instagram-carousel-indicator {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--color-light-gray);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
}

.instagram-carousel-indicator.active {
  background: var(--color-primary);
  width: 32px;
}

.instagram-carousel-indicator:hover {
  background: var(--color-primary-light);
}

/* Loading State */
.instagram-carousel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 500px;
  font-size: var(--font-size-lg);
  color: var(--color-gray);
}

.instagram-carousel-loading .spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--color-light-gray);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error State */
.instagram-carousel-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 500px;
  text-align: center;
  padding: var(--space-2xl);
}

.instagram-carousel-error-icon {
  width: 80px;
  height: 80px;
  color: var(--color-accent-pink);
  margin-bottom: var(--space-lg);
}

.instagram-carousel-error-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-dark);
  margin-bottom: var(--space-md);
}

.instagram-carousel-error-message {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  max-width: 400px;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .instagram-carousel-wrapper {
    height: 450px;
    perspective: 1000px;
  }

  .instagram-post {
    width: 300px;
    height: 400px;
  }
}

@media (max-width: 768px) {
  .instagram-feed-section {
    padding: 0;
  }

  .instagram-feed-section .section-title {
    font-size: var(--font-size-3xl);
  }

  .instagram-carousel-wrapper {
    height: 400px;
    perspective: 800px;
    padding-bottom: 50px;
  }

  .instagram-post {
    width: 280px;
    height: 380px;
  }

  .instagram-carousel-nav {
    display: none;
  }

  .instagram-carousel-nav.prev {
    left: 2%;
  }

  .instagram-carousel-nav.next {
    right: 2%;
  }

  .instagram-carousel-nav button {
    width: 40px;
    height: 40px;
  }
  
  .paragraph--type--instagram_feed.paragraph-section-wrapper .instagram-carousel-indicators {
    bottom: var(--space-md);
  }
}

@media (max-width: 480px) {
  .instagram-carousel-wrapper {
    height: 350px;
    padding-bottom: 45px;
  }

  .instagram-post {
    width: 260px;
    height: 340px;
  }

  .instagram-post-content {
    padding: var(--space-md);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .instagram-carousel,
  .instagram-post,
  .instagram-post-inner,
  .instagram-post-image img,
  .instagram-carousel-nav button {
    transition: none;
  }

  .instagram-carousel-loading .spinner {
    animation: none;
    border-top-color: var(--color-primary);
  }
}

/* Print Styles */
@media print {
  .instagram-carousel-nav,
  .instagram-carousel-indicators {
    display: none;
  }

  .instagram-carousel-wrapper {
    height: auto;
    perspective: none;
  }

  .instagram-post {
    position: relative;
    display: inline-block;
    page-break-inside: avoid;
  }
}