/**
 * @file
 * Pepernoot Hunt: hidden pepernoten and the popup they open.
 */

/* ---------- Pepernoot ---------- */

.pepernoot-hunt__trigger {
  position: absolute;
  z-index: 500;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 3px 5px rgb(0 0 0 / 0.3));
  /* Every pepernoot lies a bit differently. */
  rotate: var(--pepernoot-rotation, 0deg);
  transition: transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.pepernoot-hunt__trigger[hidden] {
  display: none;
}

.pepernoot-hunt__trigger img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pepernoot-hunt__trigger--visible {
  animation: pepernoot-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.pepernoot-hunt__trigger:hover,
.pepernoot-hunt__trigger:focus-visible {
  transform: scale(1.2) rotate(-8deg);
  animation: pepernoot-wiggle 0.6s ease-in-out;
}

.pepernoot-hunt__trigger:focus-visible {
  outline: 3px solid var(--blue, #1a73e8);
  outline-offset: 4px;
}

@keyframes pepernoot-pop {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-40deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pepernoot-wiggle {
  0%,
  100% {
    transform: scale(1.2) rotate(-8deg);
  }
  25% {
    transform: scale(1.2) rotate(8deg);
  }
  50% {
    transform: scale(1.2) rotate(-8deg);
  }
  75% {
    transform: scale(1.2) rotate(6deg);
  }
}

/* ---------- Popup ---------- */

html.pepernoot-hunt-open {
  overflow: hidden;
}

.pepernoot-hunt__dialog {
  width: min(92vw, 520px);
  max-height: 90vh;
  max-height: 90dvh;
  padding: 0;
  border: 0;
  border-radius: var(--border-radius, 8px);
  background: var(--white, #fff);
  color: var(--text-color, #222);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.4);
  overflow: hidden;
}

.pepernoot-hunt__dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.pepernoot-hunt__dialog[open] {
  animation: pepernoot-dialog-in 0.25s ease-out;
}

@keyframes pepernoot-dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.pepernoot-hunt__panel {
  position: relative;
  max-height: 90vh;
  max-height: 90dvh;
  padding: 48px 32px 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.pepernoot-hunt__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.pepernoot-hunt__close:hover {
  background: rgb(0 0 0 / 0.08);
}

.pepernoot-hunt__close:focus-visible {
  outline: 3px solid var(--blue, #1a73e8);
  outline-offset: 2px;
}

.pepernoot-hunt__title {
  margin: 0 0 12px;
  padding-right: 24px;
  color: var(--site-base-color, inherit);
  font-size: 1.5em;
  line-height: 1.25;
  /* The theme hyphenates; "pe-pernoot" in a title looks wrong. */
  hyphens: none;
  overflow-wrap: break-word;
}

.pepernoot-hunt__title:focus {
  outline: none;
}

.pepernoot-hunt__intro {
  margin-bottom: 24px;
  white-space: pre-line;
}

.pepernoot-hunt__link {
  display: inline-block;
  padding: 14px 28px;
  border: 1px solid var(--site-base-color, #023047);
  border-radius: var(--border-radius, 8px);
  background: var(--site-base-color, #023047);
  color: var(--btn-text-color, #fff);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background 0.3s ease, color 0.3s ease;
}

.pepernoot-hunt__link:hover,
.pepernoot-hunt__link:focus-visible {
  border-color: var(--hover-color, #d7eb6e);
  background: var(--hover-color, #d7eb6e);
  color: var(--black, #000);
}

.pepernoot-hunt__link:focus-visible {
  outline: 3px solid var(--blue, #1a73e8);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .pepernoot-hunt__dialog {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .pepernoot-hunt__panel {
    max-height: 100dvh;
    padding: 48px 20px 24px;
  }

  .pepernoot-hunt__link {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pepernoot-hunt__trigger,
  .pepernoot-hunt__trigger--visible,
  .pepernoot-hunt__trigger:hover,
  .pepernoot-hunt__trigger:focus-visible,
  .pepernoot-hunt__dialog[open] {
    animation: none;
    transition: none;
  }

  .pepernoot-hunt__trigger:hover,
  .pepernoot-hunt__trigger:focus-visible {
    transform: scale(1.1);
  }
}
