.footer-loupe-stage {
  --dial: #111111;
  --dial-dark: #030303;
  --lens-size: 160px;
  --dial-size: 220px;
}

.zoom-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 8px;
  color: #4f4a45;
  background: rgba(245, 244, 242, 0.52);
  border: 2px dashed rgba(72, 67, 62, 0.68);
  border-radius: 10px;
  cursor: pointer;
  font: 600 31px/1 "Comic Sans MS", "Bradley Hand", cursive;
  letter-spacing: -0.02em;
}

.zoom-toggle:focus-visible,
.loupe-trigger:focus-visible {
  outline: 2px dashed #4f4a45;
  outline-offset: 8px;
}

.zoom-icon {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 4px solid currentColor;
  border-radius: 50%;
}

.zoom-icon::before,
.zoom-icon::after {
  position: absolute;
  content: "";
  background: currentColor;
}

.zoom-icon::before {
  left: 50%;
  top: 6px;
  width: 4px;
  height: 13px;
  transform: translateX(-50%);
}

.zoom-icon::after {
  left: 6px;
  top: 50%;
  width: 13px;
  height: 4px;
  transform: translateY(-50%);
  box-shadow: 19px 19px 0 -1px currentColor;
}

.loupe {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  width: var(--dial-size);
  height: var(--dial-size);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.28),
    0 8px 16px -4px rgba(0, 0, 0, 0.24),
    0 20px 40px -8px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(0, 0, 0, 0.06);
  transform: translate3d(var(--loupe-x), var(--loupe-y), 0) translate(-50%, -50%);
  will-change: transform;
  transition: opacity 160ms ease;
  contain: layout style;
}

.loupe::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  content: "";
  border-radius: inherit;
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.48) 0 0.55deg, transparent 0.55deg 3deg),
    radial-gradient(circle, transparent 0 37%, rgba(255, 255, 255, 0.16) 37.4% 39%, transparent 39.5% 100%),
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.16), transparent 34%),
    radial-gradient(circle, transparent 0 72%, rgba(255, 255, 255, 0.08) 72.5%, rgba(0, 0, 0, 0.55) 76%, transparent 78%),
    linear-gradient(145deg, #1c1c1c 0%, #070707 44%, #000 100%);
  box-shadow:
    inset 0 18px 20px rgba(255, 255, 255, 0.08),
    inset 0 -22px 28px rgba(0, 0, 0, 0.62),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 0 20px rgba(0, 0, 0, 0.72);
  transform: rotate(var(--dial-rotation));
  -webkit-mask: radial-gradient(circle, transparent 0 37%, #000 37.5% 100%);
  mask: radial-gradient(circle, transparent 0 37%, #000 37.5% 100%);
}

.loupe::after {
  position: absolute;
  inset: 10%;
  z-index: 2;
  content: "";
  border-radius: inherit;
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.5),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.06),
    0 0 0 0.5px rgba(0, 0, 0, 0.3),
    0 0.5px 0 rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.loupe.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate3d(var(--loupe-x), var(--loupe-y), 0) translate(-50%, -50%) scale(0.88);
}

.loupe.is-maxed {
  animation: loupe-max-bounce 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes loupe-max-bounce {
  0% {
    transform: translate3d(var(--loupe-x), var(--loupe-y), 0) translate(-50%, -50%) scale(1);
  }

  38% {
    transform: translate3d(var(--loupe-x), var(--loupe-y), 0) translate(-50%, -50%) scale(0.965);
  }

  72% {
    transform: translate3d(var(--loupe-x), var(--loupe-y), 0) translate(-50%, -50%) scale(1.018);
  }

  100% {
    transform: translate3d(var(--loupe-x), var(--loupe-y), 0) translate(-50%, -50%) scale(1);
  }
}

.loupe-trigger {
  position: absolute;
  z-index: 3;
  width: var(--lens-size);
  height: var(--lens-size);
  overflow: hidden;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  box-shadow:
    inset 0 5px 10px rgba(255, 255, 255, 0.26),
    inset 0 -9px 18px rgba(0, 0, 0, 0.38),
    inset 0 0 0 4px rgba(255, 255, 255, 0.13),
    inset 0 0 9px 5px rgba(0, 0, 0, 0.3),
    inset 0 0 34px rgba(0, 0, 0, 0.33),
    0 1px 0 rgba(255, 255, 255, 0.12),
    0 12px 28px rgba(26, 24, 22, 0.16);
}

.loupe-trigger[data-dragging="true"] {
  cursor: grabbing;
}

.loupe-lens {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.54), rgba(235, 233, 228, 0.38) 48%, rgba(181, 176, 168, 0.45) 100%),
    rgb(245, 244, 242);
  isolation: isolate;
}

.loupe-lens::before {
  position: absolute;
  inset: 7px;
  z-index: 4;
  content: "";
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 50%, transparent 54%, rgba(255, 72, 93, 0.14) 56%, transparent 58.5%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(79, 226, 255, 0.16) 60%, transparent 62.5%),
    radial-gradient(circle at 50% 50%, transparent 62%, rgba(245, 222, 91, 0.12) 63.4%, transparent 65.5%),
    radial-gradient(ellipse 88% 11% at 50% 16%, rgba(255, 82, 104, 0.11), transparent 58%),
    radial-gradient(ellipse 88% 11% at 50% 18.5%, rgba(79, 226, 255, 0.11), transparent 58%),
    radial-gradient(ellipse 11% 88% at 16% 50%, rgba(255, 82, 104, 0.11), transparent 58%),
    radial-gradient(ellipse 11% 88% at 18.5% 50%, rgba(79, 226, 255, 0.1), transparent 58%),
    radial-gradient(ellipse 11% 88% at 84% 50%, rgba(79, 226, 255, 0.1), transparent 58%),
    radial-gradient(ellipse 11% 88% at 81.5% 50%, rgba(255, 82, 104, 0.1), transparent 58%);
  mix-blend-mode: screen;
  opacity: 0.72;
  pointer-events: none;
}

