.thipiz-gallery {
  --tg-bg: #181816;
  --tg-panel: #22221f;
  --tg-strip-bg: #f3efe7;
  --tg-image-bg: #0d0d0c;
  --tg-strip-ink: #272521;
  --tg-text: #f3efe7;
  --tg-muted: #bdb7aa;
  --tg-accent: #c4a56a;
  --tg-line: rgba(196, 165, 106, .35);
  --tg-stage-height: 620px;
  --tg-thumb-height: 78px;
  --tg-thumb-width: 110px;
  --tg-transition: 400ms;
  --tg-thumb-gap: 10px;
  --tg-inner-frame: 10px;
  --tg-inner-frame-color: #fff;
  --tg-outer-frame: 40px;
  --tg-outer-frame-color: #000;
  --tg-mat-width: 0px;
  --tg-mat-color: #fff;
  --tg-image-radius: 0px;
  --tg-inner-frame-radius: 0px;
  --tg-outer-frame-radius: 0px;
  --tg-artwork-shadow: none;
  --tg-image-bg-end: #343431;
  --tg-image-bg-angle: 135deg;
  --tg-frame-reserve: 100px;

  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--tg-thumb-gap);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: 0;
  overflow: visible;
  color: var(--tg-text);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.thipiz-gallery--light {
  --tg-bg: #f4f0e8;
  --tg-panel: #fff;
  --tg-strip-bg: #fff;
  --tg-strip-ink: #272521;
  --tg-text: #272521;
  --tg-muted: #6e685e;
  --tg-line: rgba(112,91,57,.22);
}

.thipiz-gallery *,
.thipiz-gallery *::before,
.thipiz-gallery *::after { box-sizing: border-box; }

.thipiz-gallery__heading {
  margin: 0 0 2px;
  color: inherit;
  font: 400 clamp(1.35rem, 2.5vw, 2rem)/1.15 Georgia, serif;
  letter-spacing: .02em;
}

/* Bandeau autonome, clair et réellement séparé du bloc principal. */
.thipiz-gallery__thumbbar {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 8px;
  margin: 0;
  color: var(--tg-strip-ink);
  background: var(--tg-strip-bg);
  border: 1px solid rgba(80, 72, 60, .16);
  border-radius: 7px;
  box-shadow: 0 5px 18px rgba(0,0,0,.12);
  overflow: hidden;
}


/* Option d’administration : masquer visuellement le conteneur du bandeau. */
.thipiz-gallery--thumbbar-transparent .thipiz-gallery__thumbbar {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

section.thipiz-gallery .thipiz-gallery__thumbs {
  display: flex !important;
  flex-flow: row nowrap !important;
  align-items: stretch !important;
  gap: 8px !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding: 2px !important;
  scrollbar-width: thin;
  scrollbar-color: var(--tg-accent) transparent;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

section.thipiz-gallery .thipiz-gallery__thumbs > button.thipiz-gallery__thumb {
  all: unset;
  display: flex !important;
  flex: 0 0 var(--tg-thumb-width) !important;
  align-items: center !important;
  justify-content: center !important;
  width: var(--tg-thumb-width) !important;
  min-width: var(--tg-thumb-width) !important;
  max-width: var(--tg-thumb-width) !important;
  height: var(--tg-thumb-height) !important;
  min-height: var(--tg-thumb-height) !important;
  max-height: var(--tg-thumb-height) !important;
  padding: 4px !important;
  margin: 0 !important;
  overflow: hidden !important;
  border: 1px solid rgba(70, 64, 55, .16) !important;
  border-radius: 4px !important;
  background: #fff !important;
  opacity: .66;
  cursor: pointer;
  scroll-snap-align: start;
  transition: opacity .2s, border-color .2s, transform .2s, box-shadow .2s;
}

section.thipiz-gallery .thipiz-gallery__thumbs > button.thipiz-gallery__thumb:hover,
section.thipiz-gallery .thipiz-gallery__thumbs > button.thipiz-gallery__thumb:focus-visible,
section.thipiz-gallery .thipiz-gallery__thumbs > button.thipiz-gallery__thumb.is-active {
  opacity: 1;
  border-color: var(--tg-accent) !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,.14);
  outline: none;
}

section.thipiz-gallery .thipiz-gallery__thumbs > button.thipiz-gallery__thumb > img {
  position: static !important;
  display: block !important;
  flex: none !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
  background: #fff !important;
}

.thipiz-gallery__thumb-arrow,
.thipiz-gallery__main-arrow,
.thipiz-gallery__action {
  border: 1px solid var(--tg-line);
  color: inherit;
  background: rgba(34,34,31,.74);
  cursor: pointer;
  transition: background .2s, border-color .2s, opacity .2s;
}

.thipiz-gallery--light .thipiz-gallery__thumb-arrow,
.thipiz-gallery--light .thipiz-gallery__main-arrow,
.thipiz-gallery--light .thipiz-gallery__action {
  background: rgba(255,255,255,.92);
}

.thipiz-gallery__thumb-arrow {
  display: grid;
  place-items: center;
  min-width: 0;
  width: 42px;
  padding: 0;
  font-size: 2rem;
  line-height: 1;
  color: var(--tg-strip-ink);
  background: rgba(255,255,255,.92);
  border-color: rgba(80,72,60,.18);
  border-radius: 4px;
}

.thipiz-gallery__thumb-arrow:hover,
.thipiz-gallery__thumb-arrow:focus-visible,
.thipiz-gallery__main-arrow:hover,
.thipiz-gallery__main-arrow:focus-visible,
.thipiz-gallery__action:hover,
.thipiz-gallery__action:focus-visible {
  border-color: var(--tg-accent);
  outline: none;
}

.thipiz-gallery__stage {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  background: var(--tg-panel);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 7px;
  box-shadow: 0 8px 26px rgba(0,0,0,.16);
}

.thipiz-gallery__figure {
  min-width: 0;
  margin: 0;
}

.thipiz-gallery__image-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--tg-stage-height);
  min-height: 280px;
  overflow: hidden;
  padding: clamp(10px, 2vw, 24px);
  background: var(--tg-image-bg);
  cursor: zoom-in;
  touch-action: none;
}

