/**
 * FE-005+009 / FE-025 R1.3 — Ask Glen Smart Island
 * Approved premium floating capsule for eligible public pages.
 * Desktop: text capsule, bottom-right; smooth scroll-roll to PG mark (~300ms).
 * Mobile: logo-only circular glass button above Soft Liquid Glass nav.
 * Does not modify FE-010 / FE-011 stylesheets.
 */
:root {
  --pg-ask-island-z: 3000; /* above sticky header / FAB (2880), below Ask drawer (3120) */
  --pg-ask-island-navy: #062b5b;
  --pg-ask-island-navy-deep: #041f42;
  --pg-ask-island-emerald: #0ba360;
  --pg-ask-island-ink: #f7faf8;
  --pg-ask-island-muted: rgba(247, 250, 248, 0.72);
  --pg-ask-island-glass: rgba(8, 28, 52, 0.72);
  --pg-ask-island-glass-border: rgba(255, 255, 255, 0.16);
  --pg-ask-island-highlight: rgba(255, 255, 255, 0.22);
  --pg-ask-island-width: min(208px, calc(100vw - 48px));
  --pg-ask-island-compact: 46px;
  --pg-ask-island-right: 24px;
  --pg-ask-island-bottom: 24px;
  /* R1.3 motion — restrained premium roll */
  --pg-ask-island-roll-ms: 300ms;
  --pg-ask-island-roll-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pg-ask-island-enter-ms: 240ms;
}

/* Smart Island replaces the legacy bottom FAB dock while active (all eligible pages) */
body.pg-ask-smart-island #askglen-fab,
body.pg-ask-smart-island #askglen-fab-dock {
  display: none !important;
}

.pg-ask-island {
  position: fixed;
  right: var(--pg-ask-island-right);
  bottom: var(--pg-ask-island-bottom);
  left: auto;
  top: auto;
  z-index: var(--pg-ask-island-z);
  width: var(--pg-ask-island-width);
  /* Right-anchored: width shrinks toward the stable dock corner */
  transform: translate3d(0, 10px, 0) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transform-origin: 100% 100%;
  transition:
    transform var(--pg-ask-island-enter-ms) var(--pg-ask-island-roll-ease),
    opacity var(--pg-ask-island-enter-ms) ease,
    width var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease);
  will-change: transform, opacity, width;
}

html.pg-ask-island-visible .pg-ask-island {
  transform: translate3d(0, 0, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Hide while drawer is open — drawer is the only Ask Glen surface.
   Keep pg-ask-island-visible so closing the drawer restores the capsule. */
html.ask-drawer-open.pg-ask-island-visible .pg-ask-island,
html.pg-ask-island-opening .pg-ask-island,
html.ask-drawer-open .pg-ask-island {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translate3d(0, 8px, 0) scale(0.94);
}

.pg-ask-island__shell {
  display: flex;
  align-items: center;
  width: 100%;
  height: 46px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--pg-ask-island-glass-border);
  border-radius: 999px;
  background:
    linear-gradient(180deg, var(--pg-ask-island-highlight), transparent 42%),
    var(--pg-ask-island-glass);
  color: var(--pg-ask-island-ink);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 0 0 0.5px rgba(11, 163, 96, 0.18),
    0 10px 28px rgba(4, 31, 66, 0.28);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  cursor: pointer;
  font: inherit;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden; /* continuous roll — no abrupt text clip pop */
  transition:
    width var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease),
    border-radius var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease),
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.pg-ask-island__shell:hover,
.pg-ask-island__shell:focus-visible {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.24) inset,
    0 0 0 0.5px rgba(11, 163, 96, 0.28),
    0 12px 32px rgba(4, 31, 66, 0.34);
}

.pg-ask-island__shell:focus-visible {
  outline: 2px solid var(--pg-ask-island-emerald);
  outline-offset: 3px;
}

.pg-ask-island__mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin: 5px 0 5px 5px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  overflow: hidden;
  transition:
    margin var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease),
    width 200ms ease,
    height 200ms ease,
    box-shadow 200ms ease;
}

.pg-ask-island__mark img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
  transition: width 200ms ease, height 200ms ease;
}

.pg-ask-island__copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  max-width: 120px;
  padding: 0 4px 0 10px;
  line-height: 1.15;
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
  transition:
    opacity 220ms ease,
    max-width var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease),
    padding var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease);
}

.pg-ask-island__copy strong {
  font-size: 0.86rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: #fff;
}

.pg-ask-island__copy span {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--pg-ask-island-muted);
}

.pg-ask-island__chev {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  margin-left: auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(11, 163, 96, 0.18);
  color: #9be6c0;
  opacity: 1;
  overflow: hidden;
  transition:
    opacity 200ms ease,
    width var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease),
    margin var(--pg-ask-island-roll-ms) var(--pg-ask-island-roll-ease),
    transform 200ms ease;
}

