/* =========================================================================
   PiggyBank Wallet Modal
   -------------------------------------------------------------------------
   The modal is injected by src/ui/domUi.js into:
       <div data-id="modal_root" class="modal-container modal-hidden"></div>
   Content comes from /modal/modal.html (no Tailwind — self contained).

   Palette (piggybankfi.webflow.shared):
     pink-900 #2b000f | pink-700 #ad003b | pink-500 #ff3077 | pink-300 #ff87b0
     pink-200 #ffd7e5 | pink-100 #fff2f6
     lila-900 #3a0061 | lila-700 #ce84ff | lila-500 #e1b5ff | lila-300 #ebcdff
     lila-200 #f4e3ff | lila-100 #fbf4ff
     blue-500 #7055ff
   Brand gradient: linear-gradient(105deg, #ce84ff, #ff3077)
   Primary font:   Bricolage Grotesque
   Secondary font: Plus Jakarta Sans
   ========================================================================= */

/* ---------- root container (fullscreen, flex-center) ---------- */

.modal-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  -webkit-overflow-scrolling: touch;
}

.modal-container::-webkit-scrollbar { display: none; }
.modal-container { scrollbar-width: none; }

.modal-hidden {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

.modal-visible {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
}

/* ---------- backdrop ---------- */

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(206, 132, 255, 0.28) 0%, rgba(43, 0, 15, 0) 60%),
    rgba(43, 0, 15, 0.72);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  cursor: pointer;
}

/* ---------- dialog wrapper ---------- */

.modal-dialog {
  position: relative;
  z-index: 1;
  width: 24rem;
  max-width: calc(100vw - 32px);
  outline: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  animation: modal-pop 0.28s cubic-bezier(0.2, 1, 0.3, 1);
}

@keyframes modal-pop {
  0%   { transform: translateY(8px) scale(0.96); opacity: 0; }
  100% { transform: translateY(0) scale(1);       opacity: 1; }
}

/* ---------- card ---------- */

