/* modal.css — shared popup system for the landing page.

   Owns the things every popup has in common:
   overlay (darken + blur), card open/close/flip states,
   keyframes, the animated exit button and the light sweep.

   The look of each card lives in its own file:
      member-login.css · admin-login.css · register.css */

/* ==========================================================================
   Page Lock & Overlay
   ========================================================================== */

body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  /* stop above the footer so the copyright bar stays crisp, like the mock */
  inset: 0 0 var(--footer-h, 32px) 0;
  z-index: 100;
  display: flex;
  overflow-y: auto;
  padding: 1rem;
  background: rgba(2, 3, 26, 0);
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
  visibility: hidden;
  pointer-events: none;
  transition: background-color 0.35s ease,
              -webkit-backdrop-filter 0.35s ease,
              backdrop-filter 0.35s ease,
              visibility 0s linear 0.35s; /* stay visible until the fade-out ends */
}

.modal-overlay.is-open {
  background: rgba(2, 3, 26, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  visibility: visible;
  pointer-events: auto;
  transition: background-color 0.35s ease,
              -webkit-backdrop-filter 0.35s ease,
              backdrop-filter 0.35s ease,
              visibility 0s;
}

/* margin: auto centres the card and stays scroll-safe on short screens */
.modal-stage {
  margin: auto;
  perspective: 1400px; /* depth for the login <-> register flip */
}

/* ==========================================================================
   Card States
   ========================================================================== */

.modal-card {
  display: none;
  position: relative;
  width: min(390px, calc(100vw - 2rem));
  transform-origin: 50% 60%;
  backface-visibility: hidden;
}

.modal-card:focus {
  outline: none;
}

/* rising in: floats up from below and settles with a small overshoot */
.modal-card.is-active {
  display: block;
  animation: modal-rise 0.7s cubic-bezier(0.22, 0.9, 0.3, 1) backwards;
}

/* arriving from the other popup: flips in */
.modal-card.is-active.is-flip-in {
  animation: modal-flip-in 0.5s cubic-bezier(0.2, 0.9, 0.25, 1) backwards;
}

/* closing: sinks and fades */
.modal-card.is-leaving {
  display: block;
  animation: modal-sink 0.3s ease-in both;
}

/* handing over to the other popup: flips away */
.modal-card.is-flip-out {
  display: block;
  animation: modal-flip-out 0.24s ease-in both;
}

/* ==========================================================================
   No light sweep / shimmer on popups.
   Popups just appear; nothing glides across the card or the buttons.
   ========================================================================== */

.modal-card .btn-primary::before,
.modal-card .btn-social::before {
  display: none;
}

/* ==========================================================================
   Exit Button
   ========================================================================== */

.modal-close {
  position: absolute;
  top: 8px;
  right: 5px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.modal-close svg {
  position: relative;
  width: 26px;
  height: 26px;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              filter 0.25s ease;
}

/* glowing disc that expands out from the centre on hover / focus */
.modal-close::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.3);
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.38) 0%,
    rgba(255, 255, 255, 0.14) 100%
  );
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55),
              0 0 26px rgba(160, 200, 255, 0.75);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s ease;
}

.modal-close:hover::before,
.modal-close:focus-visible::before {
  opacity: 1;
  transform: scale(1);
}

.modal-close:hover svg,
.modal-close:focus-visible svg {
  transform: rotate(90deg) scale(1.15);
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.95));
}

.modal-close:active svg {
  transform: rotate(90deg) scale(0.9);
}

.modal-close:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* ==========================================================================
   Keyframes
   ========================================================================== */

@keyframes modal-rise {
  0% {
    opacity: 0;
    transform: translateY(64px) scale(0.9);
  }
  55% {
    opacity: 1;
  }
  75% {
    transform: translateY(-8px) scale(1.012);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modal-sink {
  to {
    opacity: 0;
    transform: translateY(28px) scale(0.95);
  }
}

@keyframes modal-flip-in {
  0% {
    opacity: 0;
    transform: rotateY(90deg) scale(0.96);
  }
  70% {
    opacity: 1;
    transform: rotateY(-6deg) scale(1);
  }
  100% {
    opacity: 1;
    transform: rotateY(0) scale(1);
  }
}

@keyframes modal-flip-out {
  to {
    opacity: 0;
    transform: rotateY(-90deg) scale(0.96);
  }
}

@keyframes modal-item-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Accessibility / Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .modal-card.is-active,
  .modal-card.is-active *,
  .modal-card.is-active *::before,
  .modal-card.is-active *::after {
    animation: none !important;
  }
}