.thipiz-gallery--light .thipiz-gallery__image-wrap { background: var(--tg-image-bg); }
.thipiz-gallery--image-bg-transparent .thipiz-gallery__image-wrap { background: transparent; }
.thipiz-gallery--image-bg-gradient .thipiz-gallery__image-wrap {
  background: linear-gradient(var(--tg-image-bg-angle), var(--tg-image-bg), var(--tg-image-bg-end));
}

.thipiz-gallery__artwork {
  display: inline-flex;
  max-width: 100%;
  max-height: 100%;
  transform-origin: var(--tg-origin-x, 50%) var(--tg-origin-y, 50%);
  transform: translate3d(var(--tg-pan-x, 0px), var(--tg-pan-y, 0px), 0) scale(var(--tg-zoom, 1));
  transition: opacity var(--tg-transition), transform .08s linear;
  will-change: transform;
}

.thipiz-gallery__outer-frame,
.thipiz-gallery__inner-frame,
.thipiz-gallery__mat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.thipiz-gallery__outer-frame {
  padding: var(--tg-outer-frame);
  background: var(--tg-outer-frame-color);
  border-radius: var(--tg-outer-frame-radius);
  box-shadow: none;
}

.thipiz-gallery__inner-frame {
  padding: var(--tg-inner-frame);
  background: var(--tg-inner-frame-color);
  border-radius: var(--tg-inner-frame-radius);
}

.thipiz-gallery__mat {
  padding: var(--tg-mat-width);
  background: var(--tg-mat-color);
  border-radius: var(--tg-image-radius);
}

.thipiz-gallery__image {
  display: block;
  box-shadow: none;
  filter: var(--tg-image-drop-shadow, drop-shadow(10px 12px 16px rgba(0,0,0,.55))) !important;
  width: auto;
  height: auto;
  max-width: calc(100% - var(--tg-frame-reserve));
  max-height: calc(var(--tg-stage-height) - var(--tg-frame-reserve) - 48px);
  object-fit: contain;
  background: transparent;
  border: 0;
  border-radius: var(--tg-image-radius);
  user-select: none;
  -webkit-user-drag: none;
}

.thipiz-gallery__image-wrap.is-changing .thipiz-gallery__artwork { opacity: 0; }
.thipiz-gallery.is-zoomed .thipiz-gallery__image-wrap { cursor: grab; }
.thipiz-gallery.is-dragging .thipiz-gallery__image-wrap { cursor: grabbing; }

