/* ============================================
   BENTO BOX FLASHCARD FLIP ANIMATIONS
   3D card flip system with smooth horizontal axis rotation
   ============================================ */

/* ============================================
   3D FLIP SYSTEM - CORE ARCHITECTURE
   ============================================ */

/* Perspective Container */
.flip-container {
  width: 100%;
  height: 100%;
  perspective: 1000px;
  position: relative;
}

/* Flip Card (Transform Target) */
.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
  transform: translateZ(0); /* GPU acceleration */
}

/* Flipped State */
.bento-box-flippable.is-flipped .flip-card {
  transform: rotateY(180deg);
}

/* ============================================
   FLIP FACES
   ============================================ */

.flip-face {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;

  /* Center content */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
}

/* Front Face */
.flip-face-front {
  transform: rotateY(0deg);
  z-index: 2;
}

/* Back Face */
.flip-face-back {
  transform: rotateY(180deg);
  z-index: 1;
}

/* ============================================
   TYPOGRAPHY & LOGO STYLING
   ============================================ */

/* Both front and back faces use the same bento-box-text styling */
.flip-face .bento-box-text {
  /* Inherits existing bento-box-text styles from hero-modern.css */
}

/* Logo faces */
.flip-face-logo {
  padding: var(--space-md);
}

/* Logo images - sized to fit container without changing box dimensions */
.bento-logo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Specific logos that need less padding for larger display */
.flip-face-logo img[alt="Blackboard"] {
  max-width: 110%;
  max-height: 110%;
}

.flip-face-logo img[alt="Cengage MindTap"] {
  max-width: 115%;
  max-height: 115%;
}

/* Reduce padding for Blackboard and MindTap containers */
.flip-face-logo:has(img[alt="Blackboard"]) {
  padding: calc(var(--space-xs) * 0.3);
}

.flip-face-logo:has(img[alt="Cengage MindTap"]) {
  padding: calc(var(--space-xs) * 0.2);
}

/* Logo cycling system - hide inactive logos */
.flip-face-logo[data-logo-index]:not(.active-logo) {
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.15s ease-out;
}

/* Show the active logo */
.flip-face-logo.active-logo {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
  transition: opacity 0.15s ease-in;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Only apply will-change during animation */
.bento-box-flippable.is-animating .flip-card {
  will-change: transform;
}

.bento-box-flippable:not(.is-animating) .flip-card {
  will-change: auto;
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .flip-card {
    transition: none;
  }

  /* Instant opacity swap instead of 3D flip */
  .flip-face {
    transition: opacity 0.2s ease;
  }

  .bento-box-flippable:not(.is-flipped) .flip-face-front {
    opacity: 1;
  }

  .bento-box-flippable:not(.is-flipped) .flip-face-back {
    opacity: 0;
  }

  .bento-box-flippable.is-flipped .flip-face-front {
    opacity: 0;
  }

  .bento-box-flippable.is-flipped .flip-face-back {
    opacity: 1;
  }

  /* Remove 3D transforms */
  .flip-face-back {
    transform: none;
  }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Mobile */
@media (max-width: 767px) {
  .flip-container {
    perspective: 800px; /* Slightly less dramatic on mobile */
  }
}
