/* PESYJE PWA V3 FOUNDATION. This file is intentionally loaded LAST.
   Uses existing five actions and existing theme; no second navigation is created. */
@media screen and (max-width: 991px) {
  html { max-width: 100%; overflow-x: clip; }
  body { width: 100%; max-width: 100%; overflow-x: clip; }
  body:has(#pesyjeMobileFooter) {
    padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html { scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }

  /* Social views should shrink inside the screen, not widen the viewport. */
  .ps-social, .ps-shell, .ps-columns, .ps-main, .ps-sidebar,
  .ps-review-card, .ps-post-body, .ps-post-header, .ps-post-cta,
  .ps-business-tile, .ps-business-info, .ps-panel,
  .ps-timeline-columns, .ps-timeline-hero,
  .pr-main, .pr-layout, .pr-feed, .pr-review-card {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .ps-social, .ps-shell, .ps-review-card, .pr-review-card { overflow-wrap: anywhere; }
  .ps-social img, .ps-review-card img, .pr-review-card img,
  .ps-photo-grid img, .ps-post-body img { max-width: 100% !important; }
  .ps-photo-grid, .ps-business-tile, .ps-post-actions, .ps-post-cta,
  .ps-post-engagement, .ps-comments { min-width: 0 !important; max-width: 100% !important; }
  .ps-social .ps-post-body h3, .ps-social .ps-review-copy,
  .pr-review-card h3, .pr-review-card p { overflow-wrap: anywhere; }

  /* Anchor to CSS viewport, not visualViewport.offsetLeft or scrolled document. */
  body #pesyjeMobileFooter.pesyje-mobile-footer,
  body #pesyjeMobileFooter.pesyje-mobile-footer.collapsed {
    position: fixed !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: max(7px, env(safe-area-inset-bottom, 0px)) !important;
    margin: 0 !important;
    padding: 0 !important;
    width: calc(100% - 16px) !important;
    max-width: 520px !important;
    min-width: 0 !important;
    height: 75px !important;
    max-height: 75px !important;
    box-sizing: border-box !important;
    transform: translateX(-50%) !important;
    scale: 1 !important;
    zoom: 1 !important;
    z-index: 2147483000 !important;
    pointer-events: none !important;
  }
  body #pesyjeMobileFooter .pesyje-mobile-footer-shell,
  body #pesyjeMobileFooter.collapsed .pesyje-mobile-footer-shell {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    align-items: center !important;
    justify-content: stretch !important;
    gap: 0 !important;
    width: 100% !important;
    height: 75px !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: 75px !important;
    margin: 0 !important;
    padding: 5px 4px !important;
    border-radius: 24px !important;
    box-sizing: border-box !important;
    pointer-events: auto !important;
  }
  body #pesyjeMobileFooter .pesyje-mobile-item,
  body #pesyjeMobileFooter .pesyje-mobile-item-button,
  body #pesyjeMobileFooter .pesyje-mobile-center {
    display: flex !important;
    position: relative !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    height: 63px !important;
    min-height: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 1px !important;
    box-sizing: border-box !important;
    font-size: inherit !important;
    text-align: center !important;
    transform: none !important;
  }
  body #pesyjeMobileFooter .pesyje-mobile-item > span:last-child,
  body #pesyjeMobileFooter.collapsed .pesyje-mobile-item > span:last-child,
  body #pesyjeMobileFooter .pesyje-mobile-center-label,
  body #pesyjeMobileFooter.collapsed .pesyje-mobile-center-label {
    display: block !important;
    position: static !important;
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: clamp(9px, 2.6vw, 11px) !important;
    line-height: 1.2 !important;
    font-weight: 750 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  body #pesyjeMobileFooter .pesyje-mobile-item-icon {
    width: 30px !important;
    height: 30px !important;
    flex: none !important;
    font-size: 19px !important;
  }
  body #pesyjeMobileFooter .pesyje-mobile-center {
    justify-content: flex-end !important;
    padding-bottom: 2px !important;
  }
  body #pesyjeMobileFooter .pesyje-mobile-center-circle,
  body #pesyjeMobileFooter.collapsed .pesyje-mobile-center-circle {
    position: static !important;
    display: grid !important;
    place-items: center !important;
    flex: none !important;
    width: 43px !important;
    height: 43px !important;
    margin: 0 auto 1px !important;
    border-radius: 50% !important;
    border-width: 3px !important;
    font-size: 17px !important;
    transform: none !important;
  }
  /* Prevent content overlapping the dock when the phone keyboard is open. */
  body.pyv3-keyboard-open #pesyjeMobileFooter { display: none !important; }
  .ps-social .ps-tabs, .ps-profile-tabs, .pr-tabs {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    scrollbar-width: thin;
    overscroll-behavior-inline: contain;
  }
  .ps-social .ps-tabs > *, .ps-profile-tabs > *, .pr-tabs > * { flex-shrink: 0; }
}

/* Preserve independent, readable dock appearance in both theme modes. */
@media screen and (max-width: 991px) {
  html[data-pesyje-theme="light"] #pesyjeMobileFooter .pesyje-mobile-footer-shell {
    background: rgba(255,255,255,.97) !important;
    border-color: rgba(7,78,85,.12) !important;
    color: #253a40 !important;
  }
  html[data-pesyje-theme="dark"] #pesyjeMobileFooter .pesyje-mobile-footer-shell {
    background: linear-gradient(180deg, rgba(29,43,49,.99), rgba(12,25,30,.99)) !important;
    border-color: #3c5158 !important;
    color: #eaf3f4 !important;
  }
  html[data-pesyje-theme="dark"] .ps-social .ps-section-title,
  html[data-pesyje-theme="dark"] .ps-social .ps-feed-title,
  html[data-pesyje-theme="dark"] .ps-social .ps-timeline-title,
  html[data-pesyje-theme="dark"] .pr-main .pr-section-title {
    color: #f1f7f8 !important;
  }
}

/* Install/update should be accessible on mobile without covering the dock. */
#pesyjePwaV3Update {
  position: fixed;
  z-index: 2147483900;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 28px));
  padding: 11px 12px;
  border: 1px solid rgba(12,145,140,.34);
  border-radius: 16px;
  background: #fff;
  color: #152e34;
  box-shadow: 0 16px 35px rgba(0,0,0,.22);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
#pesyjePwaV3Update[data-visible="true"] { display: flex; }
#pesyjePwaV3Update span { font-weight: 700; font-size: 12px; }
#pesyjePwaV3Update button {
  border: 0; border-radius: 9px; padding: 8px 10px;
  font-weight: 700; font-size: 11px; cursor: pointer;
}
#pesyjePwaV3Update button[data-action="update"] { background: #078f88; color: #fff; }
#pesyjePwaV3Update button[data-action="later"] { background: #edf4f4; color: #36464b; }
html[data-pesyje-theme="dark"] #pesyjePwaV3Update {
  background: #202f35; color: #f5f9fa; border-color: #47676e;
}
html[data-pesyje-theme="dark"] #pesyjePwaV3Update button[data-action="later"] {
  color: #eff7f8; background: #40545a;
}
@media (prefers-reduced-motion: reduce) {
  #pesyjeMobileFooter * { transition-duration: 0s !important; animation-duration: 0s !important; }
}
