/**
 * Zoom on Hover — custom CSS (no third-party dependency).
 */

/* ─── Container ──────────────────────────────────────────────────────────── */
.zoom-container {
  position: relative;
  display: inline-block;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
  line-height: 0; /* collapse whitespace below img */
}

.zoom-container img.zoom-image {
  display: block;
  max-width: 100%;
  height: auto;
  -webkit-transition: none !important;
  transition: none !important;
}

/* ─── Lens (shared by circle + inside modes) ─────────────────────────────── */
.zoom-lens {
  position: absolute;
  z-index: 100;
  top: 0;
  left: 0;
  display: none;
  box-sizing: border-box;
  /* GPU layer for smooth 60fps movement */
  transform: translate3d(0, 0, 0);
  pointer-events: none;
  will-change: transform;
}

/* Box/inside lens */
.zoom-lens--box {
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(0, 0, 0, 0.1),
    0 4px 16px rgba(0, 0, 0, 0.2);
  /* Frosted-glass effect where supported */
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
}

/* Circle / magnifier lens — uses box-shadow to darken everything outside */
.zoom-lens--circle {
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background-repeat: no-repeat;
  box-shadow:
    0 0 0 2000px rgba(0, 0, 0, 0.35),
    0 4px 20px rgba(0, 0, 0, 0.4),
    inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Inside (rectangular magnifier) lens shows the zoomed bg itself */
.zoom-lens--inside {
  overflow: hidden;
  cursor: none;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background-repeat: no-repeat;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ─── Preview panel (box mode) ───────────────────────────────────────────── */
.zoom-preview {
  position: fixed; /* repositioned via JS using getBoundingClientRect */
  z-index: 9999;
  display: none;
  overflow: hidden;
  box-sizing: border-box;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: #111;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.3);
  will-change: transform;
}

/* Inner background div that moves to simulate panning */
.zoom-preview__bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  will-change: background-position, background-size;
}

/* Tint overlay */
.zoom-tint {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  inset: 0;
}

/* Caption strip */
.zoom-caption {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 8px 12px;
  pointer-events: none;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.75rem;
  line-height: 1.4;
}

/* Zoom level badge (shown during scroll-zoom) */
.zoom-badge {
  position: absolute;
  z-index: 4;
  top: 8px;
  right: 8px;
  padding: 3px 7px;
  transition: opacity 0.3s ease;
  letter-spacing: 0.03em;
  pointer-events: none;
  opacity: 0;
  color: #fff;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.65);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
}

.zoom-badge.zoom-badge--visible {
  opacity: 1;
}

/* Loading spinner (shown while the full-res image loads) */
.zoom-loader {
  position: absolute;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: rgba(0, 0, 0, 0.5);
  inset: 0;
}

.zoom-loader__spinner {
  width: 28px;
  height: 28px;
  animation: zoom-spin 0.7s linear infinite;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
}

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

/* ─── Background mode — the image itself is the zoomed view ─────────────── */
.zoom-container--background img.zoom-image {
  transition: transform 0.1s ease !important;
}

/* ─── Fullscreen lightbox ────────────────────────────────────────────────── */
.zoom-fullscreen-overlay {
  position: fixed;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  transition: opacity 0.25s ease;
  opacity: 0;
  background: rgba(0, 0, 0, 0.92);
  inset: 0;
}

.zoom-fullscreen-overlay.zoom-fullscreen--visible {
  opacity: 1;
}

.zoom-fullscreen-overlay img {
  display: block;
  max-width: 92vw;
  max-height: 92vh;
  cursor: default;
  transition: transform 0.25s ease;
  transform: scale(0.97);
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.zoom-fullscreen-overlay.zoom-fullscreen--visible img {
  transform: scale(1);
}

.zoom-fullscreen__close {
  position: fixed;
  z-index: 100000;
  top: 16px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.25rem;
  line-height: 1;
}

.zoom-fullscreen__close:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.25);
}

.zoom-fullscreen__caption {
  position: fixed;
  z-index: 100000;
  bottom: 24px;
  left: 50%;
  max-width: 80vw;
  padding: 6px 16px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.5);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.85rem;
}

/* ─── Hint tooltip shown briefly on first hover ──────────────────────────── */
.zoom-hint {
  position: absolute;
  z-index: 200;
  bottom: calc(100% + 8px);
  left: 50%;
  padding: 4px 10px;
  transition: opacity 0.3s ease;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  color: #fff;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.75);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.7rem;
}

.zoom-hint::after {
  position: absolute;
  top: 100%;
  left: 50%;
  content: "";
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.75);
}

.zoom-hint--visible {
  opacity: 1;
}

/* ─── Responsive — disable external preview on very small screens ────────── */
@media (max-width: 480px) {
  .zoom-preview {
    display: none !important;
  }
  .zoom-lens--box {
    display: none !important;
  }
}
