/* ────────────────────────────────────────────
 * DIMP 3D Image Morph Presenter — Frontend CSS
 * Isolated scope: all selectors prefixed .dimp-
 * ──────────────────────────────────────────── */

/* ── Widget Container ── */
.dimp-widget {
  position: relative;
  display:  block;
  width:    100%;
  height:   100vh;
  overflow: hidden;
  background: #0a0a0f;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.dimp-canvas {
  display: block;
  width:   100% !important;
  height:  100% !important;
  outline: none;
}

/* ── Loading Spinner ── */
.dimp-loading {
  position: absolute;
  inset:    0;
  display:  flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  gap: 1rem;
  pointer-events: none;
  z-index: 5;
}

.dimp-loading-spinner {
  width:  40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.7);
  border-radius: 50%;
  animation: dimp-spin 0.8s linear infinite;
}

@keyframes dimp-spin {
  to { transform: rotate(360deg); }
}

/* ── Controls ── */
.dimp-controls {
  position: absolute;
  bottom:   1.5rem;
  left:     50%;
  transform: translateX(-50%);
  display:  flex;
  gap:      0.75rem;
  z-index:  10;
  opacity:  0;
  transition: opacity 0.3s;
}

.dimp-widget:hover .dimp-controls,
.dimp-widget:focus-within .dimp-controls {
  opacity: 1;
}

.dimp-btn {
  background: rgba(255,255,255,0.12);
  border:     1px solid rgba(255,255,255,0.2);
  color:      #fff;
  padding:    0.5rem 1rem;
  border-radius: 999px;
  cursor:     pointer;
  font-size:  0.85rem;
  backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.dimp-btn:hover {
  background: rgba(255,255,255,0.22);
  transform:  scale(1.05);
}

.dimp-btn:active {
  transform: scale(0.96);
}

/* ── Body Indicator ── */
.dimp-body-indicator {
  position: absolute;
  top:      1.25rem;
  left:     50%;
  transform: translateX(-50%);
  color:    rgba(255,255,255,0.5);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  z-index:  10;
}

/* ── Fallback Gallery ── */
.dimp-fallback {
  position: absolute;
  inset:    0;
  overflow: auto;
  display:  flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:  2rem;
  background: #111;
  color:    #ccc;
  z-index:  20;
}

.dimp-fallback-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.dimp-fallback-figure {
  margin: 0;
  width:  180px;
}

.dimp-fallback-figure img {
  width:  100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.dimp-fallback-figure figcaption {
  font-size: 0.75rem;
  margin-top: 0.4rem;
  color: rgba(255,255,255,0.6);
  text-align: center;
}

/* ── Lightbox ── */
.dimp-lightbox {
  position: fixed;
  inset:    0;
  z-index:  999999;
  display:  flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity:  0;
  transition: opacity 0.3s;
}

.dimp-lightbox--visible {
  opacity:  1;
  pointer-events: all;
}

.dimp-lightbox--hidden {
  opacity:  0;
  pointer-events: none;
}

.dimp-lightbox-overlay {
  position: absolute;
  inset:    0;
  background: rgba(0,0,0, var(--overlay-opacity, 0.85));
  backdrop-filter: blur(4px);
}

.dimp-lightbox-content {
  position: relative;
  z-index:  1;
  max-width:  92vw;
  max-height: 90vh;
  display:  flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.dimp-lightbox-image-wrap {
  display:  flex;
  align-items: center;
  justify-content: center;
  max-height: 80vh;
  overflow: hidden;
  border-radius: 6px;
}

.dimp-lightbox-img {
  max-width:  90vw;
  max-height: 78vh;
  object-fit: contain;
  display:  block;
  border-radius: 4px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
}

.dimp-lightbox-close {
  position: absolute;
  top:   -2.5rem;
  right: -0.5rem;
  background: rgba(255,255,255,0.1);
  border:     1px solid rgba(255,255,255,0.25);
  color:  #fff;
  width:  2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.dimp-lightbox-close:hover {
  background: rgba(255,255,255,0.25);
}

.dimp-lightbox-caption {
  text-align:  center;
  color:       rgba(255,255,255,0.85);
  max-width:   600px;
  display:     flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dimp-lightbox-title {
  font-size:   1rem;
  font-weight: 600;
}

.dimp-lightbox-desc {
  font-size:   0.85rem;
  color:       rgba(255,255,255,0.6);
}

/* ── Lightbox Animations ── */
.dimp-lb-anim-zoom .dimp-lightbox-content {
  animation: dimp-zoom-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.dimp-lb-anim-fade .dimp-lightbox-content {
  animation: dimp-fade-in 0.3s ease;
}

.dimp-lb-anim-slide .dimp-lightbox-content {
  animation: dimp-slide-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dimp-zoom-in {
  from { transform: scale(0.75); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

@keyframes dimp-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes dimp-slide-in {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .dimp-widget { height: 70vh; }
}

@media (max-width: 767px) {
  .dimp-widget { height: 50vh; touch-action: none; }
  .dimp-controls { bottom: 1rem; }
  .dimp-lightbox-img { max-width: 95vw; max-height: 70vh; }
  .dimp-lightbox-close { top: -3rem; right: 0; }
}

/* ── Label position variants (set via JS data-label-position) ── */
.dimp-widget[data-label-pos="top-left"]      .dimp-body-indicator { top:1.25rem; left:1.25rem; right:auto; transform:none; }
.dimp-widget[data-label-pos="top-center"]    .dimp-body-indicator { top:1.25rem; left:50%; right:auto; transform:translateX(-50%); }
.dimp-widget[data-label-pos="top-right"]     .dimp-body-indicator { top:1.25rem; right:1.25rem; left:auto; transform:none; }
.dimp-widget[data-label-pos="bottom-left"]   .dimp-body-indicator { bottom:1.25rem; top:auto; left:1.25rem; right:auto; transform:none; }
.dimp-widget[data-label-pos="bottom-center"] .dimp-body-indicator { bottom:1.25rem; top:auto; left:50%; right:auto; transform:translateX(-50%); }
.dimp-widget[data-label-pos="bottom-right"]  .dimp-body-indicator { bottom:1.25rem; top:auto; right:1.25rem; left:auto; transform:none; }
