/* =========================================================
   VARIABLES FORESIA
========================================================= */

.foresia-gallery,
.foresia-lightbox {
  --foresia-green: #4f6355;
  --foresia-green-dark: #1b2b1b;
  --foresia-green-soft: #65806d;
  --foresia-mist: #ddebe1;
  --foresia-neutral: #c8cbc0;
  --foresia-white: #ffffff;
  --foresia-radius: 18px;
}


/* =========================================================
   GALERIE PRINCIPALE
========================================================= */

.foresia-gallery {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.foresia-gallery__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: repeat(2, minmax(190px, 290px));
  gap: 10px;
  overflow: hidden;
  border-radius: var(--foresia-radius);
  background: var(--foresia-mist);
}

.foresia-gallery__item {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--foresia-green-dark);
  cursor: pointer;
  appearance: none;
}

.foresia-gallery__item--main {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.foresia-gallery__item img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  transition:
    transform 0.7s cubic-bezier(.2,.7,.2,1),
    filter 0.4s ease;
}

.foresia-gallery__item::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(27, 43, 27, 0) 45%,
    rgba(27, 43, 27, 0.22) 100%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
}

.foresia-gallery__item:hover img {
  transform: scale(1.035);
  filter: brightness(0.94);
}

.foresia-gallery__item:hover::after {
  opacity: 1;
}

.foresia-gallery__item:focus-visible {
  z-index: 3;
  outline: 3px solid var(--foresia-mist);
  outline-offset: -5px;
}


/* =========================================================
   BOUTON VOIR TOUTES LES PHOTOS
========================================================= */

.foresia-gallery__view-all {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  color: var(--foresia-green-dark);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(27, 43, 27, 0.16);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    transform 0.25s ease,
    background 0.25s ease;
}

.foresia-gallery__item:hover .foresia-gallery__view-all {
  transform: translateY(-2px);
  background: var(--foresia-white);
}

.foresia-gallery__item:nth-child(3) .foresia-gallery__view-all {
  display: none;
}

.foresia-gallery__view-all-icon {
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(2, 4px);
  gap: 2px;
}

.foresia-gallery__view-all-icon span {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: currentColor;
}


/* =========================================================
   LIGHTBOX
========================================================= */

.foresia-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  color: var(--foresia-white);
}

.foresia-lightbox.is-open {
  display: block;
}

.foresia-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at center,
      rgba(79, 99, 85, 0.35),
      rgba(14, 23, 15, 0.97) 72%
    );
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: foresiaFadeIn 0.25s ease both;
}

.foresia-lightbox__dialog {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 75px 90px 55px;
  box-sizing: border-box;
}

.foresia-lightbox__topbar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 0 26px;
  box-sizing: border-box;
}

.foresia-lightbox__counter {
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(27, 43, 27, 0.45);
  font-family: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.foresia-lightbox__close {
  position: relative;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(27, 43, 27, 0.45);
  cursor: pointer;
  transition:
    transform 0.25s ease,
    background 0.25s ease;
}

.foresia-lightbox__close:hover {
  transform: rotate(5deg);
  background: rgba(101, 128, 109, 0.8);
}

.foresia-lightbox__close span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 19px;
  height: 2px;
  border-radius: 2px;
  background: var(--foresia-white);
}

.foresia-lightbox__close span:first-child {
  transform: translate(-50%, -50%) rotate(45deg);
}

.foresia-lightbox__close span:last-child {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.foresia-lightbox__figure {
  display: flex;
  width: 100%;
  height: 100%;
  max-width: 1500px;
  max-height: 900px;
  margin: 0;
  align-items: center;
  justify-content: center;
}

.foresia-lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.32);
  animation: foresiaImageIn 0.28s ease both;
}

.foresia-lightbox__caption {
  position: absolute;
  right: 90px;
  bottom: 17px;
  left: 90px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.82);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.foresia-lightbox__arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  display: flex;
  width: 52px;
  height: 52px;
  align-items: center;
  justify-content: center;
  padding: 0 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: var(--foresia-white);
  background: rgba(27, 43, 27, 0.48);
  font-family: Arial, sans-serif;
  font-size: 42px;
  font-weight: 200;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    background 0.25s ease,
    transform 0.25s ease;
}

.foresia-lightbox__arrow:hover {
  background: rgba(101, 128, 109, 0.9);
  transform: translateY(-50%) scale(1.06);
}

.foresia-lightbox__arrow--previous {
  left: 22px;
}

.foresia-lightbox__arrow--next {
  right: 22px;
}

body.foresia-lightbox-open {
  overflow: hidden;
}


/* =========================================================
   ANIMATIONS
========================================================= */

@keyframes foresiaFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes foresiaImageIn {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}


/* =========================================================
   TABLETTE
========================================================= */

