/* ===================================================
   GooeyNav — vanilla JS/CSS port of React Bits' GooeyNav
   Source: https://reactbits.dev/components/gooey-nav
   Colors adapted to the Cervera Premium palette (light header bg).
   =================================================== */

.gooey-nav-container {
  --color-1: var(--gold-400, #e0bd4a);
  --color-2: var(--olive-400, #a3b823);
  --color-3: var(--olive-700, #4d5f12);
  --color-4: var(--gold-600, #a8811f);
  position: relative;
}

.gooey-nav-container nav {
  display: flex;
  position: relative;
  /* z-index:2 so the real pill/text always paints above the .effect glow layer
     (z-index:1). The original demo uses white-on-white for both layers so the
     stacking order is invisible there; our olive pill needs to stay on top. */
  z-index: 2;
  transform: translate3d(0, 0, 0.01px);
}

.gooey-nav-container nav ul {
  display: flex;
  gap: 0.1em;
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  z-index: 3;
  color: var(--ink-700, #3c3d24);
}

.gooey-nav-container nav ul li {
  border-radius: 100vw;
  position: relative;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
  box-shadow: 0 0 0.5px 1.5px transparent;
  color: var(--ink-700, #3c3d24);
}

.gooey-nav-container nav ul li a {
  display: inline-block;
  padding: 0.6em 1.1em;
  color: inherit;
  text-decoration: none;
}

.gooey-nav-container nav ul li:focus-within:has(:focus-visible) {
  box-shadow: 0 0 0.5px 1.5px var(--olive-700, #4d5f12);
}

.gooey-nav-container nav ul li::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 100vw;
  background: var(--olive-700, #4d5f12);
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
  z-index: -1;
}

.gooey-nav-container nav ul li.active {
  color: var(--cream-50, #fdfcf6);
}

.gooey-nav-container nav ul li.active::after {
  opacity: 1;
  transform: scale(1);
}

.gooey-nav-container .effect {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  opacity: 1;
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 1;
}

.gooey-nav-container .effect.text {
  color: var(--ink-700, #3c3d24);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.gooey-nav-container .effect.text.active {
  color: var(--cream-50, #fdfcf6);
}

.gooey-nav-container .effect.filter {
  /* blur+contrast merges the blurred particle blobs into a crisp "gooey" silhouette;
     mix-blend-mode: lighten then makes the black ::before backdrop disappear against
     the real page behind it. Keep black/white/lighten here regardless of theme —
     recoloring these breaks the contrast trick (particle colors are themed via --color-N instead). */
  filter: blur(7px) contrast(100) blur(0);
  mix-blend-mode: lighten;
}

.gooey-nav-container .effect.filter::before {
  content: '';
  position: absolute;
  /* Original React Bits demo uses -75px inside a spacious 600px canvas.
     Our header is a slim ~79px fixed bar with its own stacking context, so
     anything from this blend-mode group that paints past the header's edge
     loses its backdrop and shows up as a literal black smudge. Keep this
     (and the particle physics in the JS init options) inside the header. */
  inset: -16px;
  z-index: -2;
  background: black;
}

.gooey-nav-container .effect.filter::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  transform: scale(0);
  opacity: 0;
  z-index: -1;
  border-radius: 100vw;
}

.gooey-nav-container .effect.active::after {
  animation: gooey-pill 0.3s ease both;
}

@keyframes gooey-pill {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.gooey-nav-container .particle,
.gooey-nav-container .point {
  display: block;
  opacity: 0;
  width: 12px;
  height: 12px;
  border-radius: 100%;
  transform-origin: center;
}

.gooey-nav-container .particle {
  --time: 5s;
  position: absolute;
  top: calc(50% - 6px);
  left: calc(50% - 6px);
  animation: gooey-particle calc(var(--time)) ease 1 -350ms;
}

.gooey-nav-container .point {
  background: var(--color);
  opacity: 1;
  animation: gooey-point calc(var(--time)) ease 1 -350ms;
}

@keyframes gooey-particle {
  0% {
    transform: rotate(0deg) translate(calc(var(--start-x)), calc(var(--start-y)));
    opacity: 1;
    animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
  }

  70% {
    transform: rotate(calc(var(--rotate) * 0.5)) translate(calc(var(--end-x) * 1.2), calc(var(--end-y) * 1.2));
    opacity: 1;
    animation-timing-function: ease;
  }

  85% {
    transform: rotate(calc(var(--rotate) * 0.66)) translate(calc(var(--end-x)), calc(var(--end-y)));
    opacity: 1;
  }

  100% {
    transform: rotate(calc(var(--rotate) * 1.2)) translate(calc(var(--end-x) * 0.5), calc(var(--end-y) * 0.5));
    opacity: 1;
  }
}

@keyframes gooey-point {
  0% {
    transform: scale(0);
    opacity: 0;
    animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
  }

  25% {
    transform: scale(calc(var(--scale) * 0.25));
  }

  38% {
    opacity: 1;
  }

  65% {
    transform: scale(var(--scale));
    opacity: 1;
    animation-timing-function: ease;
  }

  85% {
    transform: scale(var(--scale));
    opacity: 1;
  }

  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* ---------- Mobile: stack vertically inside the existing dropdown ---------- */
@media (max-width: 760px) {
  .gooey-nav-container,
  .gooey-nav-container nav {
    width: 100%;
  }
  .gooey-nav-container nav ul {
    flex-direction: column;
    gap: 0.25em;
    width: 100%;
  }
  .gooey-nav-container nav ul li a {
    display: block;
    width: 100%;
    padding: 0.9em 1.1em;
  }
  .gooey-nav-container .effect.filter,
  .gooey-nav-container .effect.text {
    display: none; /* particle/blob effect only makes sense in a single-row layout */
  }
}
