/**
 * Parameter Image Hotspot
 * Replaces: dipi/image-hotspot + dipi/image-hotspot-child
 */

@keyframes param-tooltip-in {
  from { opacity: 0; translate: 0 8px; }
  to   { opacity: 1; translate: 0 0; }
}

@keyframes param-hotspot-pulse {
  0%   { box-shadow: 0 0 0 0    rgba(12, 239, 181, 0.3), 0 0 0 0    rgba(12, 239, 181, 0.3); }
  33%  { box-shadow: 0 0 0 15px rgba(12, 239, 181, 0),   0 0 0 0    rgba(12, 239, 181, 0.5); }
  66%  { box-shadow: 0 0 0 10px rgba(12, 239, 181, 0),   0 0 0 10px rgba(12, 239, 181, 0); }
  100% { box-shadow: 0 0 0 0    rgba(12, 239, 181, 0),   0 0 0 15px rgba(12, 239, 181, 0); }
}

/* ── Wrapper ── */
.param-hotspot-wrap {
  --color-primary:      #00c59e;
  --color-primary-glow: rgba(0, 197, 158, 0.64);
  --color-primary-ring: rgba(0, 197, 158, 0.42);
  --dot-size:           35px;
  --tooltip-width:      650px;
  --tooltip-img-size:   250px;

  position: relative;
  display: block;
  width: 100%;
  line-height: 0;

  img.param-hotspot-bg {
    width: 100%;
    height: auto;
    display: block;
  }
}

/* ── Hotspot Item ── */
.param-hotspot-item {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 10;

  &.is-active {
    z-index: 200;

    .param-hotspot-tooltip {
      display: flex;
      align-items: center;
      gap: 16px;
      pointer-events: auto;
      animation: param-tooltip-in 0.2s ease-out forwards;
    }
  }
}

/* ── Dot ── */
.param-hotspot-dot {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--dot-size);
  height: var(--dot-size);
  background-color: var(--color-primary);
  border-radius: 100%;
  border: 3px solid var(--color-primary-ring);
  cursor: pointer;
  animation: param-hotspot-pulse 3s linear infinite;
  color: #fff;
  font-size: calc(var(--dot-size) * 0.8);
  line-height: 1;
  user-select: none;

  &::before {
    content: 'p';
    font-family: 'ETmodules';
    font-weight: 400;
  }
}

/* ── Tooltip ── */
.param-hotspot-tooltip {
  position: absolute;
  width: var(--tooltip-width);
  background-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  border: 2px solid rgba(255, 255, 255, 0.31);
  border-radius: 150px 10px 10px 150px;
  box-shadow: 3px 3px 8px 0 rgba(0, 0, 0, 0.17), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  padding: 10px;
  display: none;
  z-index: 100;
  line-height: 1.4;
  text-align: left;
  pointer-events: none;

  &.param-tooltip-right  { left: calc(100% + 15px);   top: 50%; transform: translateY(-50%); }
  &.param-tooltip-left   { right: calc(100% + 15px);  top: 50%; transform: translateY(-50%); }
  &.param-tooltip-top    { bottom: calc(100% + 15px); left: 50%; transform: translateX(-50%); }
  &.param-tooltip-bottom { top: calc(100% + 15px);    left: 50%; transform: translateX(-50%); }

  .param-tooltip-image {
    flex: 0 0 auto;
    line-height: 0;
    width: var(--tooltip-img-size);
    height: var(--tooltip-img-size);
    border-radius: 50%;
    border: 3px solid var(--color-primary);
    box-shadow: 0 2px 30px 4px var(--color-primary-glow);

    img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      clip-path: circle(47% at 50% 50%);
    }
  }

  .param-tooltip-body {
    flex: 1 1 auto;
    min-width: 0;
  }

  .param-tooltip-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 4px !important;
    line-height: 1.4em !important;
    margin: 0 0 6px 0 !important;
    color: #0d151f !important;
  }

  .param-tooltip-desc {
    font-size: 12px;
    line-height: 1.4em;
    color: #333;

    hr {
      margin: 4px 0 8px;
      border: none;
      border-top: 2px solid var(--color-primary);
    }

    p { margin: 0; }

    .param-value { color: var(--color-primary); }
  }
}

/* ── Compact (no image) ── */
.param-tooltip-compact {
  width: calc(var(--tooltip-width) / 2);
  border-radius: 14px;

  .param-tooltip-desc {
    font-size: 18px;
  }
}

/* ── Sonar rings (opt-in via data['sonar'] => true) ── */
@keyframes param-sonar-ring {
  0%   { transform: scale(0) translate(-50%, -50%); opacity: 0; }
  50%  { transform: scale(1.5) translate(-50%, -50%); opacity: 0.5; }
  100% { transform: scale(3) translate(-50%, -50%); opacity: 0; }
}

.param-hotspot-sonar {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}

.param-sonar-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--color-primary);
  opacity: 0;
  transform-origin: 0 0;
  animation: param-sonar-ring 1.8s linear infinite;

  &:nth-child(2) { animation-delay: 0.6s; }
  &:nth-child(3) { animation-delay: 1.2s; }
  &:nth-child(4) { animation-delay: 1.8s; }
}

/* ── Per-graphic icon overrides ── */
.param-icon-circle .param-hotspot-dot {
  background-color: rgba(255, 255, 255, 0.28);

  &::before {
    content: '[';
  }
}

/* ── Responsive ── */
@media (max-width: 980px) {
  .param-hotspot-wrap {
    --tooltip-width:    420px;
    --tooltip-img-size: 150px;
  }
}

@media (max-width: 767px) {
  .param-hotspot-wrap {
    --tooltip-width:    260px;
    --tooltip-img-size: 100px;
    --dot-size:         25px;
  }

  .param-hotspot-tooltip {
    flex-direction: column;
    border-radius: 20px;
    gap: 10px;
  }

  .param-tooltip-title {
    font-size: 14px !important;
    letter-spacing: 2px !important;
  }

  /* Remove transform from item so position:fixed children can escape to the viewport.
     Compensate dot centering with negative margins (same visual result, no stacking context). */
  .param-hotspot-item {
    transform: none;
    margin-left: calc(var(--dot-size) / -2);
    margin-top: calc(var(--dot-size) / -2);
  }

  /* All directions: fixed bottom-center card — avoids edge overflow on small screens.
     Note: touch tap interaction needs a JS pass (open issue). */
  .param-hotspot-wrap .param-hotspot-tooltip {
    position: fixed;
    bottom: 16px;
    top: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    z-index: 9999;
  }
}
