/* =====================================
   CAROUSEL COMPONENT
   Generic Content Slider with System Patterns
   ===================================== */
/* Hide content while loading */
.api-loading .carousel,
.api-loading .carousel-viewport {
  display: none;
}
/* =====================================
   CAROUSEL CONTAINER
   ===================================== */
.carousel {
  position: relative;
  width: 100%;
  overflow: hidden;
  display: grid;
}
/* =====================================
   VIEWPORT & TRACK
   ===================================== */
.carousel-viewport {
  overflow: hidden;
  width: 100%;
  position: relative;
}
.carousel-track {
  /* Item width is derived from these two. Carousel.js writes
     --carousel-items inline from the instance's itemsPerView, so what is on
     screen always matches what the slide math steps past; the values here are
     the fallback for before/without JS and mirror the JS defaults. */
  --carousel-items: 4;
  --carousel-gap: 18px;
  display: flex;
  width: 100%;
  gap: var(--carousel-gap);
  transition: transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  will-change: transform;
}
.carousel-track:active {
  cursor: grabbing;
}
.carousel-track.dragging {
  cursor: grabbing;
}
/* =====================================
   CAROUSEL ITEMS
   ===================================== */
.carousel-item {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  min-width: 220px;
  overflow: hidden;
  flex: 0 0 auto;
  width: calc((100% - (var(--carousel-items) - 1) * var(--carousel-gap)) / var(--carousel-items));
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  animation: carousel-fadeInScale 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
@keyframes carousel-fadeInScale {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
/* Prevent clicks during drag */
.carousel-track.dragging .carousel-item {
  pointer-events: none;
}
/* =====================================
   CAROUSEL ITEM INNER LAYOUT
   Prevent text content from forcing item width beyond flex-basis
   ===================================== */
.carousel-item .widget-body {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  display: grid;
}
.carousel-item h3,
.carousel-item .description,
.carousel-item .date {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}
/* =====================================
   NAVIGATION BUTTONS
   Uses system pattern from MediaViewer
   ===================================== */
.carousel .nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 247, 252, 0.94)) !important;
  border-radius: 50%;
  color: var(--color-primary, #29336B) !important;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
  padding: 0;
}
.carousel .nav-button:hover {
  background: var(--color-primary, #29336B) !important;
  color: white !important;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.carousel .nav-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: translateY(-50%) scale(1);
}
.carousel .nav-button:disabled:hover {
  background: rgba(255, 255, 255, 0.95) !important;
  color: var(--color-primary, #29336B) !important;
}
/* Icon positioning - icons มาจาก Now.js font */
.carousel .nav-button:before {
  margin: 0;
  font-size: 24px;
}
/* =====================================
   RESPONSIVE DESIGN
   ===================================== */
/* Tablet (2 items) */
@media (max-width: 1024px) {
  .carousel-track {
    --carousel-items: 2;
  }
  .carousel .nav-button {
    width: 40px;
    height: 40px;
  }
  .carousel .nav-button:before {
    font-size: 20px;
  }
}
/* Mobile (1 item) */
@media (max-width: 600px) {
  .carousel-track {
    --carousel-items: 1;
    --carousel-gap: 16px;
  }
  .carousel .nav-button {
    width: 32px;
    height: 32px;
  }
  .carousel .nav-button:before {
    font-size: 18px;
  }
  .carousel .nav-button.prev {
    left: -5px;
  }
  .carousel .nav-button.next {
    right: -5px;
  }
}
/* =====================================
   SMOOTH TOUCH FEEDBACK
   ===================================== */
@media (hover: none) and (pointer: coarse) {
  .carousel .nav-button:active {
    transform: translateY(-50%) scale(0.95);
  }
  .carousel-track {
    scroll-snap-type: x mandatory;
  }
  .carousel-item {
    scroll-snap-align: start;
  }
}
/* =====================================
   ACCESSIBILITY
   ===================================== */
.carousel .nav-button:focus-visible {
  outline: 2px solid var(--color-primary, #29336B);
  outline-offset: 2px;
}
/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .carousel-track,
  .carousel-item,
  .carousel .nav-button {
    animation: none;
    transition: none;
  }
}
