/* Book Cards Widget Styles */
.book-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 36px;
  width: 100%;
  max-width: 100%;
  position: relative;
  box-sizing: border-box;
}

.book-card {
  width: 100%;
  max-width: 100%;
  height: 376px;
  position: relative;
  text-align: center;
  display: block;
  text-decoration: none;
  color: inherit;
  margin: 0;
  box-sizing: border-box;
  transition: transform 0.3s ease;
}

.book-card:hover {
  transform: translateY(-5px);
}

.book-cover {
  background: white 0% 0% / cover;
  position: absolute;
  z-index: 1;
  width: 100%;
  height: 100%;
  transform-origin: 0 50%;
  transition: 0.5s ease-in-out;
  border-radius: 4px;
  background-size: 100% 100%;
}

.book-content {
  position: absolute;
  inset: 0;
  text-align: left;
}

.book-logo {
  display: flex;
  flex: auto;
  padding: 24px 32px;
}

.book-logo img {
  width: 49px;
  height: 16px;
  object-fit: contain;
  max-width: 100%;
}

.book-number {
  position: absolute;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-size: 16px;
  font-style: italic;
  color: white;
  border-radius: 50%;
  top: 40px;
  right: 24px;
  background-color: rgba(0, 0, 0, 0.6);
}

.book-background {
  position: relative;
  display: flex;
  flex: auto;
  height: 256px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.book-background::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

.book-title {
  position: absolute;
  top: 0;
  padding: 24px 8px 24px 32px;
  font-size: 36px;
  font-weight: 500;
  line-height: 1.25;
  text-transform: uppercase;
  font-family: "Arial Black", Arial, sans-serif;
  color: #000;
  margin: 0;
  z-index: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.book-spine {
  position: relative;
  width: 8px;
  height: 100%;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.05));
}

.book-effect {
  width: 20px;
  margin-left: 8px;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
  position: absolute;
  top: 0;
  height: 100%;
  transition: 0.5s;
}

.book-light {
  width: 90%;
  border-radius: 3px;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.2));
  right: 0;
  opacity: 0.1;
  transition: 0.5s;
  position: absolute;
  top: 0;
  height: 100%;
}

.book-inside {
  width: calc(100% - 2px);
  height: 96%;
  position: relative;
  top: 2%;
  border: 1px solid #d4d4d4;
  border-radius: 3px;
  background: white;
  box-shadow:
    0 20px 25px rgba(74, 74, 139, 0.1),
    0 10px 10px rgba(74, 74, 139, 0.04),
    -2px 0 0 #d4d4d4 inset,
    -3px 0 0 #dbdbdb inset,
    -4px 0 0 white inset,
    -5px 0 0 #dbdbdb inset,
    -6px 0 0 white inset,
    -7px 0 0 #dbdbdb inset,
    -8px 0 0 white inset,
    -9px 0 0 #dbdbdb inset;
}

/* Hover Effects - Perfect from original */
.book-card:hover .book-cover {
  transform: perspective(2000px) rotateY(-30deg);
  transform-style: preserve-3d;
  box-shadow: 10px 0 10px -5px rgba(0, 0, 0, 0.19);
}

/* Responsive Design - Updated to work with flexible widths */
@media (max-width: 1024px) {
  .book-cards-grid {
    gap: 24px;
  }

  .book-card {
    width: 100%;
    margin: 0;
  }
}

@media (max-width: 768px) {
  .book-cards-grid {
    gap: 20px;
  }

  .book-title {
    font-size: 24px;
    padding: 16px 8px 16px 24px;
  }

  .book-number {
    width: 40px;
    height: 40px;
    font-size: 14px;
    top: 32px;
    right: 16px;
  }
}

@media (max-width: 480px) {
  .book-cards-grid {
    gap: 16px;
  }

  .book-card {
    width: 100%;
    height: 320px;
  }

  .book-cover,
  .book-inside {
    height: 320px;
  }

  .book-background {
    height: 200px;
  }

  .book-title {
    font-size: 20px;
    padding: 12px 8px 12px 20px;
  }
}

/* Animation Keyframes */
@keyframes bookHover {
  0% {
    transform: perspective(2000px) rotateY(0deg);
  }
  100% {
    transform: perspective(2000px) rotateY(-30deg);
  }
}

/* Elementor Compatibility - Enhanced for responsive columns */
.elementor-widget-book-cards {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.elementor-widget-book-cards .book-cards-grid {
  margin: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.elementor-widget-book-cards .book-card {
  transition: all 0.3s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Custom styling overrides for better control */
.elementor-widget-book-cards .book-title {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.elementor-widget-book-cards .book-logo img {
  max-width: 100%;
  height: auto;
}

/* Ensure proper stacking context */
.elementor-widget-book-cards .book-card * {
  box-sizing: border-box;
}

/* Force grid items to stay within bounds */
.book-cards-grid > * {
  min-width: 0;
  max-width: 100%;
}

/* Override any fixed widths from Elementor controls when container is too small */
@media (max-width: 1200px) {
  .elementor-widget-book-cards .book-card {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Better mobile responsiveness */
@media (max-width: 767px) {
  .elementor-widget-book-cards .book-card {
    margin: 0 auto;
  }
}

/* Ensure proper scaling for very narrow containers */
@media (max-width: 600px) {
  .elementor-widget-book-cards .book-title {
    font-size: clamp(14px, 4vw, 24px) !important;
    padding: clamp(8px, 2vw, 16px) !important;
  }

  .elementor-widget-book-cards .book-number {
    width: clamp(30px, 8vw, 40px) !important;
    height: clamp(30px, 8vw, 40px) !important;
    font-size: clamp(10px, 3vw, 14px) !important;
  }
}
