/* expand-on-hover core — scoped for editor, demo, and builders */
.mm-expand-on-hover {
  --page-bg: #f5f4f3;
  --page-overlay: transparent;
  --gap: 4px;
  --radius: 24px;
  --collapsed-w: 5rem;
  --collapsed-h: 2.5rem;
  --expanded: 24rem;
  --track: 24rem;
  --tween: 0.3s ease-in-out;
  --max-w: 1152px;
  --caption-color: rgba(255, 255, 255, 0.5);
  --caption-size: 12px;
  --overlay-strength: 0.4;
  --lb-scrim: rgba(8, 8, 10, 0.88);
  --lb-title-color: rgba(255, 255, 255, 0.9);
  --lb-title-size: 15px;
  --lb-code-color: rgba(255, 255, 255, 0.5);
  --lb-code-size: 12px;
  --lb-close-bg: #ffffff;
  --lb-close-icon: #111111;
  box-sizing: border-box;
  width: 100%;
  min-height: 100%;
  height: auto;
  position: relative;
  isolation: isolate;
  background-color: var(--page-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* no font-family here on purpose: module text inherits the builder theme typography (K10) */
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Fixed stage in horizontal mode: module ends with the gallery (02 §6).
   overflow hidden: 12 default items are wider than narrow builder columns -
   without the clip a click on an overflow-edge item makes the page scroll
   horizontally (phantom scrollbar line under the gallery). */
.mm-expand-on-hover:has(.gallery.is-horizontal) {
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.mm-expand-on-hover *,
.mm-expand-on-hover *::before,
.mm-expand-on-hover *::after {
  box-sizing: border-box;
}

/* Background overlay (02 §6): paints overlay color over the image, under the content */
.mm-expand-on-hover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--page-overlay);
  pointer-events: none;
  z-index: 0;
}

.mm-expand-on-hover .gallery-shell {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.5rem);
}

/* Vertical: fluid stage grows with content, first/last item stay visible */
.mm-expand-on-hover:has(.gallery.is-vertical) {
  min-height: 100%;
  padding-block: 1.5rem;
}

.mm-expand-on-hover:has(.gallery.is-vertical) .gallery-shell {
  align-items: flex-start;
}

.mm-expand-on-hover .gallery {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  width: 100%;
  position: relative;
}

.mm-expand-on-hover .gallery.is-vertical {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  max-width: var(--track);
  width: 100%;
  margin: 0 auto;
  overflow-anchor: none;
}

.mm-expand-on-hover .item {
  position: relative;
  flex: 0 0 auto;
  width: var(--collapsed-w);
  height: var(--track);
  overflow: hidden;
  cursor: pointer;
  border: none;
  background: #ddd;
  padding: 0;
  border-radius: var(--radius);
  -webkit-tap-highlight-color: transparent;
  outline: none;
  isolation: isolate;
  transition: width var(--tween), height var(--tween);
}

.mm-expand-on-hover .gallery.is-horizontal .item.is-active {
  width: var(--expanded);
  height: var(--track);
}

/* Vertical (skiper53 style): width fixed, height 2.5rem -> 24rem */
.mm-expand-on-hover .gallery.is-vertical .item {
  width: min(100%, var(--track));
  height: var(--collapsed-h);
  scroll-margin-block: 1.25rem;
}

.mm-expand-on-hover .gallery.is-vertical .item.is-active {
  height: var(--expanded);
}

.mm-expand-on-hover .item:focus-visible {
  box-shadow: 0 0 0 2px var(--page-bg), 0 0 0 4px currentColor;
}

.mm-expand-on-hover .item__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Active overlay: gradient + caption bottom */
.mm-expand-on-hover .item__grad {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, color-mix(in srgb, var(--overlay-color) calc(var(--overlay-strength) * 100%), transparent), transparent);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.25s ease;
}

.mm-expand-on-hover .gallery.is-vertical .item__grad {
  background: linear-gradient(to top, color-mix(in srgb, var(--overlay-color) calc((var(--overlay-strength) + 0.1) * 100%), transparent), transparent);
}