@media (max-width: 950px) {

  .foresia-gallery__grid {
    grid-template-columns: 1.6fr 1fr;
    grid-template-rows: repeat(2, minmax(180px, 250px));
  }

  .foresia-gallery__item:nth-child(4),
  .foresia-gallery__item:nth-child(5) {
    display: none;
  }

  .foresia-gallery__item:nth-child(3) .foresia-gallery__view-all {
    display: inline-flex;
  }

}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 650px) {

  .foresia-gallery {
    width: calc(100% + 32px);
    margin-left: -16px;
  }

  .foresia-gallery__grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 16px 8px;
    border-radius: 0;
    background: transparent;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .foresia-gallery__grid::-webkit-scrollbar {
    display: none;
  }

  .foresia-gallery__item,
  .foresia-gallery__item--main,
  .foresia-gallery__item:nth-child(4),
  .foresia-gallery__item:nth-child(5) {
    display: block;
    flex: 0 0 86%;
    height: 340px;
    border-radius: 16px;
    scroll-snap-align: center;
  }

  .foresia-gallery__item:first-child {
    margin-left: 0;
  }

  .foresia-gallery__view-all {
    right: 14px;
    bottom: 14px;
    padding: 10px 14px;
    font-size: 13px;
  }

  .foresia-gallery__item:nth-child(3) .foresia-gallery__view-all {
    display: none;
  }

  .foresia-gallery__item:nth-child(5) .foresia-gallery__view-all {
    display: inline-flex;
  }

  .foresia-lightbox__dialog {
    padding: 70px 10px 75px;
  }

  .foresia-lightbox__image {
    max-width: 100%;
    max-height: calc(100vh - 155px);
    border-radius: 8px;
  }

  .foresia-lightbox__topbar {
    min-height: 62px;
    padding: 0 14px;
  }

  .foresia-lightbox__close {
    width: 42px;
    height: 42px;
  }

  .foresia-lightbox__arrow {
    top: auto;
    bottom: 14px;
    width: 45px;
    height: 45px;
    font-size: 36px;
    transform: none;
  }

  .foresia-lightbox__arrow:hover {
    transform: scale(1.05);
  }

  .foresia-lightbox__arrow--previous {
    left: calc(50% - 58px);
  }

  .foresia-lightbox__arrow--next {
    right: calc(50% - 58px);
  }

  .foresia-lightbox__caption {
    right: 15px;
    bottom: 66px;
    left: 15px;
    font-size: 13px;
  }

}

/* =========================================================
   BOUTON GALERIE FORESIA
========================================================= */

.foresia-gallery-trigger-wrap.has-text-align-center,
.foresia-gallery-trigger-editor.has-text-align-center {
  text-align: center;
}

.foresia-gallery-trigger-wrap.has-text-align-right,
.foresia-gallery-trigger-editor.has-text-align-right {
  text-align: right;
}

.foresia-gallery-trigger {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 18px;
  border: 1px solid #1b2b1b;
  border-radius: 10px;
  color: #1b2b1b;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(27, 43, 27, 0.12);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.foresia-gallery-trigger:hover {
  background: #f7faf7;
  box-shadow: 0 7px 20px rgba(27, 43, 27, 0.17);
  transform: translateY(-1px);
}

.foresia-gallery-trigger:focus-visible {
  outline: 3px solid #ddebe1;
  outline-offset: 3px;
}

.foresia-gallery-trigger__icon {
  display: grid;
  grid-template-columns: repeat(2, 5px);
  grid-template-rows: repeat(2, 5px);
  gap: 2px;
}

.foresia-gallery-trigger__icon span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: currentColor;
}


/* Petit téléphone */

@media (max-width: 420px) {

  .foresia-gallery__item,
  .foresia-gallery__item--main,
  .foresia-gallery__item:nth-child(4),
  .foresia-gallery__item:nth-child(5) {
    flex-basis: 89%;
    height: 290px;
  }

}


/* Réduction des animations si configurée par le visiteur */

@media (prefers-reduced-motion: reduce) {

  .foresia-gallery__item img,
  .foresia-gallery__view-all,
  .foresia-lightbox__arrow,
  .foresia-lightbox__close {
    transition: none;
  }

  .foresia-lightbox__backdrop,
  .foresia-lightbox__image {
    animation: none;
  }

}


/* =========================================================
   CORRECTION LIGHTBOX MOBILE + KADENCE
========================================================= */

html.foresia-lightbox-open,
body.foresia-lightbox-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.foresia-lightbox {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  transform: none !important;
  isolation: isolate;
  pointer-events: none;
}

.foresia-lightbox.is-open {
  display: block !important;
  pointer-events: auto;
}

.foresia-lightbox__backdrop {
  position: fixed !important;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.foresia-lightbox__dialog {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  transform: none !important;
  overflow: hidden;
}

.foresia-lightbox__topbar,
.foresia-lightbox__close,
.foresia-lightbox__arrow {
  pointer-events: auto !important;
  touch-action: manipulation;
}

.foresia-lightbox__close,
.foresia-lightbox__arrow {
  z-index: 20 !important;
  min-width: 44px;
  min-height: 44px;
}

@media (max-width: 650px) {

  .foresia-lightbox__dialog {
    display: grid !important;
    grid-template-rows: 62px minmax(0, 1fr) 68px;
    grid-template-columns: 1fr;
    padding: 0 !important;
  }

  .foresia-lightbox__topbar {
    position: relative !important;
    inset: auto !important;
    grid-row: 1;
    width: 100%;
    min-height: 62px;
    padding:
      max(8px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      6px
      max(14px, env(safe-area-inset-left));
  }

  .foresia-lightbox__figure {
    position: relative;
    grid-row: 2;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 6px 10px;
    box-sizing: border-box;
  }

  .foresia-lightbox__image {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
  }

  .foresia-lightbox__arrow {
    top: auto !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    transform: none !important;
  }

  .foresia-lightbox__arrow--previous {
    left: calc(50% - 57px) !important;
  }

  .foresia-lightbox__arrow--next {
    right: calc(50% - 57px) !important;
  }

  .foresia-lightbox__caption {
    display: none;
  }

  .foresia-lightbox__close {
    flex: 0 0 46px;
    width: 46px !important;
    height: 46px !important;
    background: rgba(27, 43, 27, 0.9) !important;
  }

  .foresia-lightbox__counter {
    background: rgba(27, 43, 27, 0.9);
  }
}

