/* MUSIC FM Classic — iOS Home Screen status bar + calm page navigation (v3).
 * Only installed iOS Home Screen apps are affected. The public layout, desktop,
 * mobile Safari and approved site-wide animations remain unchanged.
 *
 * IMPORTANT: chrome.css sets the canonical mobile header to position:fixed.
 * Its body offset, header height and transition top must be IDENTICAL. Avoid
 * mismatched defaults or geometry changes during each PHP document load.
 */
@media (max-width: 980px) {
  html.mf-ios-home-screen {
    --mf-app-status-navy: #061a33;
    background-color: var(--mf-app-status-navy) !important;
    scroll-padding-top: var(--mf-ui-header-bottom) !important;
  }

  /* Keep the fallback below the native status bar navy. The editorial surface
     belongs to .site-shell; header and paper therefore have stable paint on
     every PHP navigation. The mobile header is FIXED; offset content exactly
     once by the real header height plus safe area, matching chrome.css. */
  html.mf-ios-home-screen body:not(.mf-admin) {
    padding-top: var(--mf-ui-header-bottom) !important;
    background: var(--mf-app-status-navy) !important;
  }
  html.mf-ios-home-screen body:not(.mf-admin) > .site-shell {
    background:
      radial-gradient(circle at 16% 0%, rgba(89,199,255,.045), transparent 32%),
      linear-gradient(180deg,#f8fafc 0%,var(--mf-ui-page,#f5f7fa) 34%,#f4f7fa 100%) !important;
  }

  /* One authoritative geometry: chrome.css defines 72px on mobile.
     The fixed header, body offset, nav height and overlay share that value. */
  html.mf-ios-home-screen {
    --mf-ui-header-bottom: calc(var(--mf-ref-header-mobile-h,72px) + env(safe-area-inset-top,0px));
  }
  html.mf-ios-home-screen body:not(.mf-admin) .site-header.v4-site-header,
  html.mf-ios-home-screen body.scrolled:not(.mf-admin) .site-header.v4-site-header {
    box-sizing: border-box !important;
    position: fixed !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    height: var(--mf-ui-header-bottom) !important;
    min-height: var(--mf-ui-header-bottom) !important;
    padding-top: env(safe-area-inset-top,0px) !important;
    background: linear-gradient(180deg,#061a33,#031225) !important;
    opacity: 1 !important;
  }
  html.mf-ios-home-screen body:not(.mf-admin) .site-header.v4-site-header .v4-nav-shell {
    height: var(--mf-ref-header-mobile-h,72px) !important;
    min-height: var(--mf-ref-header-mobile-h,72px) !important;
  }

  /* Restore the quiet existing page-to-page cover without covering the status
     area or dark header. The header never moves or fades on navigation.
     The animation is clipped to the paper *below* the real header edge. */
  html.mf-ios-home-screen body:not(.mf-admin) .mf-page-transition {
    inset: var(--mf-ui-header-bottom) 0 0 !important;
    background: #f8fafc !important;
    display: none !important;
  }
}

/* Error documents do not include the shared header. */
@media (display-mode: standalone) and (max-width: 980px) {
  body.mf-error-page { padding-top: env(safe-area-inset-top,0px); }
  body.mf-error-page::before {
    content: '';
    position: fixed;
    inset: 0 0 auto;
    height: env(safe-area-inset-top,0px);
    background: #061a33;
    pointer-events: none;
    z-index: 2147480000;
  }
}
