/**
 * Gallery grid + lightbox styling for the Image Gallery media type.
 * Carousel markup/behavior lives in mcs_media_gallery/js/gallery-carousel.js.
 */

:root {
  --mcs-gallery-maroon: #ad1a1e;
  --mcs-gallery-maroon-dark: #921619;
  --mcs-gallery-gold: #ffcc00;
  --mcs-gallery-ink: #2e2828;
  --mcs-gallery-ground: #f7f6f4;
  --mcs-gallery-card-border: #dedede;
  --mcs-gallery-shadow: 0 5px 20px 5px rgba(0, 0, 0, 0.05);
  --mcs-gallery-shadow-hover: 0 14px 32px 0 rgba(45, 20, 20, 0.16);
}

/* Gallery title */
.field--name-name {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--mcs-gallery-ink);
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
  padding-bottom: 0.65rem;
  border-bottom: 3px solid var(--mcs-gallery-gold);
  display: inline-block;
}

/* Self-filling tile grid, scales with viewport instead of fixed breakpoints */
.photoswipe-gallery {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)) !important;
  justify-content: center;
  gap: 1.25rem !important;
  background: var(--mcs-gallery-ground);
  padding: 1.5rem;
  border-radius: 10px;
  margin-bottom: 2rem;
}

/* Mobile: one-at-a-time swipeable carousel instead of the grid */
@media (max-width: 480px) {
  .mcs-gallery-carousel {
    display: flex !important;
    /* override the grid's justify-content: center, which isn't !important */
    justify-content: flex-start !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    gap: 0;
    background: none;
    border-radius: 0;
    position: relative;
    margin-bottom: 0;
    scrollbar-width: none;
  }

  .mcs-gallery-carousel::-webkit-scrollbar {
    display: none;
  }

  .mcs-gallery-carousel .field__item {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .mcs-gallery-carousel .field__item a.photoswipe {
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .mcs-gallery-carousel-wrap {
    position: relative;
    background: var(--mcs-gallery-ground);
    padding: 0 0 2.75rem;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2rem;
  }

  .mcs-gallery-carousel-arrow {
    position: absolute;
    top: 42%;
    transform: translateY(-50%);
    z-index: 2;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--mcs-gallery-maroon);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .mcs-gallery-carousel-arrow:active {
    background: var(--mcs-gallery-maroon-dark);
  }

  .mcs-gallery-carousel-arrow--prev {
    left: 10px;
  }

  .mcs-gallery-carousel-arrow--next {
    right: 10px;
  }

  .mcs-gallery-carousel-arrow[disabled] {
    opacity: 0.35;
    pointer-events: none;
  }

  .mcs-gallery-carousel-dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.9rem;
    display: flex;
    justify-content: center;
    gap: 0.4rem;
  }

  .mcs-gallery-carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    padding: 0;
    background: var(--mcs-gallery-card-border);
    cursor: pointer;
  }

  .mcs-gallery-carousel-dot[aria-current="true"] {
    background: var(--mcs-gallery-maroon);
    width: 20px;
    border-radius: 4px;
  }
}

@media not all and (max-width: 480px) {
  .mcs-gallery-carousel-arrow,
  .mcs-gallery-carousel-dots {
    display: none;
  }
}

/* Tiles: fixed aspect-ratio card with elevation, crop and hover zoom */
.photoswipe-gallery .field__item {
  margin: 0;
}

.photoswipe-gallery .field__item a.photoswipe {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 5 / 3;
  border-radius: 6px;
  border: 1px solid var(--mcs-gallery-card-border);
  background: #fff;
  box-shadow: var(--mcs-gallery-shadow);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.photoswipe-gallery .field__item a.photoswipe:hover,
.photoswipe-gallery .field__item a.photoswipe:focus-visible {
  box-shadow: var(--mcs-gallery-shadow-hover);
  transform: translateY(-3px);
}

.photoswipe-gallery .field__item a.photoswipe:focus-visible {
  outline: 3px solid var(--mcs-gallery-maroon);
  outline-offset: 2px;
}

.photoswipe-gallery .field__item img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  display: block;
  transition: transform 0.45s ease;
}

