/**
 * Swiper Custom Styles
 * Integrates Swiper.js with Roots of Reason design system
 * Preserves original carousel control styling
 */

/* ==========================================
   SERVICES CAROUSEL - SWIPER OVERRIDES
   ========================================== */

.services-carousel .swiper {
  overflow-x: hidden; /* Prevent horizontal scrolling */
  overflow-y: visible; /* Allow shadows to show vertically */
  padding: 18px;
  margin: -18px;
}

.services-carousel .swiper-wrapper {
  display: flex;
  align-items: stretch; /* Equal height for all slides */
}

.services-carousel .swiper-slide {
  height: auto; /* Override Swiper's default height: 100% */
  display: flex; /* Make slide a flex container */
}

.services-carousel .swiper-slide .service-card {
  flex: 1; /* Fill the slide */
  display: flex;
  flex-direction: column;
}

.services-carousel .service-card .card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.services-carousel .service-card .card-body p {
  flex: 1; /* Text takes space it needs */
}

.services-carousel .service-card .learn-more-btn {
  margin-top: 1rem; /* Space above button */
  flex-shrink: 0; /* Don't compress button */
}

/* Custom Controls Container - positioned at top, buttons grouped */
.services-carousel .carousel-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  justify-content: flex-start; /* Keep buttons on left side together */
}

/* Custom Navigation Buttons - circular style */
.services-carousel .carousel-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--sage-green);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 200ms ease;
  padding: 0;
  flex-shrink: 0; /* Never shrink buttons */
}

.services-carousel .carousel-btn:hover:not(.swiper-button-disabled) {
  background: var(--sage-green);
}

.services-carousel .carousel-btn:hover:not(.swiper-button-disabled) svg {
  stroke: #fff;
}

.services-carousel .carousel-btn.swiper-button-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.services-carousel .carousel-btn svg {
  stroke: var(--sage-green);
  transition: stroke 200ms ease;
}

/* Keyboard focus states */
.services-carousel .carousel-btn:focus-visible {
  outline: 3px solid var(--sage-green);
  outline-offset: 2px;
}

/* Custom Pagination Dots Container - CRITICAL FIX */
.services-carousel .carousel-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  /* Don't set fixed width - let it size to content */
  width: auto !important;
  flex-shrink: 0; /* Never shrink container */
}

/* Override Swiper's default width */
.services-carousel .swiper-pagination-bullets.swiper-pagination-horizontal {
  width: auto !important; /* Override Swiper's fixed width */
  left: auto !important; /* Don't position absolutely */
  bottom: auto !important;
}

/* Custom Pagination Dots - PREVENT SHRINKING */
.services-carousel .carousel-dot {
  width: 10px;
  height: 10px;
  min-width: 10px; /* Prevent shrinking */
  min-height: 10px; /* Prevent shrinking */
  flex-shrink: 0; /* CRITICAL: Never allow dots to shrink */
  border-radius: 50%;
  background: rgb(38 92 47 / 25%);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 200ms ease;
}

.services-carousel .carousel-dot:hover {
  background: rgb(38 92 47 / 50%);
  transform: scale(1.15);
}

/* Active state for Swiper - accounts for scale transform */
.services-carousel .carousel-dot.swiper-pagination-bullet-active {
  background: var(--sage-green);
  transform: scale(1.2);
  min-width: 12px; /* Account for scale(1.2) = 10px * 1.2 = 12px */
  min-height: 12px; /* Prevent active dot from shrinking when scaled */
}

/* Legacy class support */
.services-carousel .carousel-dot.active {
  background: var(--sage-green);
  transform: scale(1.2);
  min-width: 12px;
  min-height: 12px;
}

/* ==========================================
   FORMATS CAROUSEL - DESKTOP GRID
   ========================================== */

/* Desktop: Grid layout (no carousel) */
@media (min-width: 768px) {
  .formats-carousel .swiper-wrapper.formats-grid {
    display: grid !important; /* Override Swiper's flex */
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
    align-items: stretch; /* Force equal height grid items */
  }
  
  .formats-carousel .swiper-slide {
    display: flex; /* Make slide a flex container */
  }
  
  .formats-carousel .format-card {
    width: 100%;
    display: flex;
    flex-direction: column;
  }
  
  .formats-carousel .format-icon {
    flex-shrink: 0; /* Don't squish icon */
  }
  
  .formats-carousel .format-benefits {
    flex: 1; /* Take remaining space */
  }
  
  .formats-carousel .swiper-pagination,
  .formats-carousel .carousel-controls {
    display: none; /* Hide controls on desktop */
  }
}

@media (min-width: 1024px) {
  .formats-carousel .swiper-wrapper.formats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
  }
}

/* ==========================================
   ACCESSIBILITY & MOTION
   ========================================== */

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .swiper-wrapper {
    transition-duration: 0ms !important;
  }
  
  .services-carousel .service-card,
  .services-carousel .carousel-btn,
  .services-carousel .carousel-dot {
    transition-duration: 0ms !important;
  }
}

