/* ==========================================================================
   WP Tours WhatsApp button and its booking popup

   The button keeps WhatsApp's own green so it is recognised at a glance. The
   popup follows the site: the theme's brand tokens (with fallbacks), gold
   buttons, and a bottom sheet on phones, like the main booking popup.
   ========================================================================== */

.wtwa,
.wtwa-dialog {
  --wtwa-green: #25d366;
  --wtwa-green-dark: #1ebe5b;
  --wtwa-ink: #123434;
  --wtwa-muted: #5c6e6e;
  --wtwa-gold: var(--brand, #d8ad02);
  --wtwa-gold-dark: var(--brand-dark, #c09a02);
  --wtwa-gold-deep: var(--brand-deep, #836901);
  --wtwa-gold-rgb: var(--brand-rgb, 216, 173, 2);
  --wtwa-on-gold: var(--on-brand, #123434);
  --wtwa-sand: #f4f1ea;
  --wtwa-line: #e4ddcd;
}

/* ---------- The floating button ---------- */
.wtwa {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 140; /* Above the site nav (100), below the mobile drawer (150 and up). */
  width: 60px;
  height: 60px;
}
.wtwa[hidden] { display: none; }

.wtwa__fab {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--wtwa-green);
  color: #fff;
  box-shadow: 0 12px 26px -8px rgba(7, 94, 84, .65), 0 3px 8px rgba(0, 0, 0, .18);
  cursor: pointer;
  touch-action: none; /* A finger on the button drags it instead of scrolling the page. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
  animation: wtwa-in .4s cubic-bezier(.2, .9, .25, 1.2) backwards;
}
.wtwa__fab svg { width: 33px; height: 33px; pointer-events: none; }
.wtwa__fab:focus-visible { outline: 3px solid var(--wtwa-ink); outline-offset: 3px; }

/* Two quiet pulses after the page loads, then it stays still. */
.wtwa__fab::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: var(--wtwa-green);
  opacity: 0;
  pointer-events: none;
  animation: wtwa-ring 2s ease-out 1s 2;
}
@keyframes wtwa-in { from { opacity: 0; transform: scale(.4); } }
@keyframes wtwa-ring {
  from { opacity: .55; transform: scale(1); }
  to { opacity: 0; transform: scale(1.75); }
}

.wtwa.is-dragging .wtwa__fab {
  background: var(--wtwa-green-dark);
  box-shadow: 0 22px 36px -10px rgba(7, 94, 84, .7), 0 6px 14px rgba(0, 0, 0, .2);
  cursor: grabbing;
  transform: scale(1.08);
  transition: none;
}

/* ---------- Tooltip: left of the button, or right when it sits on the left half ---------- */
.wtwa__tip {
  position: absolute;
  top: 50%;
  right: calc(100% + 14px);
  width: max-content;
  max-width: min(240px, calc(50vw - 50px));
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--wtwa-ink);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(6px, -50%);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.wtwa__tip::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  margin-top: -6px;
  border: 6px solid transparent;
  border-left-color: var(--wtwa-ink);
}
.wtwa--tip-right .wtwa__tip { right: auto; left: calc(100% + 14px); transform: translate(-6px, -50%); }
.wtwa--tip-right .wtwa__tip::after { left: auto; right: 100%; border-left-color: transparent; border-right-color: var(--wtwa-ink); }

.wtwa__fab:focus-visible + .wtwa__tip { opacity: 1; visibility: visible; transform: translate(0, -50%); }
@media (hover: hover) {
  .wtwa__fab:hover { background: var(--wtwa-green-dark); transform: scale(1.06); }
  .wtwa__fab:hover + .wtwa__tip { opacity: 1; visibility: visible; transform: translate(0, -50%); }
}
.wtwa.is-dragging .wtwa__tip,
.wtwa.is-tip-dismissed .wtwa__tip { opacity: 0; visibility: hidden; }

/* ---------- The popup ---------- */
html.wtwa-locked { overflow: hidden; }
html.wtwa-locked body { padding-right: var(--wtwa-scrollbar, 0px); }

.wtwa-dialog {
  position: fixed;
  inset: 0;
  width: min(560px, calc(100vw - 32px));
  height: fit-content;
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: #fff;
  color: var(--wtwa-ink);
  overflow: hidden;
  text-align: left;
  box-shadow: 0 50px 100px -40px rgba(0, 0, 0, .6);
  opacity: 0;
  transform: translateY(24px) scale(.97);
  transition: opacity .25s ease, transform .35s cubic-bezier(.2, .9, .25, 1), overlay .35s allow-discrete, display .35s allow-discrete;
}
.wtwa-dialog[open] { display: flex; flex-direction: column; opacity: 1; transform: none; }
@starting-style {
  .wtwa-dialog[open] { opacity: 0; transform: translateY(24px) scale(.97); }
}
.wtwa-dialog::backdrop {
  background: rgba(8, 28, 28, 0);
  transition: background .3s ease, overlay .35s allow-discrete, display .35s allow-discrete;
}
.wtwa-dialog[open]::backdrop { background: rgba(8, 28, 28, .62); }
@starting-style {
  .wtwa-dialog[open]::backdrop { background: rgba(8, 28, 28, 0); }
}

.wtwa-form { display: flex; flex-direction: column; min-height: 0; margin: 0; }
.wtwa-form[hidden],
.wtwa-done[hidden] { display: none; }

.wtwa-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 64px 22px 26px;
  background: var(--wtwa-ink);
  color: #fff;
}
.wtwa-head__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--wtwa-green);
  color: #fff;
}
.wtwa-head__icon svg { width: 26px; height: 26px; }
.wtwa-head__title { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; color: #fff; outline: none; }
.wtwa-head__intro { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: rgba(255, 255, 255, .84); }

.wtwa-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.wtwa-close svg { width: 20px; height: 20px; }
.wtwa-close:hover { background: var(--wtwa-gold); color: var(--wtwa-on-gold); transform: rotate(90deg); }
.wtwa-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.wtwa-dialog.is-done .wtwa-close { background: var(--wtwa-sand); color: var(--wtwa-ink); }
.wtwa-dialog.is-done .wtwa-close:focus-visible { outline-color: var(--wtwa-ink); }

/* ---------- Fields ---------- */
.wtwa-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-height: 0;
  padding: 22px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.wtwa-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.wtwa-field--full { grid-column: 1 / -1; }
.wtwa-field label { margin: 0; font-size: 13px; font-weight: 700; color: var(--wtwa-ink); }
.wtwa-req { color: #b42318; }

.wtwa-dialog input,
.wtwa-dialog select,
.wtwa-dialog textarea {
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 11px 14px;
  box-sizing: border-box;
  border: 1px solid var(--wtwa-line);
  border-radius: 12px;
  background: var(--wtwa-sand);
  color: var(--wtwa-ink);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.wtwa-dialog textarea { display: block; resize: vertical; line-height: 1.45; }
.wtwa-dialog input:focus,
.wtwa-dialog select:focus,
.wtwa-dialog textarea:focus {
  border-color: var(--wtwa-gold-deep);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(var(--wtwa-gold-rgb), .22);
}
.wtwa-dialog input:user-invalid,
.wtwa-dialog select:user-invalid { border-color: #b42318; background: #fff8f7; }
/* A required dropdown still on its "Select…" choice looks like a placeholder. */
.wtwa-dialog select:invalid { color: var(--wtwa-muted); }
.wtwa-dialog select option { color: var(--wtwa-ink); }

/* ---------- Submit and the "one last step" panel ---------- */
.wtwa-foot { flex: 0 0 auto; padding: 14px 26px 18px; border-top: 1px solid var(--wtwa-line); }
.wtwa-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 12px 24px;
  box-sizing: border-box;
  border: 0;
  border-radius: 30px;
  background: var(--wtwa-gold);
  color: var(--wtwa-on-gold);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(var(--wtwa-gold-rgb), .7);
  transition: background .2s ease, transform .2s ease;
}
.wtwa-submit svg { width: 21px; height: 21px; }
.wtwa-submit:hover { background: var(--wtwa-gold-dark); color: var(--wtwa-on-gold); transform: translateY(-2px); }
.wtwa-submit:focus-visible,
.wtwa-ghost:focus-visible { outline: 2px solid var(--wtwa-ink); outline-offset: 3px; }
.wtwa-note { margin: 10px 0 0; text-align: center; font-size: 12.5px; line-height: 1.4; color: var(--wtwa-muted); }

.wtwa-done { display: flex; flex-direction: column; align-items: center; padding: 48px 34px 30px; text-align: center; outline: none; }
.wtwa-done__icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 18px;
  border-radius: 50%;
  background: var(--wtwa-green);
  color: #fff;
}
.wtwa-done__icon svg { width: 42px; height: 42px; }
.wtwa-done__title { margin: 0 0 8px; font-size: 24px; font-weight: 800; line-height: 1.15; color: var(--wtwa-ink); }
.wtwa-done__text { max-width: 380px; margin: 0 0 22px; font-size: 15px; line-height: 1.55; color: var(--wtwa-muted); }
.wtwa-submit--link { width: auto; }
.wtwa-ghost {
  margin-top: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 30px;
  background: none;
  color: var(--wtwa-ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.wtwa-ghost:hover { background: var(--wtwa-sand); }

/* ---------- Phones: a smaller button, and the popup as a bottom sheet ---------- */
@media (max-width: 720px) {
  .wtwa { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  .wtwa__fab svg { width: 31px; height: 31px; }

  .wtwa-dialog {
    inset: auto 0 0 0;
    width: 100%;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    margin: 0;
    border-radius: 24px 24px 0 0;
    transform: translateY(40px);
  }
  @starting-style {
    .wtwa-dialog[open] { opacity: 0; transform: translateY(40px); }
  }
  .wtwa-head { padding: 18px 58px 18px 18px; }
  .wtwa-head__title { font-size: 20px; }
  .wtwa-close { top: 12px; right: 12px; }
  .wtwa-body { padding: 18px; gap: 12px; }
  .wtwa-foot { padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px)); }
  .wtwa-dialog input,
  .wtwa-dialog select,
  .wtwa-dialog textarea { font-size: 16px; } /* Below 16px, iPhones zoom in on focus. */
}
@media (max-width: 480px) {
  .wtwa-field--wide-sm { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .wtwa__fab,
  .wtwa__fab::before { animation: none; }
  .wtwa__fab,
  .wtwa__tip,
  .wtwa-dialog,
  .wtwa-dialog::backdrop,
  .wtwa-close,
  .wtwa-submit { transition: none; }
}