.mm-expand-on-hover .item__code {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.mm-expand-on-hover .gallery.is-vertical .item__code {
  padding: 0 1rem 1.25rem;
}

/* Rounded own edges on the clipped children: when hover animated, Chromium
   could leave a 1px stale line of the gradient's flat bottom row below the
   items - rounding the children removes the flat edge entirely. */
.mm-expand-on-hover .item__grad,
.mm-expand-on-hover .item__code {
  border-radius: inherit;
}

.mm-expand-on-hover .item__code span {
  font-size: var(--caption-size);
  line-height: 1;
  color: var(--caption-color);
  letter-spacing: 0.02em;
}

.mm-expand-on-hover .item.is-active .item__grad,
.mm-expand-on-hover .item.is-active .item__code {
  opacity: 1;
}

.mm-expand-on-hover .lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: var(--lb-scrim);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.mm-expand-on-hover .lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mm-expand-on-hover .lightbox__dialog {
  position: relative;
  max-width: min(1100px, 96vw);
  z-index: 1;
}

.mm-expand-on-hover .lightbox__img {
  display: block;
  max-width: 96vw;
  max-height: min(82vh, 82dvh);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  background: #1a1a1e;
}

.mm-expand-on-hover .lightbox__caption {
  margin-top: 0.75rem;
  text-align: center;
  color: var(--lb-title-color);
  font-size: var(--lb-title-size);
  font-weight: 500;
}

.mm-expand-on-hover .lightbox__code {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--lb-code-size);
  color: var(--lb-code-color);
  font-weight: 400;
}

.mm-expand-on-hover .lightbox__close {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  transform: translate(40%, -40%);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: none;
  background: var(--lb-close-bg);
  color: var(--lb-close-icon);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.mm-expand-on-hover .lightbox__close:hover { background: #f0f0f0; }

.mm-expand-on-hover .lightbox__backdrop {
  position: absolute;
  inset: 0;
  cursor: zoom-out;
}

/* 1.2.79: lift the module ROOT above later BB rows while the lightbox is
   open. isolation:isolate on the root turns it into a stacking context,
   so the fixed lightbox only ranked inside it - later rows painted over
   it. A z-index on the root itself wins over the auto-level siblings. */
.mm-expand-on-hover.is-lightbox-open { overflow: hidden; z-index: 1000000; }

.mm-expand-on-hover.reduced-motion .item,
.mm-expand-on-hover.reduced-motion .item__grad,
.mm-expand-on-hover.reduced-motion .item__code,
.mm-expand-on-hover.reduced-motion .lightbox {
  transition: none !important;
}

@media (max-width: 767px) {
  .mm-expand-on-hover .gallery-shell {
    padding: 0.75rem 0.85rem;
  }

  .mm-expand-on-hover .gallery.is-horizontal {
    justify-content: flex-start;
    width: max-content;
    min-width: 100%;
    padding: 0.25rem 0.15rem 0.5rem;
  }

  .mm-expand-on-hover .lightbox__close {
    top: 0.5rem;
    right: 0.5rem;
    transform: none;
  }
}

/* ---- Close-Icon App-Dialog-Look (Runde 60j): Inline-SVG statt Text-Glyphe,
   theme-sicher zentriert, duenner Ring wie im App-Modal. ---- */
.mm-expand-on-hover .lightbox__close {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.32) !important;
}

.mm-expand-on-hover .lightbox__close svg {
  width: 45% !important;
  height: 45% !important;
  display: block !important;
  pointer-events: none;
}


/* ---- BB theme hardening (precedence bounce-cards 1.2.60 / card-stack 60g):
   builder themes style buttons and images inside the content — the runtime
   sets the design values inline (they beat any stylesheet), this block is
   the second belt for states the inline styles cannot cover. ---- */
.mm-expand-on-hover .item,
.mm-expand-on-hover .item:hover,
.mm-expand-on-hover .item:active {
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  outline: none !important;
  text-decoration: none !important;
}
.mm-expand-on-hover .item:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 2px var(--page-bg), 0 0 0 4px currentColor !important;
}
.mm-expand-on-hover .item__img,
.mm-expand-on-hover .lightbox__img {
  border: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}
.mm-expand-on-hover .lightbox__close:hover,
.mm-expand-on-hover .lightbox__close:focus-visible {
  background: #f0f0f0 !important;
}