.loupe-lens::after {
  position: absolute;
  inset: 0;
  z-index: 5;
  content: "";
  border-radius: inherit;
  background:
    radial-gradient(circle at 36% 24%, rgba(255, 255, 255, 0.44), transparent 18%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15), transparent 36%),
    radial-gradient(circle at 50% 50%, transparent 48%, rgba(255, 255, 255, 0.22) 58%, transparent 64%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(42, 38, 35, 0.18) 78%, rgba(0, 0, 0, 0.34) 100%);
  box-shadow:
    inset 0 0 18px rgba(255, 255, 255, 0.18),
    inset 0 0 26px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.loupe-filter-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Page clone magnifier */
.loupe-page-clone-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  z-index: 1;
  background: rgba(242, 240, 236, 0.18);
  filter: saturate(0.9) contrast(0.96);
}

.loupe-page-clone {
  position: absolute;
  left: 0;
  top: 0;
  width: 100vw;
  min-height: 100%;
  transform-origin: 0 0;
  pointer-events: none;
  user-select: none;
  will-change: transform;
}

.loupe-page-clone--main {
  filter: url("#loupe-concave-filter") blur(0.05px);
  opacity: 0.82;
}

.loupe-page-clone--cyan,
.loupe-page-clone--magenta {
  z-index: 2;
  opacity: 0.2;
  mix-blend-mode: screen;
  filter: url("#loupe-concave-filter") saturate(1.2);
  -webkit-mask: radial-gradient(circle, transparent 0 57%, rgba(0, 0, 0, 0.04) 62%, #000 78%, transparent 98%);
  mask: radial-gradient(circle, transparent 0 57%, rgba(0, 0, 0, 0.04) 62%, #000 78%, transparent 98%);
}

.loupe-page-clone--cyan {
  filter: url("#loupe-concave-filter") sepia(1) saturate(4) hue-rotate(135deg);
}

.loupe-page-clone--magenta {
  filter: url("#loupe-concave-filter") sepia(1) saturate(3.6) hue-rotate(260deg);
}

/* Safari: feImage with data URI href is broken (WebKit bug 104169).
   Drop the SVG filter; keep the magnification + aberration. */
.loupe-no-svg-filter .loupe-page-clone--main {
  filter: blur(0.05px);
}

.loupe-no-svg-filter .loupe-page-clone--cyan,
.loupe-no-svg-filter .loupe-page-clone--magenta {
  filter: saturate(1.2);
}

.loupe-no-svg-filter .loupe-page-clone--cyan {
  filter: sepia(1) saturate(4) hue-rotate(135deg);
}

.loupe-no-svg-filter .loupe-page-clone--magenta {
  filter: sepia(1) saturate(3.6) hue-rotate(260deg);
}

.loupe-page-clone .footer-loupe-mount,
.loupe-page-clone .loupe,
.loupe-page-clone [data-footer-loupe] {
  display: none !important;
}

.loupe-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  display: block;
  opacity: 0.42;
  mix-blend-mode: normal;
  pointer-events: none;
  image-rendering: pixelated;
}

.dial-control {
  position: absolute;
  inset: -15px;
  z-index: 2;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  -webkit-mask: radial-gradient(circle, transparent 0 67%, #000 68% 100%);
  mask: radial-gradient(circle, transparent 0 67%, #000 68% 100%);
}

.dial-control:focus-visible {
  outline: 2px dashed rgba(78, 73, 68, 0.7);
  outline-offset: 17px;
}

.loupe-dial {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: var(--dial-size);
  height: var(--dial-size);
  overflow: visible;
  pointer-events: none;
  transform: rotate(var(--dial-rotation));
}

.dial-graphics {
  transform-origin: 50% 50%;
}

.loupe-dial circle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.36);
  stroke-width: 1.2;
}

.loupe-dial > circle:first-of-type {
  stroke: rgba(0, 0, 0, 0.72);
  stroke-width: 3;
}

.dial-outer {
  fill: none;
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 1;
}

.dial-inner-shadow {
  fill: none;
  stroke: rgba(0, 0, 0, 0.52);
  stroke-width: 12;
  filter: blur(2px);
}

.dial-inner-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.58);
  stroke-width: 1;
}

.loupe-dial text {
  fill: rgba(255, 255, 255, 0.72);
  font: 9px/1 Arial, sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .footer-loupe-stage {
    --lens-size: 120px;
    --dial-size: 170px;
  }

  .footer-loupe-mount {
    width: 100%;
    height: 100%;
  }

  .loupe-dial {
    inset: 0;
    width: var(--dial-size);
    height: var(--dial-size);
  }
}

.footer-loupe-mount {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.footer-loupe-stage {
  position: relative;
  display: grid;
  min-height: 100%;
  overflow: visible;
  place-items: end;
  background: transparent;
  pointer-events: none;
}

.footer-loupe-stage .stamp-card {
  min-height: 100%;
  justify-items: end;
  align-content: center;
}

.footer-loupe-stage .zoom-toggle {
  display: none;
}

.footer-loupe-stage .loupe {
  position: absolute;
  z-index: 70;
  pointer-events: auto;
}