.thipiz-gallery__zoom-level {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-width: 64px;
  padding: 5px 8px;
  color: #fff;
  background: rgba(0,0,0,.62);
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.thipiz-gallery__zoom-level.is-visible { opacity: 1; }

.thipiz-gallery__main-arrow {
  display: grid;
  place-items: center;
  width: 54px;
  min-width: 54px;
  padding: 0;
  font-size: 2.5rem;
}

.thipiz-gallery__caption {
  padding: 16px 18px 20px;
  background: var(--tg-panel);
  border-top: 1px solid rgba(255,255,255,.07);
}

.thipiz-gallery__title {
  margin: 0 0 5px;
  font: 400 clamp(1.2rem, 2vw, 1.6rem)/1.2 Georgia, serif;
}

.thipiz-gallery__meta,
.thipiz-gallery__availability,
.thipiz-gallery__description { margin: 5px 0; }
.thipiz-gallery__meta,
.thipiz-gallery__description { color: var(--tg-muted); }
.thipiz-gallery__availability { color: var(--tg-accent); }
.thipiz-gallery__link { color: var(--tg-accent); }
.thipiz-gallery__link.is-hidden { display: none; }

.thipiz-gallery__actions {
  position: absolute;
  right: 68px;
  top: 12px;
  display: flex;
  gap: 8px;
  z-index: 4;
}

.thipiz-gallery__action {
  padding: 8px 12px;
  border-radius: 3px;
}

.thipiz-gallery:fullscreen {
  padding: 16px;
  gap: 10px;
  background: #111;
}
.thipiz-gallery:fullscreen .thipiz-gallery__stage { height: calc(100vh - 32px); }
.thipiz-gallery:fullscreen .thipiz-gallery__image-wrap { height: calc(100vh - 140px); }

/* Tablette */
@media (max-width: 900px) {
  .thipiz-gallery { padding: 0; }
  .thipiz-gallery__stage { grid-template-columns: 44px minmax(0,1fr) 44px; }
  .thipiz-gallery__main-arrow { width: 44px; min-width: 44px; }
  .thipiz-gallery__image-wrap {
    height: min(var(--tg-stage-height), 68vh);
    min-height: 320px;
  }
  .thipiz-gallery__actions { right: 56px; }
}

/* Smartphone */
@media (max-width: 640px) {
  .thipiz-gallery {
    width: 100%;
    padding: 0;
    gap: var(--tg-thumb-gap);
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .thipiz-gallery__heading { font-size: 1.25rem; }

  .thipiz-gallery__thumbbar {
    grid-template-columns: 30px minmax(0,1fr) 30px;
    gap: 4px;
    padding: 5px;
    border-radius: 4px;
  }

  .thipiz-gallery__thumb-arrow {
    width: 30px;
    font-size: 1.6rem;
  }

  section.thipiz-gallery .thipiz-gallery__thumbs {
    gap: 5px !important;
    padding: 1px !important;
    scroll-snap-type: x mandatory;
  }

  section.thipiz-gallery .thipiz-gallery__thumbs > button.thipiz-gallery__thumb {
    flex-basis: clamp(66px, 22vw, 86px) !important;
    width: clamp(66px, 22vw, 86px) !important;
    min-width: clamp(66px, 22vw, 86px) !important;
    max-width: clamp(66px, 22vw, 86px) !important;
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
    padding: 3px !important;
    scroll-snap-align: center;
  }

  .thipiz-gallery__stage {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .thipiz-gallery__figure { width: 100%; }

  .thipiz-gallery__image-wrap {
    width: 100%;
    height: min(62vh, 520px);
    min-height: 260px;
    max-height: 520px;
    padding: 8px;
  }

  .thipiz-gallery__main-arrow {
    position: absolute;
    top: 31%;
    z-index: 5;
    width: 34px;
    min-width: 34px;
    height: 54px;
    font-size: 2rem;
    background: rgba(24,24,22,.66);
  }
  .thipiz-gallery__main-arrow--prev { left: 4px; }
  .thipiz-gallery__main-arrow--next { right: 4px; }

  .thipiz-gallery__caption { padding: 12px 12px 15px; }
  .thipiz-gallery__title { font-size: 1.2rem; }

  .thipiz-gallery__actions {
    position: static;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    padding: 8px 6px 10px;
  }

  .thipiz-gallery__action {
    min-height: 42px;
    padding: 8px 12px;
  }
}

@media (max-width: 390px) {
  .thipiz-gallery__image-wrap { min-height: 225px; height: 56vh; }
  .thipiz-gallery__main-arrow { width: 30px; min-width: 30px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .thipiz-gallery *,
  .thipiz-gallery *::before,
  .thipiz-gallery *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}


@media (min-width: 901px) {
  section.thipiz-gallery .thipiz-gallery__image-wrap {
    height: clamp(350px, calc(100dvh - 270px), 680px) !important;
    min-height: 350px !important;
    max-height: 680px !important;
    padding: 10px 16px !important;
  }

  section.thipiz-gallery .thipiz-gallery__image {
    max-height: calc(clamp(350px, calc(100dvh - 270px), 680px) - var(--tg-frame-reserve) - 20px) !important;
  }

  section.thipiz-gallery .thipiz-gallery__caption {
    padding: 8px 14px 10px !important;
  }

  section.thipiz-gallery .thipiz-gallery__title {
    margin-bottom: 3px !important;
  }

  section.thipiz-gallery .thipiz-gallery__meta,
  section.thipiz-gallery .thipiz-gallery__availability,
  section.thipiz-gallery .thipiz-gallery__description {
    margin: 3px 0 !important;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  section.thipiz-gallery .thipiz-gallery__image-wrap {
    height: clamp(260px, calc(100dvh - 350px), 500px) !important;
    min-height: 260px !important;
    max-height: 500px !important;
  }

  section.thipiz-gallery .thipiz-gallery__image {
    max-height: calc(clamp(260px, calc(100dvh - 350px), 500px) - var(--tg-frame-reserve) - 20px) !important;
  }
}

@media (min-width: 641px) {
  .thipiz-gallery__actions {
    display: grid !important;
    grid-template-columns: auto auto;
    gap: 6px 8px;
    align-items: center;
  }

  .thipiz-gallery__fullscreen {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: stretch;
  }

  .thipiz-gallery__rotate-left {
    grid-column: 1;
    grid-row: 2;
  }

  .thipiz-gallery__rotate-right {
    grid-column: 2;
    grid-row: 2;
  }

  .thipiz-gallery__zoom {
    grid-column: 1 / -1;
    grid-row: 3;
  }
}
