/*
 * LuckyQuest + Roxy mobile safe-area alignment (2026-11-06).
 * Only the v2 public homepage. Keep the two launchers apart, reserve room
 * for consent/browser chrome, and let an OPEN panel use the whole viewport.
 */
@media (max-width: 650px) {
  body.lw-public-home[data-lw-home="v2"] {
    --lw-mobile-fab-bottom: calc(
      var(--lw-consent-height, 0px) + 5.75rem + env(safe-area-inset-bottom, 0px)
    );
  }

  body.lw-public-home[data-lw-home="v2"] #lw-explorer,
  body.lw-public-home[data-lw-home="v2"] #roxy-widget {
    bottom: var(--lw-mobile-fab-bottom) !important;
  }

  body.lw-public-home[data-lw-home="v2"] #lw-explorer {
    left: 12px !important;
    right: auto !important;
    width: 52px !important;
    max-width: calc(50vw - 24px) !important;
    z-index: 1150 !important;
  }

  body.lw-public-home[data-lw-home="v2"] #roxy-widget {
    left: auto !important;
    right: 12px !important;
    width: max-content !important;
    max-width: calc(50vw - 24px) !important;
    justify-items: end;
    z-index: 1150 !important;
  }

  body.lw-public-home[data-lw-home="v2"] #lw-explorer-toggle {
    width: 52px;
    min-width: 52px;
    height: 52px;
    min-height: 52px !important;
    max-width: 100%;
    overflow: visible !important;
    box-sizing: border-box;
  }

  body.lw-public-home[data-lw-home="v2"] #roxy-widget .roxy-widget__launch {
    min-height: 52px;
    max-width: 100%;
    white-space: nowrap;
  }

  /* The default half-screen limits apply ONLY while launchers are closed. */
  body.lw-public-home[data-lw-home="v2"] #lw-explorer:has(#lw-explorer-panel:not([hidden])) {
    width: min(330px, calc(100vw - 24px)) !important;
    max-width: none !important;
  }

  body.lw-public-home[data-lw-home="v2"] #roxy-widget:has(.roxy-widget__panel:not([hidden])) {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: none !important;
  }

  /* When Quest is open, make the idle Roxy launcher a compact FAB. */
  body.lw-public-home[data-lw-home="v2"]:has(#lw-explorer-panel:not([hidden])) #roxy-widget .roxy-widget__launch {
    width: 52px;
    min-width: 52px;
    justify-content: center;
    padding: 5px !important;
  }

  body.lw-public-home[data-lw-home="v2"]:has(#lw-explorer-panel:not([hidden])) #roxy-widget .roxy-widget__launch > span:last-child {
    display: none;
  }

  body.lw-public-home[data-lw-home="v2"] #lw-explorer-panel {
    max-height: min(
      54dvh,
      max(0px, calc(100dvh - var(--lw-mobile-fab-bottom) - 76px))
    ) !important;
  }

  body.lw-public-home[data-lw-home="v2"] #roxy-widget .roxy-widget__panel {
    width: min(410px, calc(100vw - 24px));
    max-height: min(
      710px,
      max(0px, calc(100dvh - var(--lw-mobile-fab-bottom) - 76px))
    ) !important;
    overflow: auto;
  }
}

/* Keep the smallest phones readable without trapping the Roxy label. */
@media (max-width: 380px) {
  body.lw-public-home[data-lw-home="v2"] #roxy-widget .roxy-widget__launch {
    width: 52px;
    min-width: 52px;
    justify-content: center;
    padding: 5px !important;
  }

  body.lw-public-home[data-lw-home="v2"] #roxy-widget .roxy-widget__launch > span:last-child {
    display: none;
  }
}

/* QA repair: consent-aware touchable launchers and separated modal. */
@media(max-width:650px){
body.lw-public-home[data-lw-home="v2"] #lw-explorer{
  height:52px !important;
  min-height:52px !important;
}
body.lw-public-home[data-lw-home="v2"] #lw-explorer-toggle {
  pointer-events:auto !important;
  min-height:52px !important;
}
body.lw-public-home[data-lw-home="v2"] #roxy-widget:not([data-home-roxy-open="true"]) {
  height:52px !important;
}
body.lw-public-home[data-lw-home="v2"] #roxy-widget .roxy-widget__launch:not([aria-expanded="true"]) {
  width:52px !important;
  min-width:52px !important;
  height:52px !important;
  min-height:52px !important;
  padding:5px !important;
}
body.lw-public-home[data-lw-home="v2"] #lw-explorer-panel:not([hidden]) {
  top:auto !important;
  bottom:calc(var(--lw-mobile-fab-bottom) + 62px) !important;
  max-height:min(54dvh, max(0px, calc(100dvh - var(--lw-mobile-fab-bottom) - 78px))) !important;
}
body.lw-public-home[data-lw-home="v2"] #roxy-widget .roxy-widget__panel:not([hidden]) {
  max-height:calc(100dvh - 24px - env(safe-area-inset-bottom, 0px)) !important;
}
}
