/* =======================
   SHARED MEDIA CAROUSEL
======================= */

.media-carousel {
  position: relative;
  width: 100%;
}

.media-carousel--hero {
  max-width: 1100px;
  margin: 0 auto;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.media-carousel--gallery {
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin: 20px 0;
  width: 100%;
  max-width: 100%;
  min-height: 500px;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

/* Slide mode (galleries): panel width is set in px by JS to avoid
   flex % circular sizing (Safari shows two half-slides on mobile). */
.media-carousel__track {
  display: flex;
  align-items: stretch;
  width: 100%;
  will-change: transform;
  cursor: grab;
  touch-action: pan-y;
}

.media-carousel__track:active {
  cursor: grabbing;
}

.media-carousel--slide .media-carousel__panel {
  flex: 0 0 auto;
  box-sizing: border-box;
  min-width: 0;
  max-width: none;
}

.media-carousel--gallery .media-carousel__panel {
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #f8f9fa);
  overflow: hidden;
  padding: 0.5rem;
}

.media-carousel--gallery .media-carousel__figure {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  height: 100%;
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.media-carousel--gallery .media-carousel__panel img {
  display: block;
  max-width: 100%;
  max-height: 500px;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  pointer-events: auto;
  -webkit-user-drag: none;
}

/* Fade mode (hero): grid stack keeps a stable height (tallest slide). */
.media-carousel--hero.media-carousel--fade {
  display: grid;
}

.media-carousel--hero.media-carousel--fade > .media-carousel__panel {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.media-carousel--hero.media-carousel--fade > .media-carousel__panel.is-active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
  animation: media-carousel-fade-in 0.45s ease;
}

/* Fade mode (non-hero fallback) */
.media-carousel--fade:not(.media-carousel--hero) .media-carousel__panel {
  display: none;
  width: 100%;
}

.media-carousel--fade:not(.media-carousel--hero) .media-carousel__panel.is-active {
  display: block;
  animation: media-carousel-fade-in 0.45s ease;
}

@keyframes media-carousel-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.media-carousel__caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  box-sizing: border-box;
  font-family: var(--font-family-primary);
  font-size: var(--font-size-sm);
  line-height: 1.35;
  color: var(--text-inverse);
  text-align: center;
  margin: 0;
  background: rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.media-carousel--hero .media-carousel__panel .media-carousel__layout {
  min-height: 280px;
  padding: var(--spacing-md) 3rem;
  width: 100%;
}

.media-carousel--hero .media-carousel__panel--text-only .media-carousel__layout {
  padding: var(--spacing-lg) 2rem;
}

/* Content + media layout */
.media-carousel__layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  width: 100%;
}

.media-carousel__content {
  flex: 1 1 280px;
  max-width: 32rem;
}

.media-carousel__media {
  flex: 0 1 32rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.media-carousel__media img {
  width: min(100%, 500px);
  max-width: 500px;
  display: block;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  object-fit: cover;
}

/* Text-only panel: centered title/CTA block (intro justify lives in home_page.css) */
.media-carousel__panel--text-only .media-carousel__layout {
  justify-content: center;
}

.media-carousel__panel--text-only .media-carousel__content {
  flex: 1 1 100%;
  max-width: 40rem;
  margin: 0 auto;
}

.media-carousel__panel--text-only .media-carousel__content h1 {
  text-align: center;
}

.media-carousel__panel--text-only .media-carousel__content .hero-btn {
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

/* Navigation - vertically centered on a stable viewport */
.media-carousel__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-inverse);
  background: rgba(10, 39, 66, 0.45);
  backdrop-filter: blur(6px);
  transition: background var(--transition-normal), transform var(--transition-normal);
}

.media-carousel__nav:hover {
  background: rgba(10, 39, 66, 0.72);
  transform: translateY(-50%) scale(1.06);
}

.media-carousel__nav--prev {
  left: 0.5rem;
}

.media-carousel__nav--next {
  right: 0.5rem;
}

.media-carousel--hero .media-carousel__nav--prev {
  left: -0.25rem;
  right: auto;
}

.media-carousel--hero .media-carousel__nav--next {
  right: -0.25rem;
  left: auto;
}

/* Keep nav/dots in the same grid cell as stacked fade panels */
.media-carousel--hero.media-carousel--fade > .media-carousel__nav,
.media-carousel--hero.media-carousel--fade > .media-carousel__dots {
  grid-area: 1 / 1;
  z-index: 10;
}

/* Pagination dots — inset + wrap so edge dots aren't clipped by overflow:hidden */
.media-carousel__dots {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.65rem;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.4rem;
  box-sizing: border-box;
  max-width: calc(100% - 1.5rem);
  margin: 0 auto;
  height: auto;
  min-height: 0;
  pointer-events: none;
}

/*
  Hit target = transparent button; visible circle = ::after.
  Avoids Safari stretching empty <button> into ovals when using % border-radius.
*/
.media-carousel__dot {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  position: relative;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 0;
  line-height: 0;
  cursor: pointer;
}

.media-carousel__dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 999px;
  background: rgba(10, 39, 66, 0.32);
  box-shadow: 0 0 0 1px rgba(10, 39, 66, 0.1);
  transition: background 0.2s ease, box-shadow 0.2s ease, width 0.2s ease, height 0.2s ease, margin 0.2s ease;
}

.media-carousel__dot.is-active::after {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--color-primary, #03b0cc);
  box-shadow: 0 0 0 2px rgba(3, 176, 204, 0.35);
}

.media-carousel--gallery .media-carousel__dots {
  bottom: 0.75rem;
}

.media-carousel--hero .media-carousel__dot::after {
  background: rgba(10, 39, 66, 0.32);
}

.media-carousel--hero .media-carousel__dot.is-active::after {
  background: var(--color-primary, #03b0cc);
}

@media (max-width: 1024px) {
  .media-carousel__layout {
    flex-direction: column;
    gap: var(--spacing-lg);
  }

  .media-carousel__content,
  .media-carousel__media {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
  }

  .media-carousel__panel:not(.media-carousel__panel--text-only) .media-carousel__content {
    text-align: center;
  }

  .media-carousel--hero .media-carousel__nav--prev {
    left: 0.25rem;
    right: auto;
  }

  .media-carousel--hero .media-carousel__nav--next {
    right: 0.25rem;
    left: auto;
  }

  .media-carousel--gallery {
    min-height: 420px;
  }

  .media-carousel--gallery .media-carousel__panel {
    min-height: 420px;
  }

  .media-carousel--gallery .media-carousel__panel img {
    max-height: 420px;
  }
}

@media (max-width: 768px) {
  /* Swipe + dots replace arrows on small screens */
  .media-carousel__nav {
    display: none;
  }

  .media-carousel--gallery {
    min-height: min(280px, 55vh);
  }

  .media-carousel--gallery .media-carousel__panel {
    min-height: min(280px, 55vh);
    padding: 0.35rem;
  }

  .media-carousel--gallery .media-carousel__panel img {
    max-height: min(260px, 50vh);
  }

  .media-carousel__dots {
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    max-width: calc(100% - 1rem);
    gap: 0.3rem 0.35rem;
  }

  .media-carousel__dot {
    width: 10px;
    height: 10px;
  }

  .media-carousel__dot::after {
    width: 5px;
    height: 5px;
    margin: -2.5px 0 0 -2.5px;
  }

  .media-carousel__dot.is-active::after {
    width: 7px;
    height: 7px;
    margin: -3.5px 0 0 -3.5px;
  }
}
