/* Shared before/after cases — sedation + ortodont */
.sm-ba {
  padding: 48px 0 56px;
  background: #fff;
}

.sm-ba__carousel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
  justify-content: center;
}

/* Persistent mobile stage arrows — positioned over active photo by JS. */
.sm-ba__stage-nav {
  display: none;
}

.sm-ba__track-wrap {
  flex: 1 1 auto;
  max-width: 1200px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  overflow: hidden;
  position: relative;
}

.sm-ba__track {
  width: 100%;
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
}

.sm-ba__track::-webkit-scrollbar {
  display: none;
}

.sm-ba__slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.sm-ba__slide:not(.is-active) {
  pointer-events: none;
}

.sm-ba__layout {
  display: grid;
  grid-template-columns: minmax(0, 640px) minmax(260px, 420px);
  gap: 48px;
  align-items: start;
}

.sm-ba__media {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

.sm-ba__case {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: #f3f3f3;
  font-family: var(--sm-font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--sm-grey-600);
}

.sm-ba__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.sm-ba__photo {
  margin: 0;
  position: relative;
  width: 100%;
  aspect-ratio: 302 / 232;
  border-radius: 12px;
  overflow: hidden;
  background: var(--sm-main-100);
}

.sm-ba__open {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.sm-ba__open:focus-visible {
  outline: 2px solid #ffe552;
  outline-offset: -2px;
}

.sm-ba__tag {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffe552;
  font-family: var(--sm-font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  color: var(--sm-grey-900);
  pointer-events: none;
}

.sm-ba__photo picture {
  display: contents;
}

.sm-ba__photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.sm-ba__open:hover img {
  transform: scale(1.03);
}

.sm-ba-lightbox.sm-lightbox {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483646 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border: 0 !important;
  padding: 64px 16px 24px !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(49, 49, 49, 0.82) !important;
}

.sm-ba-lightbox.sm-lightbox:not([open]) {
  display: none !important;
}

.sm-ba-lightbox.sm-lightbox::backdrop {
  background: rgba(49, 49, 49, 0.82);
}

.sm-ba-lightbox .sm-ba-lightbox__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: min(1100px, calc(100vw - 32px));
}

.sm-ba-lightbox .sm-lightbox__img {
  max-width: min(1100px, calc(100vw - 32px));
  max-height: calc(100dvh - 140px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.sm-ba-lightbox__caption {
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: #ffe552;
  font-family: var(--sm-font-body);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  color: var(--sm-grey-900);
}

.sm-ba-lightbox .sm-lightbox__close,
.sm-ba-lightbox .sm-lightbox__nav {
  position: absolute;
  background: #ffe552;
  color: #3e3e3e;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sm-ba-lightbox .sm-lightbox__close {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 28px;
  line-height: 1;
  z-index: 2;
}

.sm-ba-lightbox .sm-lightbox__nav {
  top: 50%;
  width: 40px;
  height: 40px;
  margin-top: -20px;
}

.sm-ba-lightbox .sm-lightbox__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.sm-ba-lightbox .sm-lightbox__nav--prev {
  left: 12px;
}

.sm-ba-lightbox .sm-lightbox__nav--next {
  right: 12px;
}

.sm-ba-lightbox .sm-lightbox__nav-icon {
  display: flex;
  width: 9px;
  height: 16px;
}

.sm-ba-lightbox .sm-lightbox__nav--prev .sm-lightbox__nav-icon {
  transform: rotate(180deg);
}

.sm-ba-lightbox .sm-lightbox__nav-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sm-ba__copy {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  /* Align title with photo grid top (case badge ~28px + media gap 16px). */
  padding-top: 44px;
}

.sm-ba__title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sm-ba__spark--start {
  display: none;
}

.sm-ba__mobile {
  display: none;
}

.sm-ba__title {
  margin: 0;
  font-family: var(--sm-font-body);
  font-weight: 700;
  font-size: 32px;
  line-height: 36px;
  color: var(--sm-grey-900);
}

.sm-ba__spark {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #ffe552;
}

.sm-ba__spark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sm-ba__text {
  margin: 0;
  font-family: var(--sm-font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 22px;
  color: var(--sm-grey-600);
}

.sm-ba__text strong {
  font-weight: 700;
  color: var(--sm-grey-800);
}

.sm-ba__cta {
  margin-top: 12px;
}

.sm-ba__cta .sm-btn {
  width: fit-content;
  max-width: 100%;
}

.sm-ba__summary {
  margin: 0;
  font-family: var(--sm-font-body);
  font-size: 16px;
  font-weight: 700;
  line-height: 22px;
  color: var(--sm-grey-900);
}

.sm-ba__nav {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #ffe552;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  box-shadow: none;
}

.sm-ba__nav:disabled {
  opacity: 0.4;
  cursor: default;
}

.sm-ba__nav-icon {
  display: flex;
  width: 9.25px;
  height: 15.74px;
  flex: 0 0 auto;
}

.sm-ba__nav-icon svg {
  width: 9.25px;
  height: 15.74px;
  display: block;
  overflow: visible;
  flex: 0 0 auto;
}

.sm-ba__nav--prev .sm-ba__nav-icon {
  transform: rotate(180deg);
}

.sm-ba__progress {
  width: 142px;
  height: 8px;
  border-radius: 16px;
  background: rgba(66, 119, 132, 0.1);
  overflow: hidden;
  position: relative;
  align-self: flex-start;
}

.sm-ba__progress-bar {
  height: 100%;
  width: 40px;
  border-radius: 16px;
  background: #757879;
  transition: transform 0.35s ease;
  will-change: transform;
}

@media (max-width: 900px) {
  .sm-ba__layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .sm-ba__carousel {
    gap: 12px;
  }

  .sm-ba {
    padding: 40px 0 48px;
    overflow: visible;
  }

  .sm-ba .sm-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .sm-ba__carousel {
    display: block;
    width: 100%;
  }

  .sm-ba__nav--case {
    display: none;
  }

  .sm-ba__track-wrap {
    flex: none;
    width: 100%;
    max-width: none;
    min-width: 0;
    gap: 20px;
    overflow: hidden;
    contain: paint;
  }

  .sm-ba__stage-nav {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 8;
    pointer-events: none;
  }

  .sm-ba__stage-nav[hidden] {
    display: none !important;
  }

  .sm-ba__stage-nav .sm-ba__nav--stage-global {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto;
  }

  .sm-ba__stage-nav .sm-ba__nav--prev {
    left: 8px;
  }

  .sm-ba__stage-nav .sm-ba__nav--next {
    right: 8px;
  }

  /* Swap cases in place — no horizontal page-like scroll */
  .sm-ba__carousel[data-slider-swap] .sm-ba__track {
    display: block;
    width: 100%;
    overflow: hidden;
    scroll-snap-type: none;
    touch-action: pan-y;
  }

  .sm-ba__carousel[data-slider-swap] .sm-ba__slide {
    display: none;
    flex: none;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .sm-ba__carousel[data-slider-swap] .sm-ba__slide.is-active {
    display: block;
  }

  .sm-ba__layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .sm-ba__media--desktop {
    display: none;
  }

  .sm-ba__mobile {
    display: flex;
    flex-direction: column;
    gap: 16px;
    order: 2;
    min-height: var(--sm-ba-mobile-min, 0px);
  }

  .sm-ba__copy {
    order: 1;
    gap: 16px;
    padding-top: 0;
    text-align: center;
    align-items: center;
    /* Locked by sliders.js to the tallest case — keeps stage arrows steady. */
    min-height: var(--sm-ba-copy-min, 0px);
  }

  .sm-ba__carousel[data-slider-swap] .sm-ba__stage {
    min-height: var(--sm-ba-stage-min, 0px);
  }

  .sm-ba__title-row {
    justify-content: center;
    width: 100%;
  }

  .sm-ba__spark--start {
    display: inline-flex;
  }

  .sm-ba__title {
    font-size: 24px;
    line-height: 28px;
    text-align: center;
  }

  .sm-ba__cta {
    display: none;
  }

  .sm-ba__text,
  .sm-ba__summary {
    text-align: left;
    width: 100%;
  }

  .sm-ba__stage {
    position: relative;
    display: block;
    width: 100%;
  }

  .sm-ba__stage-photo {
    position: relative;
    margin: 0;
    width: 100%;
    max-width: none;
    aspect-ratio: 320 / 250;
    border-radius: 12px;
    overflow: hidden;
    background: var(--sm-main-100);
    touch-action: pan-y;
  }

  .sm-ba__stage-tag {
    z-index: 4;
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Image fills the figure; open overlay is separate so side insets
     for arrows do not letterbox the photo. */
  .sm-ba__stage-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    display: block;
    pointer-events: none;
  }

  .sm-ba__stage-open {
    position: absolute;
    top: 0;
    right: 48px;
    bottom: 0;
    left: 48px;
    z-index: 2;
    width: auto;
    height: auto;
    touch-action: pan-y;
  }

  .sm-ba__nav--stage {
    z-index: 6;
    width: 44px;
    height: 44px;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .sm-ba__nav--stage .sm-ba__nav-icon,
  .sm-ba__nav--stage .sm-ba__nav-icon svg {
    pointer-events: none;
  }

  .sm-ba__thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .sm-ba__thumb {
    position: relative;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    overflow: hidden;
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    aspect-ratio: 1;
    background: var(--sm-main-100);
    cursor: pointer;
  }

  .sm-ba__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .sm-ba__thumb-num {
    position: absolute;
    z-index: 1;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffe552;
    color: var(--sm-grey-900);
    font-family: var(--sm-font-body);
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
  }

  .sm-ba__thumb.is-active {
    outline: 2px solid #ffe552;
    outline-offset: 1px;
  }

  .sm-ba__more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 12px 20px;
    border: 1px solid var(--sm-grey-700);
    border-radius: var(--sm-radius-pill, 999px);
    background: transparent;
    color: var(--sm-grey-900);
    font-family: var(--sm-font-body);
    font-size: 16px;
    font-weight: 700;
    line-height: 20px;
    cursor: pointer;
    transition: background var(--sm-transition, 0.2s ease), transform var(--sm-transition, 0.2s ease);
  }

  .sm-ba__more:hover {
    background: rgba(49, 49, 49, 0.04);
    transform: translateY(-1px);
  }

  .sm-ba__more:active {
    transform: translateY(0);
  }

  .sm-ba__progress {
    width: 120px;
    margin-inline: auto;
  }

  .sm-ba {
    padding: 48px 0;
  }

  .sm-ba__title {
    font-size: 24px;
    line-height: 28px;
  }
}

/* Pair layout (2 photos) — ortodont desktop */
.sm-ba__grid--pair {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto;
}

.sm-ba__grid--pair .sm-ba__photo {
  aspect-ratio: 280 / 380;
}

/* Triple layout (before / mid / after) */
.sm-ba__grid--triple {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto;
}

.sm-ba__grid--triple .sm-ba__photo {
  aspect-ratio: 302 / 232;
}

/* >4 equal photos without mid/before split */
.sm-ba__grid--multi {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto;
}

.sm-ba__grid--multi .sm-ba__photo {
  aspect-ratio: 302 / 232;
}

/*
 * Mosaic (>4 with mid): large before + after on top row,
 * smaller intermediate photos in a strip below.
 */
.sm-ba__grid--mosaic {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.sm-ba__heroes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

.sm-ba__heroes .sm-ba__photo--lg {
  min-height: 0;
  aspect-ratio: 320 / 240;
}

.sm-ba__heroes .sm-ba__photo--lg:only-child {
  grid-column: 1 / -1;
  max-width: 70%;
}

.sm-ba__mids {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.sm-ba__mids:has(> :only-child) {
  grid-template-columns: minmax(110px, 200px);
}

.sm-ba__mids .sm-ba__photo--sm {
  aspect-ratio: 4 / 3;
  min-height: 0;
}

.sm-ba__photo--lg .sm-ba__tag,
.sm-ba__photo--sm .sm-ba__tag {
  font-size: 12px;
  line-height: 16px;
}

.sm-ba__photo--sm .sm-ba__tag {
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 14px;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ortodont: no case badge above photos — title aligns with image top */
.sm-ba--orto .sm-ba__copy {
  padding-top: 0;
}
