/**
 * Mobile bottom sheet: pin entry and country picking.
 *
 * The panel's transform is written by JS (spring driven), so nothing here animates it.
 * The country list carries the `country-select` class purely so the existing flag sprite
 * rules in countrySelect.css apply to its rows; the first two declarations undo the layout
 * that class brings with it.
 *
 * No dark-scheme variant on purpose: the sheet hosts the VayaPin widget, which is light on
 * every storefront. Following the phone's dark mode would drop a dark panel into a light
 * checkout.
 */

.vp-sheet {
  /* Default matches the widget's own accent; JS overrides it with the merchant's value. */
  --vp-sheet-surface: #f0fcf6;
  --vp-sheet-surface-muted: #e2f3ea;
  --vp-sheet-surface-muted: color-mix(in srgb, var(--vp-sheet-text) 7%, var(--vp-sheet-surface));
  --vp-sheet-text: #0f172a;
  --vp-sheet-text-muted: #64748b;
  --vp-sheet-border: rgba(15, 23, 42, 0.08);
  --vp-sheet-accent: #1f9f8b;

  position: fixed;
  inset: 0;
  z-index: 999999;
}

.vp-sheet[hidden] {
  display: none;
}

.vp-sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  opacity: 0;
  will-change: opacity;
}

.vp-sheet__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;

  display: flex;
  flex-direction: column;
  max-height: calc(100% - 2.5rem);

  background: var(--vp-sheet-surface);
  border-radius: 1.25rem 1.25rem 0 0;
  box-shadow: 0 -0.75rem 2.5rem rgba(15, 23, 42, 0.28);
  color: var(--vp-sheet-text);

  font-size: 1rem;
  line-height: 1.4;

  transform: translate3d(0, 100%, 0);
  will-change: transform;
  outline: none;
  overflow: hidden;
}

/* Country picking wants the tall sheet; pin entry sizes to its content. */
.vp-sheet__panel.is-country-view {
  height: 80vh;
  height: 80svh;
}

.vp-sheet__panel.is-resizing {
  transition: height 260ms cubic-bezier(0.32, 0.72, 0, 1);
}

.vp-sheet__grabber {
  display: flex;
  justify-content: center;
  padding: 0.625rem 0 0.375rem;
  touch-action: none;
  cursor: grab;
}

.vp-sheet__grabber span {
  width: 2.25rem;
  height: 0.25rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.18);
}

.vp-sheet__panel.is-dragging .vp-sheet__grabber {
  cursor: grabbing;
}

.vp-sheet__views {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.vp-sheet__view {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* display:flex above would otherwise beat the [hidden] attribute. */
.vp-sheet__view[hidden] {
  display: none;
}

/* --- Pin entry -------------------------------------------------------- */

/*
 * The widget body drops its own surface: the panel already carries that colour, and two
 * stacked tinted cards read as a card inside a card. The background sits inline on the
 * element (merchant setting), so !important is the only way to lift it onto the panel.
 */
.vp-sheet__widget.vayapin-checkout-dropdown-body {
  position: static;
  width: 100%;
  max-width: none;
  margin: 0;
  padding-bottom: calc(1.125rem + env(safe-area-inset-bottom));
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  border-radius: 0 !important;
}

/*
 * The row is authored as content-box, so its padding adds to the 100% width and the GO
 * button hangs off the panel edge, which is exactly the screen width here.
 */
.vp-sheet__widget,
.vp-sheet__widget .vayapin-pin-input-wrapper {
  box-sizing: border-box;
  width: 100%;
}

/*
 * The widget carries its own <=520px breakpoint that stacks the row and turns GO into a
 * full-width bar. Inside the sheet the row gets the whole panel width, so the desktop
 * layout is the correct one: these rules restate it value for value. !important appears
 * only where the breakpoint itself uses it.
 */
.vp-sheet .vp-sheet__widget .vayapin-pin-input-wrapper {
  flex-wrap: nowrap;
  align-items: stretch;
  row-gap: 0;
  min-height: 3rem;
  padding: 0.25rem 0.3125rem 0.25rem 0.75rem;
  border-radius: 999px;
}

.vp-sheet .vp-sheet__widget .vayapin-pin-country-wrapper {
  position: static !important;
  top: auto !important;
  order: 0;
  flex-shrink: 0;
  padding-left: 0.125rem;
}

.vp-sheet .vp-sheet__widget .vayapin-pin-country-wrapper .country-select.inside .selected-flag {
  left: 0.6875rem !important;
}

.vp-sheet .vp-sheet__widget .vayapin-pin-divider {
  display: block;
  align-self: center;
  min-height: 1.625rem;
  margin: 0 0.625rem;
}

.vp-sheet .vp-sheet__widget .vayapin-pin-input-field {
  order: 1;
  flex: 1 1 0%;
  min-width: 0;
  padding: 0 !important;
  font-size: 0.9375rem;
}

.vp-sheet .vp-sheet__widget #vayapin-fields-button {
  order: 2;
  flex: 0 0 auto;
  width: auto;
  min-width: 2.75rem;
  align-self: center;
  margin: 0 0.125rem 0 0;
  padding: 0.46rem 0;
  font-size: 0.875rem;
}

.vp-sheet__widget .vayapin-checkout-dropdown-close {
  top: 0.25rem;
  right: 0.75rem;
}

/* --- Country picking -------------------------------------------------- */

/*
 * Storefront themes style every control they can reach, typically as
 * `.button, [type=button], button { padding: 12px 20px; ... }`. An attribute selector has
 * the same specificity as a class, and theme CSS usually loads after the plugin's, so a
 * plain class rule here loses on every shared property. Hence the blanket !important set:
 * this is a reset against unknown third-party CSS, not a specificity shortcut.
 */
.vp-sheet__back,
.vp-sheet__search {
  -webkit-appearance: none !important;
  appearance: none !important;
  font-family: inherit !important;
  font-weight: 400 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  text-shadow: none !important;
  float: none !important;
  transform: none;
}

/* Themes also hang icons and ribbons on pseudo elements of their buttons. */
.vp-sheet__back::before,
.vp-sheet__back::after {
  content: none !important;
}

.vp-sheet__country-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 1rem 0.75rem;
  border-bottom: 1px solid var(--vp-sheet-border);
  touch-action: none;
}

