/*!
 * @stashgg/stash-pay v2 — required styles
 * All visual tokens are CSS custom properties. Override on the root element
 * or globally to re-theme without rebuilding.
 */

:where(.stash-pay) {
  /* Colors */
  --stash-pay-color-bg:                #000000;
  --stash-pay-color-backdrop:          rgba(0, 0, 0, 0.4);
  --stash-pay-color-text:              #ffffff;
  --stash-pay-color-accent:            #4f46e5;
  --stash-pay-color-close-bg:          rgba(31, 41, 55, 0.9);
  --stash-pay-color-close-bg-hover:    #374151;
  --stash-pay-color-close-fg:          #d1d5db;
  --stash-pay-color-close-fg-hover:    #ffffff;
  --stash-pay-color-spinner-track:     #4b5563;
  --stash-pay-color-spinner-head:      #d1d5db;
  --stash-pay-color-drag-bar:          #4b5563;
  --stash-pay-color-shadow:            rgba(0, 0, 0, 0.5);

  /* Geometry */
  --stash-pay-radius:                  1.5rem;
  --stash-pay-sheet-max-width:         28rem;
  --stash-pay-modal-max-width:         32rem;
  --stash-pay-side-panel-width:        28rem;
  --stash-pay-close-offset:            1rem;

  /* Motion */
  --stash-pay-animation-duration:      300ms;
  --stash-pay-animation-easing:        cubic-bezier(0.32, 0.72, 0, 1);
  --stash-pay-iframe-fade-duration:    400ms;

  /* Layering */
  --stash-pay-z-index:                 2147483000;
}

/* ---- root ---- */

.stash-pay {
  position: fixed;
  inset: 0;
  z-index: var(--stash-pay-z-index);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  opacity: 1;
  pointer-events: auto;
  transition: opacity var(--stash-pay-animation-duration)
    var(--stash-pay-animation-easing);
  color: var(--stash-pay-color-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stash-pay[data-stash-pay-state="closed"] {
  opacity: 0;
  pointer-events: none;
}

/* ---- backdrop ---- */

.stash-pay__backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--stash-pay-color-backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity var(--stash-pay-animation-duration)
    var(--stash-pay-animation-easing);
}

.stash-pay[data-stash-pay-state="closed"] .stash-pay__backdrop {
  opacity: 0;
}

/* ---- card (shared) ---- */

.stash-pay__card {
  position: relative;
  width: 100%;
  background-color: var(--stash-pay-color-bg);
  box-shadow: 0 -4px 24px var(--stash-pay-color-shadow);
  overflow: hidden;
  transition: transform var(--stash-pay-animation-duration)
      var(--stash-pay-animation-easing),
    opacity var(--stash-pay-animation-duration)
      var(--stash-pay-animation-easing);
  will-change: transform, opacity;
}

/* ---- drag bar ---- */

.stash-pay__drag-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 0.75rem 0 0.5rem;
  z-index: 20;
  pointer-events: none;
}

.stash-pay__drag-bar-indicator {
  width: 3rem;
  height: 0.375rem;
  background-color: var(--stash-pay-color-drag-bar);
  border-radius: 9999px;
}

/* ---- close button ---- */

.stash-pay__close {
  position: absolute;
  top: var(--stash-pay-close-offset);
  right: var(--stash-pay-close-offset);
  z-index: 20;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background-color: var(--stash-pay-color-close-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 9999px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  color: var(--stash-pay-color-close-fg);
  border: none;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}

.stash-pay__close:hover,
.stash-pay__close:focus-visible {
  color: var(--stash-pay-color-close-fg-hover);
  background-color: var(--stash-pay-color-close-bg-hover);
}

.stash-pay__close:focus-visible {
  outline: 2px solid var(--stash-pay-color-accent);
  outline-offset: 2px;
}

.stash-pay__close svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ---- loading ---- */

.stash-pay__loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--stash-pay-color-bg);
  opacity: 1;
  transition: opacity var(--stash-pay-iframe-fade-duration) ease-out;
}

