/*
 * Coffee Buddy 0.11.409 – iOS Home-Screen PWA top-edge stabilization.
 *
 * iOS 27 can apply a strong system scroll-edge blur over edge-to-edge web apps.
 * A real, viewport-constrained solid edge layer keeps that system treatment from
 * sampling/blurring the map and the controls underneath it. The layer is only
 * enabled for standalone WebKit PWAs; Safari tabs and non-WebKit browsers keep
 * their existing presentation.
 */
.ios-pwa-top-edge-shield {
  display: none;
}

@supports (-webkit-touch-callout: none) {
  @media (display-mode: standalone) {
    .ios-pwa-top-edge-shield {
      display: block;
      position: fixed;
      inset: 0 0 auto 0;
      height: max(44px, calc(env(safe-area-inset-top, 0px) + 4px));
      background: #e9e3d7;
      z-index: 840;
      pointer-events: none;
      transform: translateZ(0);
    }

    /*
     * Keep our own translucent top controls stable as well. Their nearly opaque
     * backgrounds remain unchanged; only local backdrop sampling is disabled on
     * the affected standalone-iOS surface.
     */
    .floating-toolbar .toolbar-button,
    .map-search-field,
    .profile-menu,
    .buddy-card .buddy-bubble {
      -webkit-backdrop-filter: none !important;
      backdrop-filter: none !important;
    }
  }
}

/*
 * Coffee Buddy 0.11.410/0.11.411 – keep interactive top controls out of iOS' system
 * scroll-edge blur zone. 0.11.409 made the sampled background stable, but on
 * current iPhone Home-Screen PWAs the OS blur can extend a little below the
 * safe-area itself. Reserve a small standalone-only clearance instead of
 * trying to fight the system overlay.
 */
@supports (-webkit-touch-callout: none) {
  @media (display-mode: standalone) and (max-width: 820px) {
    :root {
      --cb-ios-pwa-top-control-clearance: 15px;
    }

    /* 0.11.411: keep the native iOS edge treatment over the map itself.
     * The solid 0.11.409 shield created a visible horizontal band; controls now
     * sit below the blur zone, so the shield is intentionally disabled. */
    .ios-pwa-top-edge-shield {
      display: none !important;
    }

    .buddy-card {
      top: calc(10px + env(safe-area-inset-top) + var(--cb-ios-pwa-top-control-clearance)) !important;
    }

    .floating-toolbar {
      top: calc(9px + env(safe-area-inset-top) + var(--cb-ios-pwa-top-control-clearance)) !important;
    }

    .profile-menu,
    .map-search-control {
      top: calc(9px + env(safe-area-inset-top) + var(--cb-ios-pwa-top-control-clearance)) !important;
    }

    .weather-panel {
      top: calc(169px + env(safe-area-inset-top) + var(--cb-ios-pwa-top-control-clearance)) !important;
    }
  }
}
