/* Themes for the Soul – responsive, container-query based */

/* 1) Wrapper is a size container so inner values can respond to it */
.themes-slider-wrapper {
  container-type: inline-size; /* enables 100cqi etc. */
  width: 100%;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
  overflow-y: visible;
  /* extra bottom space so controls/content aren't cut off in tight containers */
  padding-bottom: 40px;
}

/* 2) Defaults (custom properties = single source of truth) */
.themes-for-the-soul-container.themes-slider {
  --gap: 30px;
  --min-card: 180px; /* min width of a card */
  --max-card: 330px; /* max width of a card */
  --cols: 2.5; /* how many cards visible by default */

  display: flex;
  gap: var(--gap);
  align-items: stretch;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding: 0;
  inline-size: 100%;
  /* Mobile scrolling improvements */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  /* Improve desktop drag responsiveness */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Active dragging state */
.themes-for-the-soul-container.themes-slider:active,
.themes-for-the-soul-container.themes-slider.swiper-container-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

/* Mobile scrolling optimizations */
@media (max-width: 768px) {
  .themes-for-the-soul-container.themes-slider {
    /* Enhanced mobile scrolling */
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: auto;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    /* Remove snap on smaller screens for smoother scrolling */
    scroll-snap-type: none;
  }
}

.themes-for-the-soul-container.themes-slider::-webkit-scrollbar {
  display: none;
}

/* 3) Card sizing: one clamp() formula, no per-breakpoint math */
.theme-item {
  /* fluid card width: min…fluid…max */
  inline-size: clamp(
    var(--min-card),
    /* fluid target = (container - total gaps)/cols */
      calc((100cqi - (var(--cols) - 1) * var(--gap)) / var(--cols)),
    var(--max-card)
  );
  flex: 0 0 auto;
  min-inline-size: var(--min-card);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 27px;
  transition: opacity 0.4s ease;
}

/* Dimmed state applied by JS when not fully visible */
.theme-item.is-dimmed {
  opacity: 0.45;
}
/* Make it obvious the dimmed (partially off-screen) cards are interactive */
.theme-item.can-scroll-into-view {
  cursor: pointer;
}
.theme-item.can-scroll-into-view:focus-visible {
  outline: 2px solid var(--heading-primary);
  outline-offset: 2px;
}

/* 4) Last spacer = container width minus one card width (so last card can fully snap) */
.themes-for-the-soul-container.themes-slider::after {
  content: "";
  flex: 0 0
    calc(
      100% -
        clamp(
          var(--min-card),
          calc((100cqi - (var(--cols) - 1) * var(--gap)) / var(--cols)),
          var(--max-card)
        )
    );
}

/* 5) Media/content styles (unchanged where possible) */
.theme-item img {
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 1;
  object-fit: cover;
  flex: 0 0 auto;
}
.theme-item-content-wrapper {
  inline-size: 100%;
  min-block-size: 220px;
  padding-bottom: 14px;
  display: flex;
  flex: 1 1 auto;
}
.theme-item-content {
  inline-size: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 18px;
  flex: 1 1 auto;
}
.theme-item-discover-link {
  margin-top: auto;
}
.theme-item-title {
  color: var(--heading-primary);
  font: 400 20px/24px "KoPub Batang", serif;
}
.theme-item-description {
  color: var(--body-primary);
  font: 300 16px/22.4px "Work Sans", sans-serif;
}
.theme-item-discover-link a {
  text-decoration: none;
}
.theme-item-discover-link-inner {
  padding-block: 10px;
  border-bottom: 1px solid var(--heading-primary);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.theme-item-discover-link-text {
  color: var(--heading-primary);
  font: 500 16px "Work Sans", sans-serif;
}

/* Progress (unchanged) */
.slider-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  inline-size: 100%;
  margin-top: 60px;
}
.themes-progress-track {
  inline-size: 100%;
  block-size: 1px;
  background: #b6b6b6;
  position: relative;
}
.themes-progress-fill {
  block-size: 1px;
  background: #000;
  inline-size: 0%;
  transition: inline-size 0.3s ease;
}

/* 6) Container queries: only tweak columns & text at a few widths */
@container (min-width: 1440px) {
  .themes-for-the-soul-container.themes-slider {
    --gap: 44px;
    --cols: 2.5;
  }
  .theme-item {
    gap: 30px;
  }
}

@container (min-width: 1024px) and (max-width: 1439px) {
  .themes-for-the-soul-container.themes-slider {
    --gap: 35px;
    --cols: 2.5;
  }
}

@container (min-width: 768px) and (max-width: 1023px) {
  .themes-for-the-soul-container.themes-slider {
    --gap: 25px;
    --cols: 2;
  }
  .theme-item-title {
    font-size: 18px;
    line-height: 22px;
  }
  .theme-item-description {
    font-size: 15px;
    line-height: 21px;
  }
  .theme-item-content-wrapper {
    min-block-size: 200px;
    padding-bottom: 12px;
  }
}

@container (min-width: 600px) and (max-width: 767px) {
  .themes-for-the-soul-container.themes-slider {
    --gap: 20px;
    --cols: 1.8;
  }
  .theme-item {
    gap: 18px;
  }
  .theme-item-title {
    font-size: 17px;
    line-height: 21px;
  }
  .theme-item-description {
    font-size: 14px;
    line-height: 20px;
  }
  .theme-item-content-wrapper {
    min-block-size: 188px;
    padding-bottom: 12px;
  }
  .theme-item-content {
    gap: 15px;
  }
}

@container (min-width: 480px) and (max-width: 599px) {
  .themes-for-the-soul-container.themes-slider {
    --gap: 18px;
    --cols: 1.5;
  }
  .theme-item {
    gap: 16px;
  }
  .theme-item-title {
    font-size: 16px;
    line-height: 20px;
  }
  .theme-item-description {
    font-size: 14px;
    line-height: 19px;
  }
  .theme-item-content-wrapper {
    min-block-size: 176px;
    padding-bottom: 10px;
  }
  .theme-item-content {
    gap: 14px;
  }
  .theme-item-discover-link-inner {
    padding-block: 8px;
  }
  .theme-item-discover-link-text {
    font-size: 15px;
  }
}

@container (max-width: 479px) {
  .themes-for-the-soul-container.themes-slider {
    --gap: 15px;
    --cols: 1.3;
  }
  .theme-item {
    gap: 14px;
  }
  .theme-item-title {
    font-size: 15px;
    line-height: 19px;
  }
  .theme-item-description {
    font-size: 13px;
    line-height: 18px;
  }
  .theme-item-content-wrapper {
    min-block-size: 166px;
    padding-bottom: 10px;
  }
  .theme-item-content {
    gap: 12px;
  }
  .theme-item-title-container {
    gap: 6px;
  }
  .theme-item-discover-link-inner {
    padding-block: 6px;
    gap: 8px;
  }
  .theme-item-discover-link-text {
    font-size: 14px;
  }
}

/* Touch niceties */
@media (hover: none) and (pointer: coarse) {
  .themes-for-the-soul-container.themes-slider {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    /* Override desktop styles for mobile */
    cursor: default !important;
    user-select: auto !important;
    -webkit-user-select: auto !important;
    -moz-user-select: auto !important;
    -ms-user-select: auto !important;
    /* Optimize for touch scrolling */
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
  }
  
  .themes-for-the-soul-container.themes-slider:active {
    cursor: default !important;
  }
  
  .theme-item-discover-link-inner {
    min-block-size: 44px;
    padding-block: 12px;
    /* Ensure touch targets are large enough */
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  .theme-item {
    /* Improve touch responsiveness */
    touch-action: manipulation;
    /* Reset desktop transform effects */
    transform: none !important;
    transition: opacity 0.4s ease;
  }
  
  /* Allow text selection on mobile */
  .themes-for-the-soul-container.themes-slider *,
  .theme-item-title,
  .theme-item-description,
  .theme-item-discover-link-text {
    -webkit-user-select: auto !important;
    -moz-user-select: auto !important;
    -ms-user-select: auto !important;
    user-select: auto !important;
  }
}

/* Desktop improvements */
@media (hover: hover) and (pointer: fine) {
  .themes-for-the-soul-container.themes-slider {
    /* Better desktop mouse interaction */
    scroll-behavior: auto;
    cursor: grab;
  }
  
  .themes-for-the-soul-container.themes-slider:active {
    cursor: grabbing;
  }
  
  /* Improve card interaction on desktop */
  .theme-item {
    transition: transform 0.2s ease, opacity 0.4s ease;
  }
  
  .theme-item:hover:not(.is-dimmed) {
    transform: translateY(-2px);
  }
  
  /* Prevent text selection during drag */
  .themes-for-the-soul-container.themes-slider * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  /* Allow text selection on links and text when not dragging */
  .theme-item-title,
  .theme-item-description,
  .theme-item-discover-link-text {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
  }
}

/* HiDPI */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .theme-item img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}