.stash-pay[data-stash-pay-loading="false"] .stash-pay__loading {
  opacity: 0;
  pointer-events: none;
}

.stash-pay__spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid var(--stash-pay-color-spinner-track);
  border-top-color: var(--stash-pay-color-spinner-head);
  border-radius: 9999px;
  animation: stash-pay-spin 1s linear infinite;
}

@keyframes stash-pay-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- iframe ---- */

.stash-pay__iframe-wrap {
  position: absolute;
  inset: 0;
}

.stash-pay__iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---- position: bottom-sheet (default) ---- */

.stash-pay[data-stash-pay-position="bottom-sheet"] {
  align-items: flex-end;
}
.stash-pay[data-stash-pay-position="bottom-sheet"] .stash-pay__card {
  max-width: var(--stash-pay-sheet-max-width);
  height: 90vh;
  max-height: 90vh;
  border-top-left-radius: var(--stash-pay-radius);
  border-top-right-radius: var(--stash-pay-radius);
  transform: translateY(0);
}
.stash-pay[data-stash-pay-position="bottom-sheet"][data-stash-pay-state="closed"] .stash-pay__card,
.stash-pay[data-stash-pay-position="bottom-sheet"][data-stash-pay-state="closing"] .stash-pay__card {
  transform: translateY(100%);
}

/* ---- position: center-modal ---- */

.stash-pay[data-stash-pay-position="center-modal"] {
  align-items: center;
}
.stash-pay[data-stash-pay-position="center-modal"] .stash-pay__card {
  max-width: var(--stash-pay-modal-max-width);
  width: min(92vw, var(--stash-pay-modal-max-width));
  height: min(90vh, 720px);
  max-height: 90vh;
  border-radius: var(--stash-pay-radius);
  transform: scale(1);
  opacity: 1;
}
.stash-pay[data-stash-pay-position="center-modal"][data-stash-pay-state="closed"] .stash-pay__card,
.stash-pay[data-stash-pay-position="center-modal"][data-stash-pay-state="closing"] .stash-pay__card {
  transform: scale(0.96);
  opacity: 0;
}

/* ---- position: side-panel-right ---- */

.stash-pay[data-stash-pay-position="side-panel-right"] {
  justify-content: flex-end;
  align-items: stretch;
}
.stash-pay[data-stash-pay-position="side-panel-right"] .stash-pay__card {
  width: var(--stash-pay-side-panel-width);
  max-width: 100vw;
  height: 100%;
  max-height: 100%;
  border-top-left-radius: var(--stash-pay-radius);
  border-bottom-left-radius: var(--stash-pay-radius);
  transform: translateX(0);
}
.stash-pay[data-stash-pay-position="side-panel-right"][data-stash-pay-state="closed"] .stash-pay__card,
.stash-pay[data-stash-pay-position="side-panel-right"][data-stash-pay-state="closing"] .stash-pay__card {
  transform: translateX(100%);
}

/* ---- position: side-panel-left ---- */

.stash-pay[data-stash-pay-position="side-panel-left"] {
  justify-content: flex-start;
  align-items: stretch;
}
.stash-pay[data-stash-pay-position="side-panel-left"] .stash-pay__card {
  width: var(--stash-pay-side-panel-width);
  max-width: 100vw;
  height: 100%;
  max-height: 100%;
  border-top-right-radius: var(--stash-pay-radius);
  border-bottom-right-radius: var(--stash-pay-radius);
  transform: translateX(0);
}
.stash-pay[data-stash-pay-position="side-panel-left"][data-stash-pay-state="closed"] .stash-pay__card,
.stash-pay[data-stash-pay-position="side-panel-left"][data-stash-pay-state="closing"] .stash-pay__card {
  transform: translateX(-100%);
}

/* ---- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .stash-pay,
  .stash-pay *,
  .stash-pay *::before,
  .stash-pay *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