/* Keyboard focus states */
.carousel-btn:focus-visible,
.carousel-dot:focus-visible,
.swiper-pagination-bullet:focus-visible {
  outline: 3px solid var(--sage-green);
  outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


/* ==========================================
   FORMAT CARDS - SINGLE CARD CENTERING
   ========================================== */

/* Center content when displaying single format cards */
@media (min-width: 768px) {
  .formats-carousel .format-benefits {
    text-align: center;
    list-style: none;
    padding: 0;
    margin: 0 auto;
    max-width: 500px; /* Constrain width for better readability */
  }
  
  .formats-carousel .format-benefits li {
    font-size: 1.125rem; /* Increased from 1rem for better readability */
    line-height: 1.8; /* More breathing room between lines */
    margin-bottom: 0.75rem; /* Space between list items */
    padding-left: 0; /* Remove left padding used for bullets */
  }
  
  /* Remove bullet pseudo-elements when centered */
  .formats-carousel .format-benefits li::before {
    content: none; /* Remove bullets for centered layout */
  }
  
  /* Also center the format duration text */
  .formats-carousel .format-duration {
    font-size: 1.05rem; /* Slightly larger */
  }
}

/* On larger screens where single cards are very wide, increase size more */
@media (min-width: 1200px) {
  .formats-carousel .format-benefits li {
    font-size: 1.25rem; /* Even larger on big screens */
    line-height: 1.9;
    margin-bottom: 1rem;
    padding-left: 0; /* Ensure no left padding on large screens */
  }
  
  .formats-carousel .format-duration {
    font-size: 1.125rem;
  }
}


/* ==========================================
   FORMATS CAROUSEL - MOBILE STYLING
   ========================================== */

/* Formats carousel: mobile-first overrides */
.formats-carousel {
  /* Swiper CSS variables so defaults don't override */
  --swiper-pagination-bullet-size: 10px;
  --swiper-pagination-bullet-inactive-color: rgb(38 92 47 / 0.25);
  --swiper-pagination-bullet-inactive-opacity: 1;
  --swiper-theme-color: var(--sage-green);
  --swiper-pagination-color: var(--sage-green);
  
  /* Prevent horizontal overflow on mobile */
  overflow: hidden;
}

@media (max-width: 767.98px) {
  .formats-carousel .swiper {
    overflow: hidden; /* Contain slides within viewport - prevents horizontal page scroll */
    padding-bottom: 12px; /* breathing room above dots */
  }

  /* Control bar layout matches services carousel */
  .formats-carousel .carousel-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    margin-bottom: 8px;
    justify-content: flex-start;
  }

  .formats-carousel .carousel-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--sage-green);
    background: transparent;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 200ms ease;
    padding: 0;
    flex-shrink: 0;
  }
  
  .formats-carousel .carousel-btn:hover:not(:disabled) {
    background: var(--sage-green);
  }
  
  .formats-carousel .carousel-btn:hover:not(:disabled) svg {
    stroke: #fff;
  }
  
  .formats-carousel .carousel-btn:disabled,
  .formats-carousel .carousel-btn.swiper-button-disabled {
    opacity: 0.3;
    cursor: not-allowed;
  }
  
  .formats-carousel .carousel-btn svg { 
    stroke: var(--sage-green); 
    transition: stroke 200ms ease; 
  }

  /* Dots container uses Swiper's pagination inside control bar */
  .formats-carousel .swiper-pagination {
    position: static !important; /* stop absolute full-width positioning */
    display: flex !important;
    gap: 8px;
    align-items: center;
    width: auto !important;
    flex-shrink: 0;
  }

  /* Pagination bullets */
  .formats-carousel .swiper .swiper-pagination-bullet {
    width: 10px !important;
    height: 10px !important;
    border-radius: 50%;
    opacity: 1 !important;
    transition: transform 200ms ease;
    margin: 0 !important; /* Remove Swiper's default margin */
  }
  
  .formats-carousel .swiper .swiper-pagination-bullet-active {
    transform: scale(1.2);
  }

  /* Card mobile optimizations */
  .format-card { 
    padding: var(--space-md); 
  }
  
  .format-icon { 
    width: 48px; 
    height: 48px; 
    margin-bottom: var(--space-sm); 
  }

  /* Benefit list with circular bullets */
  .format-benefits { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    text-align: left; 
  }
  
  .format-benefits li {
    position: relative;
    padding: 4px 0 4px 24px;
    font-size: var(--text-sm);
    line-height: 1.4;
    color: var(--body);
  }
  
  .format-benefits li::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 0.7em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sage-green);
    box-shadow: 0 0 0 2px rgb(38 92 47 / 0.25);
    transform: translateY(-50%);
  }
}

/* Fallback if Swiper's hardcoded background wins */
.formats-carousel .swiper .swiper-pagination-bullet,
.formats-carousel .swiper .swiper-pagination-bullet-active {
  background: var(--swiper-pagination-color) !important;
}

/* ==========================================
   MOBILE-SPECIFIC: FORMATS SECTION CLEANUP
   ========================================== */

@media (max-width: 640px) {
  /* A. Tighten section padding on mobile */
  .tutoring-formats {
    padding-block: var(--space-md);
  }

  /* B. Make each slide feel like a focused card view */
  .formats-carousel .swiper-slide {
    display: flex;
    justify-content: center;
  }

  .formats-carousel .format-card {
    width: 100%;
    max-width: 520px;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  /* C. Remove arrows, keep only dots (touch-friendly) */
  .formats-carousel .carousel-btn {
    display: none;
  }

  .formats-carousel .swiper-pagination {
    position: static;
    margin-top: var(--space-sm);
    justify-content: center;
  }

  /* D. Remove extra bottom gap */
  .formats-carousel .swiper {
    padding-bottom: 0;
  }
}