.modal-card {
  position: relative;
  width: 100%;
  background:
    radial-gradient(120% 70% at 100% 0%, #ffd7e5 0%, rgba(255, 215, 229, 0) 55%),
    radial-gradient(120% 70% at 0% 100%, #f4e3ff 0%, rgba(244, 227, 255, 0) 60%),
    #ffffff;
  border: 1px solid rgba(206, 132, 255, 0.35);
  border-radius: 28px;
  box-shadow:
    0 40px 80px -20px rgba(206, 132, 255, 0.45),
    0 20px 40px -15px rgba(255, 48, 119, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
  font-family: "Bricolage Grotesque", "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  color: #2b000f;
  isolation: isolate;
}

/* ---------- decorative glows ---------- */

.modal-glow {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.75;
  z-index: 0;
}
.modal-glow-a {
  width: 220px;
  height: 220px;
  top: -80px;
  right: -60px;
  background: radial-gradient(circle, #ff3077 0%, rgba(255, 48, 119, 0) 70%);
}
.modal-glow-b {
  width: 260px;
  height: 260px;
  bottom: -100px;
  left: -80px;
  background: radial-gradient(circle, #ce84ff 0%, rgba(206, 132, 255, 0) 70%);
}

/* ---------- close button ---------- */

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(206, 132, 255, 0.35);
  color: #2b000f;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.modal-close-btn:hover {
  background: #ffffff;
  color: #ff3077;
  border-color: #ff87b0;
  transform: rotate(90deg);
}
.modal-close-btn:active {
  transform: rotate(90deg) scale(0.94);
}

/* ---------- header ---------- */

.modal-header {
  position: relative;
  z-index: 1;
  padding: 36px 28px 8px;
  text-align: center;
}

.modal-eyebrow {
  display: inline-block;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  color: #ffffff;
  background-image: linear-gradient(105deg, #ce84ff, #ff3077);
  box-shadow: 0 6px 18px rgba(255, 48, 119, 0.35);
  margin-bottom: 14px;
}

.modal-header h2 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 88%;
  letter-spacing: -0.02em;
  color: #2b000f;
  margin: 0;
}

.modal-header p {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 140%;
  color: rgba(43, 0, 15, 0.65);
  margin: 10px 0 0;
}

/* ---------- body / wallet list ---------- */

.modal-body {
  position: relative;
  z-index: 1;
  padding: 22px 20px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 56px;
  padding: 10px 48px 10px 60px;
  border-radius: 16px;
  border: 1px solid rgba(206, 132, 255, 0.35);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  color: #2b000f;
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 600;
  font-size: 0.98rem;
  text-align: left;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  box-shadow: 0 2px 6px rgba(43, 0, 15, 0.04);
}

.wallet-btn .wallet-icon-box {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.wallet-btn > span {
  flex: 1;
  text-align: left;
}

.wallet-btn .wallet-arrow {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  opacity: 0;
  color: #ff3077;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.wallet-btn:hover {
  border-color: rgba(255, 48, 119, 0.55);
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow:
    0 12px 28px -6px rgba(206, 132, 255, 0.4),
    0 4px 10px -2px rgba(255, 48, 119, 0.2);
}
.wallet-btn:hover .wallet-arrow {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.wallet-btn:active {
  transform: translateY(-1px);
}

/* selected / featured wallet — brand gradient */
.wallet-btn.wallet-option-selected {
  background-image: linear-gradient(105deg, #ce84ff, #ff3077);
  background-color: transparent;
  border-color: transparent;
  color: #ffffff;
  box-shadow:
    0 12px 30px -6px rgba(255, 48, 119, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.wallet-btn.wallet-option-selected .wallet-arrow {
  color: #ffffff;
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.wallet-btn.wallet-option-selected .wallet-icon-box {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}
.wallet-btn.wallet-option-selected:hover {
  transform: translateY(-2px);
  box-shadow:
    0 16px 36px -6px rgba(255, 48, 119, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* wallet icon wrapper */
.wallet-icon-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(206, 132, 255, 0.25);
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(43, 0, 15, 0.08);
}
.wallet-icon-box img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  display: block;
}

/* error alert reuses wallet-btn shape */
.wallet-btn.wallet-error-alert {
  cursor: default;
  padding: 14px 18px;
  min-height: auto;
  background: #fff2f6;
  border-color: #ffd7e5;
  color: #ad003b;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  justify-content: center;
  box-shadow: none;
}
.wallet-btn.wallet-error-alert:hover {
  transform: none;
  background: #fff2f6;
  border-color: #ffd7e5;
  box-shadow: none;
}

/* ---------- terms ---------- */

.modal-terms {
  position: relative;
  z-index: 1;
  padding: 14px 28px 0;
  text-align: center;
}
.modal-terms p {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.55;
  color: rgba(43, 0, 15, 0.6);
  margin: 0;
}
.modal-terms a {
  font-weight: 700;
  color: #ff3077;
  text-decoration: none;
  background-image: linear-gradient(105deg, #ce84ff, #ff3077);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: opacity 0.2s ease;
}
.modal-terms a:hover {
  opacity: 0.85;
  text-decoration: underline;
  text-decoration-color: #ff3077;
  -webkit-text-fill-color: transparent;
}

/* ---------- footer ---------- */

.modal-footer {
  position: relative;
  z-index: 1;
  margin: 18px 0 0;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(90deg, rgba(244, 227, 255, 0.6) 0%, rgba(255, 242, 246, 0.6) 100%);
  border-top: 1px solid rgba(206, 132, 255, 0.3);
}
.modal-footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-image: linear-gradient(105deg, #ce84ff, #ff3077);
  box-shadow: 0 0 10px rgba(255, 48, 119, 0.6);
  animation: modal-footer-pulse 2.2s ease-in-out infinite;
}
.modal-footer p {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(43, 0, 15, 0.7);
  margin: 0;
}
.modal-footer a {
  color: #ff3077;
  text-decoration: none;
  font-weight: 700;
}
.modal-footer a:hover {
  text-decoration: underline;
}

@keyframes modal-footer-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.85); }
}

/* ---------- wallet-adapter compatibility leftovers ---------- */

.wallet-adapter-modal-chevron {
  transition: transform 0.25s ease-out;
  margin-left: 0.5rem;
  fill: #fff;
}

.wallet-adapter-collapse {
  transition: height 250ms ease-out;
}

/* =========================================================================
   Mobile — fullscreen sheet
   On narrow screens the card fills the whole viewport (no rounding, no
   side margins) and the footer sticks to the bottom regardless of content
   height. Slide-up animation replaces the pop animation.
   ========================================================================= */

@media (max-width: 640px) {
  .modal-container {
    padding: 0;
    align-items: stretch;
    overflow: hidden;
  }

  .modal-overlay {
    background: rgba(43, 0, 15, 0.9);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .modal-dialog {
    width: 100%;
    max-width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    animation: modal-slide-up 0.32s cubic-bezier(0.2, 1, 0.3, 1);
  }

  .modal-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    min-height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  /* body fills the free space, becomes the scroll area */
  .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 22px 18px 12px;
    -webkit-overflow-scrolling: touch;
  }
  .modal-body::-webkit-scrollbar { display: none; }
  .modal-body { scrollbar-width: none; }

  /* push footer to the very bottom */
  .modal-footer {
    margin-top: auto;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  /* close button a bit larger / easier to tap */
  .modal-close-btn {
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: 16px;
    width: 36px;
    height: 36px;
  }

  /* header keeps a bit more top padding to clear iOS notch */
  .modal-header {
    padding: calc(40px + env(safe-area-inset-top, 0px)) 24px 6px;
  }

  /* decorative glows — make them bigger so they fill wider viewport */
  .modal-glow-a {
    width: 280px;
    height: 280px;
    top: -100px;
    right: -80px;
  }
  .modal-glow-b {
    width: 320px;
    height: 320px;
    bottom: -120px;
    left: -100px;
  }
}

@keyframes modal-slide-up {
  0%   { transform: translateY(100%); opacity: 0; }
  100% { transform: translateY(0);    opacity: 1; }
}

/* ---------- small phones polish ---------- */

@media (max-width: 420px) {
  .modal-header h2 {
    font-size: 1.7rem;
  }
  .modal-header p {
    font-size: 0.85rem;
  }
  .wallet-btn {
    min-height: 52px;
    font-size: 0.92rem;
    padding-left: 56px;
    padding-right: 44px;
  }
  .wallet-icon-box {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }
  .wallet-icon-box img {
    width: 24px;
    height: 24px;
  }
  .modal-terms {
    padding: 12px 22px 0;
  }
}

/* ---------- short screens (landscape phones) ---------- */

@media (max-width: 640px) and (max-height: 560px) {
  .modal-header {
    padding-top: calc(28px + env(safe-area-inset-top, 0px));
  }
  .modal-header h2 {
    font-size: 1.5rem;
  }
  .modal-eyebrow {
    margin-bottom: 10px;
  }
  .wallet-btn {
    min-height: 48px;
  }
}
