/**
 * PM Media — Liquid Glass buttons (21st.dev look · recreate · $0)
 * Specular tracks finger/cursor · spring press · touch ripple
 * Chromium: SVG refraction filter · others: blur+saturate fallback
 */

/* Shared SVG filter host (injected once) */
.pm-lg-svg {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.btn.pm-liquid,
a.btn.pm-liquid,
button.btn.pm-liquid {
  --lg-x: 50%;
  --lg-y: 50%;
  --lg-press: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transform: translate3d(0, 0, 0) scale(calc(1 - var(--lg-press) * 0.045));
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s ease,
    filter 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  will-change: transform;
}

/* Frosted plate */
.btn.pm-liquid {
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 8px 28px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 212, 238, 0.08) !important;
  -webkit-backdrop-filter: blur(18px) saturate(1.65);
  backdrop-filter: blur(18px) saturate(1.65);
}

@supports ((-webkit-backdrop-filter: url(#pm-liquid-glass)) or (backdrop-filter: url(#pm-liquid-glass))) {
  html.pm-lg-refract .btn.pm-liquid {
    -webkit-backdrop-filter: url(#pm-liquid-glass) blur(14px) saturate(1.7);
    backdrop-filter: url(#pm-liquid-glass) blur(14px) saturate(1.7);
  }
}

.btn.pm-liquid.btn-primary {
  background-color: transparent !important;
  background-image:
    radial-gradient(
      circle 130px at var(--lg-x) var(--lg-y),
      rgba(255, 255, 255, 0.38) 0%,
      rgba(255, 255, 255, 0.08) 32%,
      transparent 62%
    ),
    linear-gradient(
      135deg,
      rgba(0, 200, 232, 0.78) 0%,
      rgba(232, 50, 138, 0.74) 100%
    ) !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 10px 36px rgba(232, 50, 138, 0.32),
    0 6px 20px rgba(0, 212, 238, 0.22),
    0 0 40px rgba(0, 212, 238, 0.12) !important;
}

.btn.pm-liquid.btn-outline {
  background-color: rgba(8, 14, 28, 0.42) !important;
  background-image:
    radial-gradient(
      circle 120px at var(--lg-x) var(--lg-y),
      rgba(255, 255, 255, 0.28) 0%,
      rgba(0, 212, 238, 0.12) 35%,
      transparent 62%
    ) !important;
  color: #e8fbff !important;
  border-color: rgba(0, 212, 238, 0.45) !important;
}

.btn.pm-liquid.btn-white {
  background-color: rgba(255, 255, 255, 0.82) !important;
  background-image:
    radial-gradient(
      circle 120px at var(--lg-x) var(--lg-y),
      rgba(255, 255, 255, 0.9) 0%,
      transparent 55%
    ) !important;
  color: #0a0a14 !important;
}

/* Soft edge highlight — does not cover label (no z-index above text) */
.btn.pm-liquid::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  opacity: 0.85;
}

/* Liquid sheen sweep — blend so label stays readable */
.btn.pm-liquid::after {
  content: "";
  position: absolute;
  inset: -40% -60%;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 35%,
    rgba(255, 255, 255, 0.5) 48%,
    rgba(0, 212, 238, 0.22) 52%,
    transparent 65%
  );
  transform: translateX(-40%) rotate(8deg);
  opacity: 0;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
  mix-blend-mode: soft-light;
}

.btn.pm-liquid:hover::after,
.btn.pm-liquid.is-lg-active::after {
  opacity: 0.95;
  transform: translateX(40%) rotate(8deg);
}

.btn.pm-liquid:hover {
  transform: translate3d(0, -2px, 0) scale(calc(1.02 - var(--lg-press) * 0.05));
  filter: brightness(1.06);
}

.btn.pm-liquid:active,
.btn.pm-liquid.is-lg-pressed {
  --lg-press: 1;
  filter: brightness(0.96);
  transition-duration: 0.08s;
}

/* Touch ripple */
.pm-lg-ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(0, 212, 238, 0.25) 40%,
    transparent 70%
  );
  transform: scale(0);
  opacity: 0.9;
  animation: pm-lg-ripple 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pm-lg-ripple {
  to {
    transform: scale(18);
    opacity: 0;
  }
}

/* Header CTAs still liquid but no page-bleed (parent is opaque) */
.site-header .btn.pm-liquid {
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  backdrop-filter: blur(12px) saturate(1.4);
}

@media (prefers-reduced-motion: reduce) {
  .btn.pm-liquid,
  .btn.pm-liquid::before,
  .btn.pm-liquid::after {
    transition: none !important;
    animation: none !important;
  }
  .btn.pm-liquid::after { display: none; }
  .pm-lg-ripple { display: none; }
  html.pm-lg-refract .btn.pm-liquid {
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    backdrop-filter: blur(14px) saturate(1.4);
  }
}

@media (pointer: coarse) {
  .btn.pm-liquid {
    min-height: 48px;
  }
}