.pg-ask-island__chev svg {
  width: 14px;
  height: 14px;
  display: block;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .pg-ask-island__shell {
    background: rgba(6, 43, 91, 0.94);
  }
}

/*
 * DETAIL-GLEN-R1 — scroll-minimised compact PG control on desktop/tablet.
 * Continuous width + opacity roll (no absolute 1px clip pop).
 */
@media (min-width: 761px) {
  .pg-ask-island.is-minimized {
    width: var(--pg-ask-island-compact);
  }

  .pg-ask-island.is-minimized .pg-ask-island__shell {
    width: var(--pg-ask-island-compact);
    height: var(--pg-ask-island-compact);
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    border-radius: 50%;
    text-align: center;
  }

  .pg-ask-island.is-minimized .pg-ask-island__copy {
    opacity: 0;
    max-width: 0;
    padding-left: 0;
    padding-right: 0;
    pointer-events: none;
  }

  .pg-ask-island.is-minimized .pg-ask-island__chev {
    opacity: 0;
    width: 0;
    margin-right: 0;
    margin-left: 0;
    pointer-events: none;
    transform: scale(0.6);
  }

  .pg-ask-island.is-minimized .pg-ask-island__mark {
    width: 34px;
    height: 34px;
    margin: 0;
    box-shadow: none;
  }

  .pg-ask-island.is-minimized .pg-ask-island__mark img {
    width: 26px;
    height: 26px;
  }
}

/* Tablet / mid: same desktop corner dock (Soft Liquid Glass nav is ≤760px only) */
@media (min-width: 761px) and (max-width: 1199px) {
  :root {
    --pg-ask-island-width: min(200px, calc(100vw - 48px));
    --pg-ask-island-right: 24px;
    --pg-ask-island-bottom: 24px;
  }
}

/* Mobile: logo-only circular glass control above Soft Liquid Glass nav (≤760px) */
@media (max-width: 760px) {
  :root {
    --pg-ask-island-size: 48px; /* accessible touch target */
    --pg-ask-island-width: var(--pg-ask-island-size);
    --pg-ask-island-right: 16px;
    --pg-ask-island-bottom: calc(
      var(--mobile-app-nav-height, 72px) +
        var(--mobile-app-nav-inset, calc(8px + env(safe-area-inset-bottom, 0px))) +
        5px
    );
  }

  body.listings-page.pg-ask-smart-island,
  body.commercial-page.pg-ask-smart-island {
    --pg-ask-island-bottom: calc(
      var(--mobile-app-nav-height, 72px) +
        var(--mobile-app-nav-inset, calc(8px + env(safe-area-inset-bottom, 0px))) +
        var(--mobile-filter-bar-height, 52px) +
        5px
    );
  }

  body.sale-page.listings-page.bayut-serp-page.pg-ask-smart-island {
    --pg-ask-island-bottom: calc(
      var(--mobile-app-nav-height, 72px) +
        var(--mobile-app-nav-inset, calc(8px + env(safe-area-inset-bottom, 0px))) +
        5px
    );
  }

  body.listing-detail-page.has-detail-mobile-cta.pg-ask-smart-island {
    --pg-ask-island-bottom: calc(
      var(--pg-ux01-detail-cta-h, 64px) +
        var(--mobile-app-nav-height, 72px) +
        var(--mobile-app-nav-inset, calc(8px + env(safe-area-inset-bottom, 0px))) +
        5px
    );
  }

  .pg-ask-island {
    width: var(--pg-ask-island-size);
    height: var(--pg-ask-island-size);
  }

  .pg-ask-island__shell {
    width: var(--pg-ask-island-size);
    height: var(--pg-ask-island-size);
    min-width: var(--pg-ask-island-size);
    min-height: var(--pg-ask-island-size);
    justify-content: center;
    border-radius: 50%;
    text-align: center;
  }

  .pg-ask-island__mark {
    width: 30px;
    height: 30px;
    margin: 0;
  }

  .pg-ask-island__mark img {
    width: 22px;
    height: 22px;
  }

  .pg-ask-island__copy,
  .pg-ask-island__chev {
    display: none !important;
  }

  html.pg-ask-island-visible body.pg-ask-smart-island {
    scroll-padding-bottom: calc(var(--pg-ask-island-bottom) + 56px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pg-ask-island,
  .pg-ask-island__shell,
  .pg-ask-island__mark,
  .pg-ask-island__mark img,
  .pg-ask-island__copy,
  .pg-ask-island__chev,
  html.pg-ask-island-visible .pg-ask-island,
  html.ask-drawer-open .pg-ask-island,
  html.pg-ask-island-opening .pg-ask-island {
    transition: none !important;
  }
}