.vp-sheet__back {
  flex: 0 0 auto;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  /* 2.75rem keeps the back control inside the comfortable touch range. */
  width: 2.75rem !important;
  height: 2.75rem !important;
  padding: 0 !important;
  line-height: 1 !important;
  font-size: 1rem !important;

  color: var(--vp-sheet-text) !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 999px !important;
  cursor: pointer;
  transition: background-color 120ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 120ms cubic-bezier(0.23, 1, 0.32, 1);
}

.vp-sheet__back svg {
  display: block !important;
  width: 1.25rem !important;
  height: 1.25rem !important;
  max-width: none !important;
  fill: none !important;
  stroke: currentColor !important;
  opacity: 1 !important;
  vertical-align: middle;
}

.vp-sheet__back:active {
  background: var(--vp-sheet-surface-muted);
  transform: scale(0.94);
}

.vp-sheet__search {
  flex: 1 1 auto;
  width: 100%;
  padding: 0.75rem 1rem !important;

  /* 1rem keeps iOS from zooming the page when the field takes focus. */
  font-size: 1rem !important;
  line-height: 1.25 !important;
  color: var(--vp-sheet-text) !important;

  background: var(--vp-sheet-surface-muted) !important;
  border: 1px solid transparent !important;
  border-radius: 0.75rem !important;
  height: auto !important;
  touch-action: auto;
  transition: border-color 150ms cubic-bezier(0.23, 1, 0.32, 1),
    background-color 150ms cubic-bezier(0.23, 1, 0.32, 1);
}

.vp-sheet__search:focus {
  outline: none;
  background: #ffffff !important;
  border-color: var(--vp-sheet-accent);
}

.vp-sheet__list.country-select {
  display: block;
  position: static;

  flex: 1 1 auto;
  margin: 0;
  padding: 0.25rem 0 calc(0.75rem + env(safe-area-inset-bottom));
  list-style: none;

  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.vp-sheet__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;

  /* 3rem is the smallest row that still reads as a comfortable finger target. */
  min-height: 3rem;
  margin: 0;
  padding: 0.5rem 1rem;

  cursor: pointer;
  transition: background-color 120ms cubic-bezier(0.23, 1, 0.32, 1);
}

.vp-sheet__row:active {
  background: var(--vp-sheet-surface-muted);
}

@media (hover: hover) and (pointer: fine) {
  .vp-sheet__row:hover {
    background: var(--vp-sheet-surface-muted);
  }
}

.vp-sheet__row .flag {
  flex: 0 0 auto;
}

.vp-sheet__country-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vp-sheet__country-code {
  flex: 0 0 auto;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--vp-sheet-text-muted);
}

.vp-sheet__row.is-selected {
  background: color-mix(in srgb, var(--vp-sheet-accent) 10%, transparent);
}

.vp-sheet__row.is-selected .vp-sheet__country-name {
  font-weight: 600;
}

.vp-sheet__row.is-selected .vp-sheet__country-code {
  color: var(--vp-sheet-accent);
  font-weight: 600;
}

.vp-sheet__empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--vp-sheet-text-muted);
}

/* Page behind the sheet must not scroll while it is open. */
html.vp-sheet-lock,
html.vp-sheet-lock body {
  overflow: hidden;
  overscroll-behavior: none;
}

@media (prefers-contrast: more) {
  .vp-sheet__panel {
    border-top: 1px solid var(--vp-sheet-text);
  }

  .vp-sheet__search {
    border-color: var(--vp-sheet-text);
  }
}

@media (prefers-reduced-motion: reduce) {
  .vp-sheet__panel.is-resizing,
  .vp-sheet__search,
  .vp-sheet__back,
  .vp-sheet__row {
    transition: none;
  }
}
