/*
 * Sigma Gallery — front-end + editor styles.
 *
 * Plain CSS (no Tailwind): this loads on the public front end and inside every
 * page builder, none of which carry the plugin's `.smm-wrap` scope.
 */

.smm-gallery {
  display: grid;
  grid-template-columns: repeat(var(--smm-gallery-cols, 3), minmax(0, 1fr));
  gap: var(--smm-gallery-gap, 12px);
  margin: 0 0 1.5em;
  padding: 0;
  list-style: none;
}

.smm-gallery__item {
  margin: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
}

.smm-gallery__link {
  display: block;
  line-height: 0;
  text-decoration: none;
}

.smm-gallery__img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* Cropped: uniform squares regardless of source ratio. */
.smm-gallery--crop .smm-gallery__img {
  aspect-ratio: 1 / 1;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
}

/* Older browsers without aspect-ratio support fall back to a padded box. */
@supports not (aspect-ratio: 1 / 1) {
  .smm-gallery--crop .smm-gallery__item {
    padding-top: 100%;
  }
  .smm-gallery--crop .smm-gallery__link,
  .smm-gallery--crop .smm-gallery__img {
    position: absolute;
    inset: 0;
    height: 100%;
  }
}

.smm-gallery__caption {
  margin: 0;
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.3;
  color: #555;
  text-align: center;
}

.smm-gallery__link:hover .smm-gallery__img {
  opacity: 0.92;
  transition: opacity 0.15s ease;
}

.smm-gallery--empty {
  display: block;
  border: 1px dashed #c3c4c7;
  border-radius: 4px;
  padding: 24px;
  text-align: center;
  color: #757575;
  background: #f6f7f7;
}

/* Responsive column drop-down. */
@media (max-width: 782px) {
  .smm-gallery {
    grid-template-columns: repeat(
      min(var(--smm-gallery-cols, 3), 3),
      minmax(0, 1fr)
    );
  }
}

@media (max-width: 480px) {
  .smm-gallery {
    grid-template-columns: repeat(
      min(var(--smm-gallery-cols, 3), 2),
      minmax(0, 1fr)
    );
  }
}

/* ---- Lightbox ---- */

body.smm-lightbox-open {
  overflow: hidden;
}

.smm-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.smm-lightbox[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.smm-lightbox__figure {
  margin: 0;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.smm-lightbox__img {
  max-width: 92vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  -o-object-fit: contain;
     object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.smm-lightbox__caption {
  margin-top: 12px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  max-width: 80vw;
}

.smm-lightbox__close,
.smm-lightbox__nav {
  position: absolute;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s ease;
  padding: 8px;
}

.smm-lightbox__close:hover,
.smm-lightbox__nav:hover {
  opacity: 1;
}

.smm-lightbox__close {
  top: 16px;
  right: 20px;
  font-size: 40px;
}

.smm-lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 56px;
}

.smm-lightbox__prev {
  left: 12px;
}

.smm-lightbox__next {
  right: 12px;
}

.smm-lightbox__counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  letter-spacing: 0.03em;
}

@media (max-width: 600px) {
  .smm-lightbox__nav {
    font-size: 40px;
  }
  .smm-lightbox__close {
    font-size: 32px;
  }
}

/* ---- Block editor: Image Source inspector ---- */

.smm-gi {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.smm-gi__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #1e1e1e;
}

.smm-gi__count {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #757575;
}

.smm-gi__folders {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

.smm-gi__folder {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  color: #1e1e1e;
  transition: background-color 0.1s ease;
}

.smm-gi__folder:hover {
  background: #f0f0f0;
}

.smm-gi__folder.is-selected {
  background: #f0f6fc;
  color: #043959;
}

.smm-gi__check {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 1.5px solid #949494;
  border-radius: 3px;
  box-sizing: border-box;
  position: relative;
}

.smm-gi__check.is-on {
  background: #3858e9;
  border-color: #3858e9;
}

.smm-gi__check.is-on::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.smm-gi__folder-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.smm-gi__field .components-base-control {
  margin-bottom: 0;
}

.smm-gi__field--divider {
  border-top: 1px solid #e0e0e0;
  padding-top: 16px;
}

.smm-gi__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.smm-gi__btn.smm-gi__btn {
  width: 100%;
  justify-content: center;
}

