/* ============================================
   Scroll & Dagger - Book Cards & Tab Navigation
   ============================================
   
   This stylesheet handles:
   - Book card grid layout and animations
   - Tab navigation system with backdrop blur effects
   - Staggered fade-in animations for book cards
   ============================================ */

/* ============================================
   Book Card Grid Layout
   ============================================ */

/* Responsive grid container for book cards */
.book-card-grid { 
  display: grid; 
  gap: 16px; 
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); 
}

/* Individual book card styling with staggered animations */
.book-card { 
  padding: 12px 16px; 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.0));
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1), 
              box-shadow 0.5s cubic-bezier(0.25, 1, 0.5, 1),
              border-color 0.3s ease;
  backface-visibility: hidden;
  perspective: 1000px;
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  animation: fadeInOpacity 0.6s ease forwards, slideUpInitial 0.6s ease forwards;
  animation-delay: calc(var(--card-index, 0) * 0.1s), calc(var(--card-index, 0) * 0.1s);
  will-change: transform, opacity;
}

/* Fallback: If CSS variable is not set, still show the card (no delay) */
.book-card:not([style*="--card-index"]) {
  animation-delay: 0s, 0s;
}

/* Fallback: Ensure cards are visible after animation completes, even if JS fails */
@supports (animation: fadeInOpacity) {
  .book-card {
    animation-fill-mode: forwards;
  }
}

/* Fallback for browsers that don't support CSS variables in calc */
@supports not (animation-delay: calc(var(--card-index) * 0.1s)) {
  .book-card {
    animation-delay: 0s, 0s;
  }
}

/* Reset animation for newly shown cards */
.tab-content.active .book-card {
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  animation: fadeInOpacity 0.6s ease forwards, slideUpInitial 0.6s ease forwards;
  animation-delay: calc(var(--card-index, 0) * 0.1s), calc(var(--card-index, 0) * 0.1s);
}

/* Ensure cards in active tab are visible after animation */
.tab-content.active .book-card {
  visibility: visible;
}

/* Separate animations: opacity (with forwards) and transform (without forwards to allow transitions) */
@keyframes fadeInOpacity {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUpInitial {
  from {
    transform: translate3d(0, 20px, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

/* Reduce spacing in book cards */
.book-card h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
  line-height: 1.3;
}

.book-card .meta {
  margin-bottom: 8px;
  font-size: 13px;
}

.book-card p {
  margin: 0;
}

.book-card p.book-cg {
  margin-top: 8px;
}

.book-card a {
  font-size: 14px;
  display: inline-block;
  margin-top: 6px;
  transition: all 0.3s ease;
}

/* Book card content alignment */
.book-cg { 
  align-content: center; 
  align-items: center; 
  align-self: center;
}

/* Hover effect for book cards */
article.book-card:hover {
  transform: translate3d(0, -5px, 0);
  box-shadow: 0 15px 30px rgba(0, 166, 118, 0.25);
  border-color: var(--accent);
}

/* Book thumbnail images - responsive sizing */
.book-thumbnail {
  border-radius: 8px;
  width: 100%;
  height: auto;
  max-width: 100%;
  aspect-ratio: 255 / 285; /* Maintains original 255px × 285px proportions */
  object-fit: contain;
  display: block;
}

/* ============================================
   Tab Navigation System
   ============================================ */

/* Tab container with fade-in animation */
.tab-container {
  animation: fadeIn 0.6s ease-out 0.3s both;
  margin-bottom: 24px;
}

/* Hide tab content by default */
.tab-content {
  display: none;
  opacity: 0;
}

/* Show active tab content */
.tab-content.active {
  display: block;
  animation: fadeInSlide 0.5s ease forwards;
}

/* Tab content fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Tab content fade in with slide animation */
@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tab button base styling with backdrop blur for non-active buttons */
.tab-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.0));
  color: var(--text);
  cursor: pointer;
  margin-right: 8px;
  margin-bottom: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  position: relative;
}

/* Backdrop blur effect for non-active tab buttons */
button.tab-button:not(.active) {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Tab button hover state - only for non-active buttons */
button.tab-button:not(.active):hover {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Active tab button styling - solid gradient background (no blur needed) */
.tab-button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  backdrop-filter: none; /* Remove blur for active button (solid background) */
  -webkit-backdrop-filter: none;
  color: #0b1020;
  font-weight: 700;
  border: none;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 166, 118, 0.3);
  animation: pulseGlow 2s ease-in-out infinite;
}

/* Pulse glow animation for active tab */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 166, 118, 0.3);
  }
  50% {
    box-shadow: 0 4px 16px rgba(0, 166, 118, 0.5);
  }
}
