/* ===== CHAPTERS MODAL STYLES ===== */

/* Modal Container - Full viewport overlay */
.chapters-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chapters-modal.active {
  display: flex;
  opacity: 1;
  visibility: visible;
  align-items: center;
  justify-content: center;
}

/* Overlay - Backdrop with blur effect */
.chapters-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Main Container - Centered card */
.chapters-modal-container {
  position: relative;
  z-index: 2001;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-dark-secondary) 100%);
  border-radius: 8px;
  max-width: 1000px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(184, 115, 51, 0.35);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chapters-modal.active .chapters-modal-container {
  transform: scale(1);
}

/* Header Styles */
.chapters-modal-header {
  position: relative;
  padding: 32px 40px;
  background: linear-gradient(135deg, rgba(184, 115, 51, 0.25), rgba(139, 94, 60, 0.2));
  border-bottom: 1px solid rgba(184, 115, 51, 0.25);
}

.chapters-modal-header h2 {
  color: var(--text-light);
  font-size: 2rem;
  margin: 0 0 8px 0;
  font-weight: 700;
}

.chapters-subtitle {
  color: var(--text-light-muted);
  font-size: 1rem;
  margin: 0;
}

.chapters-close-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.chapters-close-btn:hover {
  background: rgba(184, 115, 51, 0.3);
  transform: rotate(90deg);
}

.chapters-close-btn svg {
  width: 20px;
  height: 20px;
}

/* Body and Grid */
.chapters-modal-body {
  padding: 32px 40px;
  overflow-y: auto;
  max-height: calc(85vh - 140px);
}

/* Custom scrollbar */
.chapters-modal-body::-webkit-scrollbar {
  width: 8px;
}

.chapters-modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.chapters-modal-body::-webkit-scrollbar-thumb {
  background: rgba(184, 115, 51, 0.55);
  border-radius: 4px;
}

.chapters-modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 115, 51, 0.75);
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding-bottom: 20px;
}

/* Chapter Card Component */
.chapter-card {
  background: rgba(242, 232, 213, 0.08);
  border: 1px solid rgba(184, 115, 51, 0.18);
  border-radius: 6px;
  padding: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  opacity: 0;
  min-height: 360px;
  perspective: 900px;
}

.chapter-card:hover {
  border-color: rgba(184, 115, 51, 0.45);
  box-shadow: 0 12px 24px rgba(184, 115, 51, 0.18);
}

.chapter-card:focus-visible {
  outline: 2px solid rgba(184, 115, 51, 0.85);
  outline-offset: 2px;
}

.chapter-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 360px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.23, 1, 0.32, 1);
}

.chapter-card.flipped .chapter-card-inner {
  transform: rotateY(180deg);
}

.chapter-card-front,
.chapter-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.chapter-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, rgba(184, 115, 51, 0.3), rgba(139, 94, 60, 0.25));
}

/* Card icon */
.chapter-card-icon {
  width: 60px;
  height: 60px;
  object-fit: contain;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Card title */
.chapter-card-title {
  color: var(--text-light);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 12px 0;
  line-height: 1.3;
}

/* Card overview */
.chapter-card-overview {
  color: var(--text-light-muted);
  font-size: 0.95rem;
  margin: 0 0 12px 0;
  line-height: 1.5;
}

/* Experience intro */
.chapter-card-experience {
  color: var(--text-light);
  font-size: 0.9rem;
  margin: 0 0 12px 0;
  font-style: italic;
  line-height: 1.4;
}

/* Location badge */
.chapter-card-location {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(184, 115, 51, 0.2);
  color: var(--text-light);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.chapter-card-location::before {
  content: '📍';
  font-size: 1rem;
}

/* View CTA button */
.chapter-card-cta {
  width: 100%;
  padding: 12px;
  background: var(--gradient-primary);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.chapter-card-cta:hover {
  transform: translateY(1px);
  box-shadow: 0 6px 16px rgba(184, 115, 51, 0.35);
}

.chapter-card-hint {
  display: inline-block;
  margin-top: auto;
  font-size: 0.8rem;
  color: rgba(242, 232, 213, 0.7);
}

/* Animations */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideIn {
  from {
    transform: translateY(100vh) scale(0.9);
  }
  to {
    transform: translateY(0) scale(1);
  }
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .chapters-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
  }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
  .chapters-modal-container {
    width: 95%;
    max-height: 90vh;
    border-radius: 16px;
  }
  
  .chapters-modal-header {
    padding: 24px 20px;
  }

  .chapters-modal-header h2 {
    font-size: 1.6rem;
  }
  
  .chapters-modal-body {
    padding: 20px;
    max-height: calc(90vh - 120px);
  }
  
  .chapters-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .chapters-close-btn {
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
  }
}

/* Small mobile (< 480px) */
@media (max-width: 480px) {
  .chapters-modal-header h2 {
    font-size: 1.4rem;
  }
  
  .chapters-subtitle {
    font-size: 0.9rem;
  }
  
  .chapter-card {
    padding: 20px;
  }
  
  .chapter-card-icon {
    width: 50px;
    height: 50px;
  }

  .chapter-card-title {
    font-size: 1.2rem;
  }

  .chapter-card-overview,
  .chapter-card-experience {
    font-size: 0.9rem;
  }
}

/* Accessibility - High contrast mode */
@media (prefers-contrast: high) {
  .chapters-modal-overlay {
    background: rgba(0, 0, 0, 0.9);
  }

  .chapter-card {
    border: 2px solid rgba(255, 255, 255, 0.3);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .chapters-modal,
  .chapters-modal-container,
  .chapter-card,
  .chapters-close-btn,
  .chapter-card-cta {
    transition: none;
    animation: none;
  }

  .chapters-modal.active .chapters-modal-container {
    transform: scale(1);
  }
}