.photoswipe-gallery .field__item a.photoswipe:hover img,
.photoswipe-gallery .field__item a.photoswipe:focus-visible img {
  transform: scale(1.07);
}

.photoswipe-gallery .field__item a.photoswipe::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(to top, rgba(20, 10, 10, 0.55), rgba(20, 10, 10, 0));
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.photoswipe-gallery .field__item a.photoswipe:hover::after,
.photoswipe-gallery .field__item a.photoswipe:focus-visible::after {
  opacity: 1;
}

.photoswipe-gallery .field__item a.photoswipe::before {
  content: "\2922";
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  line-height: 1;
  border-radius: 50%;
  background: var(--mcs-gallery-maroon);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1;
}

.photoswipe-gallery .field__item a.photoswipe:hover::before,
.photoswipe-gallery .field__item a.photoswipe:focus-visible::before {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .photoswipe-gallery .field__item a.photoswipe,
  .photoswipe-gallery .field__item img {
    transition: none;
  }
}

/* PhotoSwipe lightbox chrome: brand maroon instead of default flat black */
.pswp__bg {
  background: #140a0a;
}

.pswp__top-bar {
  background: linear-gradient(to bottom, rgba(45, 15, 15, 0.9), rgba(45, 15, 15, 0));
}

.pswp__button {
  transition: opacity 0.2s ease;
}

.pswp__button:hover {
  opacity: 0.75;
}

.pswp__counter {
  color: #f3e4c8;
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pswp__caption,
.pswp__dynamic-caption {
  background: linear-gradient(to top, rgba(20, 8, 8, 0.92), rgba(20, 8, 8, 0));
  color: #fdf6f6;
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
}

.pswp__button--arrow {
  opacity: 1;
}

/* keep arrows visible on touch too, not just swipe */
.pswp--touch .pswp__button--arrow {
  visibility: visible !important;
}

/* recenter the off-center chevron glyph in SVG user-space */
.pswp__button--arrow .pswp__icn {
  top: 50%;
  left: 50%;
  right: auto;
  margin: -22px 0 0 -22px;
  width: 44px;
  height: 44px;
  background: var(--mcs-gallery-maroon);
  border-radius: 50%;
  transition: background 0.2s ease;
}

.pswp__button--arrow .pswp__icn use:not(.pswp__icn-shadow) {
  transform: translateX(10.5px);
  transform-box: fill-box;
}

.pswp__button--arrow--next .pswp__icn {
  transform: scale(-1, 1);
}

.pswp__button--arrow:hover .pswp__icn {
  background: var(--mcs-gallery-maroon-dark);
}

.pswp__button--arrow .pswp__icn-shadow {
  display: none;
}

@media (max-width: 480px) {
  .pswp__button--arrow .pswp__icn {
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
  }
}

/* Galleries listing page (/galleries): card styling + override the view's
   fixed-column grid with a responsive auto-fit one */
.path-galleries .view-content .views-view-grid .views-row {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)) !important;
  gap: 1.5rem;
  float: none !important;
  width: 100% !important;
  margin: 0 !important;
}

.path-galleries .view-content .views-view-grid .views-col {
  float: none !important;
  width: auto !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--mcs-gallery-card-border);
  border-radius: 8px;
  box-shadow: var(--mcs-gallery-shadow);
  overflow: hidden;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.path-galleries .view-content .views-view-grid .views-col:hover {
  box-shadow: var(--mcs-gallery-shadow-hover);
  transform: translateY(-3px);
}

.path-galleries .views-field-name {
  order: 2;
  padding: 0.75rem 1rem 1rem;
  font-weight: 700;
  color: var(--mcs-gallery-maroon);
}

.path-galleries .views-field-name a {
  color: inherit;
  text-decoration: none;
}

.path-galleries .views-field-name a:hover {
  color: var(--mcs-gallery-maroon-dark);
  text-decoration: underline;
}

.path-galleries .views-field-thumbnail__target-id {
  order: 1;
  line-height: 0;
}

.path-galleries .views-field-thumbnail__target-id img {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 3;
  object-fit: cover;
  display: block;
}
